在Emacs org-mode中折叠当前大纲

21

假设我在一个具有以下结构的org-mode文档中:

* First headline 
* Second headline
** Section A
   Here is one line
   Here is another line
   blah, blah
** Section B

假设光标位于读取“Here is another line”这一行,我想用快捷键折叠** Section A

  • 如果我按<TAB>,它不会折叠** Section A,因为我需要将光标放在星号上才能起作用。
  • 如果我按<Shift-TAB>,它会折叠所有大纲,而不是当前的大纲。

有没有办法在范围内(即“当前大纲”)中循环折叠大纲?


1
一旦它已经折叠到“**部分A”,你希望该命令展开该标题,还是折叠上一个标题(“第二个标题”)? - Jonathan Leech-Pepin
@JonathanLeech-Pepin 再次扩展它将是很棒的! - Amelio Vazquez-Reina
在这种情况下,@cyon的答案将完全做到这一点。 - Jonathan Leech-Pepin
3
谢谢,@JonathanLeech-Pepin。我怎样才能实现另一种方式?(即将下一个标题折叠起来) - Amelio Vazquez-Reina
2个回答

22
您可以通过更改org-cycle-emulate-tab的值来自定义org-cycle命令(绑定到<TAB>)。
要使其在光标位于Here is another line时折叠** Section A,请将以下行添加到您的.emacs文件中:
(setq org-cycle-emulate-tab 'white)

使用 white 可以让你在空行中仍然可以使用 <TAB> 进行缩进。来自 org-mode Github:

org-cycle-emulate-tab's value is t

Documentation:
Where should `org-cycle' emulate TAB.
nil         Never
white       Only in completely white lines
whitestart  Only at the beginning of lines, before the first non-white char
t           Everywhere except in headlines
exc-hl-bol  Everywhere except at the start of a headline

1
我觉得这并没有帮助。首先,我们有没有一个命令可以“折叠下一个标题”?编辑:找到了解决方法;) https://emacs.stackexchange.com/questions/41703/fold-the-immediate-outer-section-in-org-mode - Jason Hunter

4
如果您不介意分两步操作的话:
  1. C-c C-p将光标移动到上一个标题(在您的示例中为** Section A

  2. TAB:折叠该部分

只要您习惯了这种方法,它就不需要任何配置。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接