5

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.

Drew
  • 75,699
  • 9
  • 109
  • 225
Leo Ufimtsev
  • 4,488
  • 3
  • 22
  • 45
  • 1
    Does calling `(org-reveal)` or `(show-all)` first help? I haven't tried it. [Reference](http://orgmode.org/manual/Global-and-local-cycling.html#Global-and-local-cycling). – 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

1 Answers1

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.

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
  • Thank you. Btw, this was actually a sub-question of :http://emacs.stackexchange.com/questions/9530/org-mode-is-it-possible-to-see-only-outline-in-2nd-buffer-like-dynamic-table – Leo Ufimtsev Feb 24 '15 at 18:22