1

我想知道是否可以为大纲的不同级别设置不同的填充列值。目前我将其设置为 78,并且对于较低级别 (),该列的计数方式似乎不同,因此,较低级别的文本超过 78 列。

在邮件列表中提出了同样的问题,但没有回复: http: //lists.gnu.org/archive/html/emacs-orgmode/2011-05/msg00654.html

最好的,俊

4

1 回答 1

0

我添加了计算 apt 偏移量并调用常规组织填充的函数:

(defun calc-offset-on-org-level ()
  "Calculate offset (in chars) on current level in org mode file."
  (* (or (org-current-level) 0) org-indent-indentation-per-level))

(defun my-org-fill-paragraph (&optional JUSTIFY)
  "Calculate apt fill-column value and fill paragraph."
  (let* ((fill-column (- fill-column (calc-offset-on-org-level))))
    (org-fill-paragraph JUSTIFY)))

(defun my-org-auto-fill-function ()
  "Calculate apt fill-column value and do auto-fill"
  (let* ((fill-column (- fill-column (calc-offset-on-org-level))))
    (org-auto-fill-function)))

并在我的 .emacs 中设置 org-mode 以使用此功能(请参阅 org.el、org-setup-filling):

(defun my-org-mode-hook ()
  (setq fill-paragraph-function   'my-org-fill-paragraph
        normal-auto-fill-function 'my-org-auto-fill-function)

(add-hook 'org-load-hook 'my-org-mode-hook)
(add-hook 'org-mode-hook 'my-org-mode-hook)

结果我得到了(所见即所得):

* Top level heading
  This is sufficiently long string, and, as you see fill-column is not far
  from screen edge on the top level.  My fill-column value is 77.

        * Level 5
          Offset is 12 chars on this level, but we set there fill column to
          the 78 - 12 = 66 chars.

                                  * Derived 18 (?)
                                    Auto fill mode works too due to function
                                    my-org-auto-fill-function.
于 2013-08-29T14:12:09.457 回答