[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: associating bookmarks with paragraphs

From: Drew Adams
Subject: RE: associating bookmarks with paragraphs
Date: Thu, 6 Dec 2018 16:42:20 +0000 (UTC)

> 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

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.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]