Org自动编号列表使用

huangapple go评论61阅读模式
英文:

Org auto numbering of list with <RET>

问题

假设我有以下Org文件:

一些内容
1. 一些X

假设我的光标在“X”所在位置,我处于插入模式(我在Emacs中使用Evil模式)。现在,如果我按<kbd>M-RET</kbd>,我将得到一个自动编号的列表,如下所示:

一些内容
1. 一些X
2. 

我的问题是,如何只使用<kbd>RET</kbd>实现这一功能,而不使用<kbd>M-RET</kbd>?

  1. 这对我来说似乎更自然,也是一个更明智的默认设置。
  2. 我经常忘记按<kbd>M-RET</kbd>,而按<kbd>RET</kbd>,然后想知道为什么它不起作用。
英文:

Lets say I have the following Org file:

Bla bla bla
1. BlaX

And let's say my cursor is where "X" is, and I am in insert mode (I use Evil mode in Emacs). Now, if I press <kbd>M-RET</kbd> I will get auto numbers in a list like this:

Bla bla bla
1. BlaX
2. 

My question is, how can I make it happen with just <kbd>RET</kbd> and not <kbd>M-RET</kbd>?

  1. It just seems more natural to me and a more sane default.
  2. I am constantly forgetting to do <kbd>M-RET</kbd> and do a <kbd>RET</kbd> and wonder why its not working.

答案1

得分: 1

以下是已翻译的部分:

最简单的方法,我认为,是检查<kbd>M-RET</kbd>绑定到哪个函数,然后将<kbd>RET</kbd>绑定到它。例如,如果<kbd>C-h c</kbd> <kbd>M-RET</kbd> 输出“org-meta-return”,那么可以使用以下配置:

(define-key org-mode-map (kbd "RET") #'org-meta-return)

但事情可能比这复杂一些,所以有可能需要调整更多设置。这是因为org-mode添加了相当多的配置“糖”。为了处理这一点,请仔细阅读绑定函数的文档,以解决所有令人困惑的键绑定。

一个明显的例子:<kbd>C-h f</kbd> org-return-and-maybe-indent 显示缩进行为可能受到许多影响。具体来说,

> 在插入新行时,如果‘org-adapt-indentation’为t:如果‘electric-indent-mode’被禁用,则缩进该行,如果启用则不缩进。

我的一个小速查表也许有助于解决这个问题。

英文:

The simplest approach, I think, would be to check to which function <kbd>M-RET</kbd> is bound, and then bind <kbd>RET</kbd> to it instead. For instance, if <kbd>C-h c</kbd> <kbd>M-RET</kbd> outputs "org-meta-return", then use this configuration:

(define-key org-mode-map (kbd &quot;RET&quot;) #&#39;org-meta-return)

But the full story may be a bit more complex than that, so there's a chance you'd need more settings tweaked. This is a case because org-mode has quite a lot of configurational "sugar" added. To handle that, read a bound function's documentation carefully for every confusing keybinding.

One bright example: <kbd>C-h f</kbd> org-return-and-maybe-indent reveals indentation behavior can have many influencers. Namely,

> When inserting a newline, if ‘org-adapt-indentation’ is t: indent the
> line if ‘electric-indent-mode’ is disabled, don’t indent it if it is
> enabled.

A small cheatsheet of mine might help figuring that out.

huangapple
  • 本文由 发表于 2023年5月18日 13:40:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76278031.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定