all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Michael Maurer <maurer.michael@gmail.com>, help-gnu-emacs@gnu.org
Subject: RE: associating bookmarks with paragraphs
Date: Thu, 6 Dec 2018 16:42:20 +0000 (UTC)	[thread overview]
Message-ID: <bf3ce0ca-85a4-41e8-8e23-80ba860e1ec6@default> (raw)
In-Reply-To: <CAH-0+bCEOaUfAts1Ro6i-C7pb5tgz02s__+F3ZcxutSCJkKNcw@mail.gmail.com>

> as far as I know, the bookmark option is tied to a line
> number. is it possible to associate it with a paragraph,
> so when you cut and paste the paragraph to a different
> position in your document, the bookmark moves with it?

Emacs bookmarks (but perhaps not Org or EWW "bookmarks" -
can't speak for those) can bookmark pretty much anything.

By default, they bookmark a single position in a buffer,
typically a file buffer, not a line number.

The position is recorded, but so (by default) are some
text before and after the position.  If, when you jump
to a bookmark, the bookmarked position is not between
such text snippets then Emacs tries to reposition the
bookmark position, by searching forward and backward
for those saved text sequences (context).

It's not clear to me what you want to bookmark:

(1) A snippet of text that you (by jumping to the
    bookmark) paste here and there?
(2) Automatic relocation of a bookmarked position
    (e.g. of a paragraph)?
(3) Something else?

1. If you use Bookmark+ then you can do #1 by using a
snippet bookmark.  That records a snippet of text (e.g.
your paragraph), and when you jump to the bookmark that
text gets copied to the `kill-ring', so you can paste
it anywhere.

You can create (set) a snippet bookmark using command
`bmkp-set-snippet-bookmark', bound by default to
`C-x p c M-w' (bookmark-creation commands are put on
prefix key `C-x p c', by default).

You can jump to (i.e., use) a snippet bookmark using
command `bmkp-snippet-to-kill-ring', bound by default
to `C-x j M-w' (bookmark-jump commands are put on
prefix key `C-x j', by default).

(Or you can jump to it using the ordinary command
`bookmark-jump', which is bound by default to `C-x j j'.
But in that case the available bookmark-name completion
candidates are all bookmarks, not just snippet bookmarks.)

But you also say "so when you cut and paste the paragraph
to a different position in your document, the bookmark
moves with it."  That's unclear - makes no sense to me.
When you use a snippet bookmark the bookmarked snippet of
text becomes available for pasting.  When you paste that
text no bookmark is created in the buffer where you paste
it.  What bookmark do you want to "move with" the pasted
text?

2. But maybe you meant something completely different.
Maybe meant only that you want to bookmark the position
of a paragraph and then jump to that later, and have that
jump be accurate even if that paragraph has been moved
to a different location in your buffer/file?

If that's all you're asking then the answer is yes, that's
what Emacs does already - see above, about automatically
relocating a bookmarked position by searching for its
recorded context.

However, if the recorded context is no longer relevant
at all then Emacs won't be able to relocate the new
position accurately.

There is another possibility that can help here.  With
Bookmark+ you can bookmark not only a single position,
with its surrounding context, but two positions, with
their surrounding context.

This happens if you bookmark the active region, i.e.,
select your paragraph before bookmarking it.

If option `bmkp-use-region' is non-nil (the default)
then when you jump to a bookmark that records the
region (beginning and end positions, and surrounding
text), the targeted text that you jump to is highlighted
as the active region.

---

You can also define your own region handler for
bookmarks that record regions.  (This is in addition to
being able to define bookmark handlers.)  Use option
`bmkp-handle-region-function' for this.  As one example,
command `bmkp-region-jump-narrow-indirect-other-window'
binds the option to a function that narrows the targeted
region in a cloned indirect buffer.  (You need library
`narrow-indirect.el' for that command.)

https://www.emacswiki.org/emacs/BookmarkPlus



  parent reply	other threads:[~2018-12-06 16:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06  8:02 associating bookmarks with paragraphs Michael Maurer
2018-12-06 16:39 ` Eric Abrahamsen
2018-12-06 16:42 ` Drew Adams [this message]
2018-12-11  8:03   ` Michael Maurer
2018-12-11 16:03     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf3ce0ca-85a4-41e8-8e23-80ba860e1ec6@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=maurer.michael@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.