gpt4 book ai didi

Emacs 组织模式 : How can i fold everything but the current headline?

转载 作者:行者123 更新时间:2023-12-02 10:50:37 28 4
gpt4 key购买 nike

我使用组织模式来处理多个文件中的任务和项目。

在每周议程中,可以使用 <TAB> 跳转到每个 TODO 条目的位置。或<RET> 。如果目标文件之前未打开,则会加载该文件,并将光标设置到正确的标题,并且整个文档展开,包括抽屉

我非常希望只看到一棵稀疏的树,其中除了正确的标题之外的所有内容都被折叠(子树可见性并不重要)。

可以通过使用 C-u <TAB 循环全局可见性来折叠整个树。 ,但随后我必须再次找到标题。

我知道我可以通过缩小缓冲区来隐藏其余部分,如下所述: Emacs, How can I display only current task and hide others in org-mode?但随后我失去了上下文(父标题,轻松访问 sibling )并且抽屉仍然打开。

理想情况下,我希望有一个显示以下内容的命令:

  • 顶级标题
  • 当前标题及其所有上层内容
  • 当前标题的子级

编辑:

函数 user3173715 的稍微修改版本发布似乎可以解决问题:

(defun org-show-current-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-back-to-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)))

最佳答案

这是基于实际问题编辑中的答案。

如果对任何人有帮助:当我尝试将上面的内容绑定(bind)到热键时,我不断收到错误,命令错误的参数某事......事实证明必须添加(交互式)标志才能使其工作。下面是与 M-= 相关的函数示例

(defun org-show-current-heading-tidily ()
(interactive) ;Inteactive
"Show next entry, keeping other entries closed."
(if (save-excursion (end-of-line) (outline-invisible-p))
(progn (org-show-entry) (show-children))
(outline-back-to-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)))

(global-set-key "\M-=" 'org-show-current-heading-tidily)

@Patrick.B 感谢您的编辑!

关于Emacs 组织模式 : How can i fold everything but the current headline?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25161792/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com