gpt4 book ai didi

emacs - 更改段落的定义(例如在 org-mode 中)

转载 作者:行者123 更新时间:2023-12-04 18:48:32 26 4
gpt4 key购买 nike

我想使用 mark-paragraph (也适用于向前/向后段落的移动)在 org-mode 缓冲区中的方式与在其他主要模式中相同,即标记由空行分隔的连续区域。这也应该适用于标题、列表项、以“#”开头的行等——即,出于段落编辑的目的,我希望将所有内容都视为常规文本。

这可能吗?

最佳答案

查看变量 paragraph-startparagraph-separate , 也可能是 use-hard-newlines相关的功能(但在这种情况下可能实际上并不相关)。

(defun use-default-paragraph-delimiters ()
(setq paragraph-start (default-value 'paragraph-start)
paragraph-separate (default-value 'paragraph-separate)))

(add-hook 'org-mode-hook 'use-default-paragraph-delimiters)

编辑:不可否认,org-mode 可能不仅仅依赖于它的段落定义来进行交互式标记和移动,因此这里有一种更有针对性的方法,用于仅在使用它们的键绑定(bind)交互调用时为这些命令自定义段落定义。

(defmacro with-default-paragraph-definition (&rest body)
"Evaluate body forms using the default definition of a paragraph."
`(let ((paragraph-start (default-value 'paragraph-start))
(paragraph-separate (default-value 'paragraph-separate)))
,@body))

(defalias 'my-org-mark-paragraph 'mark-paragraph)
(defadvice my-org-mark-paragraph
(around my-org-mark-paragraph-advice activate)
(with-default-paragraph-definition ad-do-it))

(defalias 'my-org-forward-paragraph 'forward-paragraph)
(defadvice my-org-forward-paragraph
(around my-org-forward-paragraph-advice activate)
(with-default-paragraph-definition ad-do-it))

(defalias 'my-org-backward-paragraph 'backward-paragraph)
(defadvice my-org-backward-paragraph
(around my-org-backward-paragraph-advice activate)
(with-default-paragraph-definition ad-do-it))

(defun my-org-paragraph-overrides ()
"Use the default paragraph definitions in org-mode
when marking or moving by paragraph."
(local-set-key [remap mark-paragraph] 'my-org-mark-paragraph)
(local-set-key [remap forward-paragraph] 'my-org-forward-paragraph)
(local-set-key [remap backward-paragraph] 'my-org-backward-paragraph))

(add-hook 'org-mode-hook 'my-org-paragraph-overrides)

关于emacs - 更改段落的定义(例如在 org-mode 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9923540/

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