In elisp buffers, I use outline-mode in order to manage headings similarly as in org-mode. But when I jump to a bookmark which points to a hidden part of a buffer (because it is below a folded heading), the point ends up at the lowest visible heading which contains the bookmark position.

How can I unfold the corresponding part of the buffer and jump to the actual position of the buffer?

In org-mode however, the problem does not occur: we have the desired behavior.

  • When you say, "In org-mode...the problem does not occur", what do you mean? When you do what in Org mode? – Drew Oct 2 '18 at 21:32
  • I mean: when I jump to a bookmark which points to a hidden place in an org-mode buffer, then the corresponding part unfolds. – Joon Kwon Oct 4 '18 at 17:32

If you use Bookmark+ then you can add a bmkp-jump tag to any bookmark, to carry out any action just after that particular bookmark location is jumped to.

Give this tag a value that is a function, which then is called whenever the tagged bookmark is visited. Any Lisp-readable function value is allowed: a symbol or a lambda expression.

For example, to display Hello! when a bookmark is visited you can use this on that bookmark in the bookmark-list display:

T v bmkp-jump RET (lambda () (message "Hello!"))

That prompts you for the name of the bookmark to add that jump-function to as the value of tag bmkp-jump.

T v is bound in the bookmark-list display to command bmkp-set-tag-value. Elsewhere, the command is bound to C-x p t v. It adds a value to a tag that has none, or it changes the current value of a tag.

The function that is the value of a bmkp-jump tag is called just after the the standard hook bookmark-after-jump-hook is invoked. You can use this tag to invoke functions that are specific to individual bookmarks; bookmarks can thus have their own, extra jump functions.

So you just need a function that unfolds/unhides the current bit of text that you want to show. Use that in place of the function shown above. Try function outline-show-entry, for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.