3

我为 Org-mode 找到了这个漂亮的小功能:

;;; Move to next heading with dedicated buffer preview
(defun ded/org-show-next-heading-tidily ()
  "Show next entry, keeping other entries closed."
  (if (save-excursion (end-of-line) (outline-invisible-p))
      (progn (org-show-entry) (show-children))
    (outline-next-heading)
    (unless (and (bolp) (org-on-heading-p))
      (org-up-heading-safe)
      (hide-subtree)
      (error "Boundary reached"))
    (org-overview)
    (org-reveal t)
    (org-show-entry)
    (show-children)))

它从一个标题移动到另一个标题,并显示其直接内容和子项。我喜欢这个想法,但更希望它显示在专用缓冲​​区中,使用(org-tree-to-indirect-buffer).

我试着这样做:

(defun ded/org-show-next-heading-test ()
  "Show next entry, keeping other entries closed."
  (if (save-excursion (end-of-line) (outline-invisible-p))
      (progn (org-show-entry) (org-tree-to-indirect-buffer))
    (outline-next-heading)
    (unless (and (bolp) (org-on-heading-p))
      (org-up-heading-safe)
      (hide-subtree)
      (error "Boundary reached"))
    (org-overview)
    (org-reveal t)
    (org-tree-to-indirect-buffer)
    (show-children)))

但是然后我必须双击该键-一旦它在专用缓冲​​区中显示条目,然后它仍然显示该条目。我试图删除该progn功能,但后来它并没有完全起作用。

我不是一个 lisp 程序员,我试着用它玩了一个小时左右但无济于事,所以我希望有经验的人帮我解决这个问题 :)

非常感谢。

4

2 回答 2

2

不太确定你想要什么,但据我所知,你应该org-tree-to-indirect-buffer在最后打电话:

;;; Move to next heading with dedicated buffer preview
(defun ded/org-show-next-heading-tidily ()
  "Show next entry, keeping other entries closed."
  (if (save-excursion (end-of-line) (outline-invisible-p))
      (progn (org-show-entry) (show-children))
    (outline-next-heading)
    (unless (and (bolp) (org-on-heading-p))
      (org-up-heading-safe)
      (hide-subtree)
      (error "Boundary reached"))
    (org-overview)
    (org-reveal t)
    (org-show-entry)
    (show-children)
    (org-tree-to-indirect-buffer)))

如果这不是您想要的,那么您能否提供更多详细信息。

于 2012-10-16T13:29:38.397 回答
1

我最终制作了自己的简单功能,以便更轻松地导航:

(defun forward-and-preview ()
    "Go to same level next heading and show preview in dedicated buffer"
    (hide-subtree)
    (org-speed-move-safe (quote outline-next-visible-heading))
    (show-children)
    (org-tree-to-indirect-buffer)
    )
(defun back-and-preview ()
    "Go to same level previous heading and show preview in dedicated buffer"
    (hide-subtree)
    (org-speed-move-safe (quote outline-previous-visible-heading))
    (show-children)
    (org-tree-to-indirect-buffer)
    )
(defun up-back-and-preview ()
    "Go to previous level heading and show preview in dedicated buffer"
    (org-speed-move-safe (quote outline-up-heading))
    (org-tree-to-indirect-buffer)
    (hide-subtree)
    )
(defun up-forward-and-preview ()
    "Go to previous level next heading and show preview in dedicated buffer"
    (org-speed-move-safe (quote outline-up-heading))
    (hide-subtree)
    (org-speed-move-safe (quote outline-next-visible-heading))
    (org-tree-to-indirect-buffer)
    )
(defun inside-and-preview ()
    "Go to next level heading and show preview in dedicated buffer"
    (org-speed-move-safe (quote outline-next-visible-heading))
    (show-children)
    (org-tree-to-indirect-buffer)
    )
(add-to-list 'org-speed-commands-user '("l" inside-and-preview))
(add-to-list 'org-speed-commands-user '("j" forward-and-preview))
(add-to-list 'org-speed-commands-user '("k" back-and-preview))
(add-to-list 'org-speed-commands-user '("J" up-forward-and-preview))
(add-to-list 'org-speed-commands-user '("K" up-back-and-preview))
于 2012-10-16T15:03:37.883 回答