* associating bookmarks with paragraphs @ 2018-12-06 8:02 Michael Maurer 2018-12-06 16:39 ` Eric Abrahamsen 2018-12-06 16:42 ` Drew Adams 0 siblings, 2 replies; 5+ messages in thread From: Michael Maurer @ 2018-12-06 8:02 UTC (permalink / raw) To: help-gnu-emacs 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? or maybe there's a different function in place which is more appropriate for that purpose. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: associating bookmarks with paragraphs 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 1 sibling, 0 replies; 5+ messages in thread From: Eric Abrahamsen @ 2018-12-06 16:39 UTC (permalink / raw) To: help-gnu-emacs Michael Maurer <maurer.michael@gmail.com> writes: > 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? Bookmarks are implemented with markers, which do move with the surrounding text. Did you try your cut and paste test with a marker in a paragraph? The marker should move with it. When you save them, they're saved as absolute positions in the file, but even then some textual context is saved with them, to maximize the changes that the bookmark can be restored correctly. Eric ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: associating bookmarks with paragraphs 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 2018-12-11 8:03 ` Michael Maurer 1 sibling, 1 reply; 5+ messages in thread From: Drew Adams @ 2018-12-06 16:42 UTC (permalink / raw) To: Michael Maurer, help-gnu-emacs > 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: associating bookmarks with paragraphs 2018-12-06 16:42 ` Drew Adams @ 2018-12-11 8:03 ` Michael Maurer 2018-12-11 16:03 ` Drew Adams 0 siblings, 1 reply; 5+ messages in thread From: Michael Maurer @ 2018-12-11 8:03 UTC (permalink / raw) To: help-gnu-emacs On Thu, 6 Dec 2018 at 17:42, Drew Adams <drew.adams@oracle.com> wrote: ... snip ... > 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. > Yes, this is what I was aiming at. I'll give it a try. Just one question: How is Emacs able to determine the relevancy of context? I guess this only works with writing code? Doesn't this go into semantics? I'm probably mistaking "context" for something far more complicated here. ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: associating bookmarks with paragraphs 2018-12-11 8:03 ` Michael Maurer @ 2018-12-11 16:03 ` Drew Adams 0 siblings, 0 replies; 5+ messages in thread From: Drew Adams @ 2018-12-11 16:03 UTC (permalink / raw) To: Michael Maurer, help-gnu-emacs > Yes, this is what I was aiming at. I'll give it a try. > Just one question: How is Emacs able to determine the relevancy of > context? I guess this only works with writing code? Doesn't this go > into semantics? I'm probably mistaking "context" for something far > more complicated here. As I said, the bookmark records text immediately before and after the bookmarked position (or positions, if recording a region). When you jump to a bookmarked position, it looks for a match of the recorded text that was before and after the recorded position. If a match is found elsewhere (not at the recorded position) then it jumps to that found match position and asks you if you want to record that (i.e., update the bookmarked position and context text). ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-12-11 16:03 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2018-12-11 8:03 ` Michael Maurer 2018-12-11 16:03 ` Drew Adams
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.