4

I like to clone-indirect-buffer . But then once in a while, I want to move to the other buffer and go to the same position as in the previous marker.

This is usually the case when I use the indirect buffer as an 'outline' and want to s-mouse-1 to move the other buffer to the same spot.

I tried to hack together the following:

(defun my/goto-same-spot-in-other-buffer () 
  "Go to the same location in the other buffer. Useful for when you have cloned indirect buffers"
  (interactive)
  (let ((my/goto-current-point (point)))
       (other-window 1)
       (goto-char my/goto-current-point)
       (org-reveal))
)

But it doesn't work properly if the other buffer's content isn't fully expanded. I.e it doesn't jump into content that is collapsed.

[edit]
org-reveal did the job. (added to the code above). Can the above be modified so that it expands sections properly if they are not expanded?

[edit2]
This may be of interest to future readers. In this post it dissucsses a dynamic TOC where I use the function above as well as another function that first finds the other buffer. You might want to check it out.

  • 1
    Does calling (org-reveal) or (show-all) first help? I haven't tried it. Reference. – Kaushal Modi Feb 24 '15 at 17:47
  • org-reveal did the trick. Thank you. If you post it as answer, I will accept it. – Leo Ufimtsev Feb 24 '15 at 18:08
4

From the org-mode global/local cycling documentation, the org-reveal command should do the trick.

Reveal context around point, showing the current entry, the following heading and the hierarchy above. Useful for working near a location that has been exposed by a sparse tree command (see Sparse trees) or an agenda command (see Agenda commands). With a prefix argument show, on each level, all sibling headings. With a double prefix argument, also show the entire subtree of the parent.

So call (org-reveal) in the elisp.

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.