当我编辑大型文档时,我想通过在单独的缓冲区中看到轮廓(没有内容)来查看我的位置。就像您阅读PDF文件时一样,左侧有一个目录。(见下文)
在组织模式下,可以展开/折叠轮廓。但是是否有可能在单独的缓冲区的左侧(或右侧)具有静态轮廓,以便当您单击标题时,另一个缓冲区移至该位置?
有点像这样,但对于组织模式?
[编辑]
将clone-indirect-buffer
是非常接近我想要的东西。难题的缺失部分是单击标题/(或实际上是任何一点)时跳转到相同的位置。
为此,我尝试编写一些代码:移动到其他克隆的缓冲区到同一点?(间接缓冲区的同步位置)(组织模式)
但是,如果内容被折叠,它将不起作用。如果可以做到这一点,那么clone-inderect-buffer就是一个完整的解决方案。
[Edit2解决方案]
上方链接和下方答案中的代码结合了niceley来解决来回跳转的问题。
;first call 'clone-indirect-buffer'. Then...
;This function works between buffer and it's clone.
(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)
(when (invisible-p (point))
(org-reveal)))
)
;This function is a clone-to-buffer jump only:
; It does find the other buffer first thou instead of just jumping to the other
; window as does the function above.
(defun my/jump-to-point-and-show ()
"Switch to a cloned buffer's base buffer and move point to the
cursor position in the clone."
(interactive)
(let ((buf (buffer-base-buffer)))
(unless buf
(error "You need to be in a cloned buffer!"))
(let ((pos (point))
(win (car (get-buffer-window-list buf))))
(if win
(select-window win)
(other-window 1)
(switch-to-buffer buf))
(goto-char pos)
(when (invisible-p (point))
(show-branches)))))
(global-set-key (kbd "<s-mouse-1>") 'my/goto-same-spot-in-other-buffer)
(global-set-key (kbd "s-m") 'my/goto-same-spot-in-other-buffer)
(global-set-key (kbd "<C-s-mouse-1>") 'my/jump-to-point-and-show)
(global-set-key (kbd "C-s-m") 'my/jump-to-point-and-show)
org-sparse-tree-to-indirect-buffer
例如,我们需要的是一个函数,但是它似乎不存在。
C-c C-x b
,或者org-tree-to-indirect-buffer
。