8

如何使当前子树更清晰可识别?

使“行号”粗体是可以的,或者只是在当前子树的整个文本下划线也很好。

我的意思是,有人可以帮我提供一些elisp代码吗?实现这一点(例如,强调整个子树)?


我不能给你看下划线,所以我加粗了这个例子:

* [1] 这是一个子树

一些文字

** [1.1] 子树 n°2

还有文字

*** [1.1.1]子树你好

** [2] 祝你有美好的一天

4

1 回答 1

2

加载以下定义

(defun org-subtree-highlight-find-overlay (p1 p2)
  "Find an overlay with property 'org-subtree-highlight-overlay"
  (defun org-subtree-highlight-find-overlay01 (overlays)
    (if overlays
    (let ((ov (car overlays)))
      (if (overlay-get ov 'org-subtree-highlight-overlay)
          ov
        (org-subtree-highlight-find-overlay01 (cdr overlays))))
      nil))
  (org-subtree-highlight-find-overlay01 (overlays-in p1 p2)))

(defun org-subtree-highlight-toggle ()
  "Toggle subtree highlighting"
  (interactive)
  (save-excursion
    (let* ((p1 (progn (org-back-to-heading t) (point)))
       (p2 (progn (outline-next-visible-heading 1)
              (if (and (org-at-heading-p) (not (eobp))) (backward-char 1))
              (point)))
       (ov (org-subtree-highlight-find-overlay p1 p2)))
      (if ov
      (delete-overlay ov)
    (setq ov (make-overlay p1 p2))
    (overlay-put ov 'org-subtree-highlight-overlay t)
    ;; set a format for the subtree (can be also 'bold)
    (overlay-put ov 'font-lock-face 'underline)))))

;; keybindin example
(add-hook 'org-mode-hook
      (lambda ()
        (local-set-key "\C-c\C-h" 'org-subtree-highlight-toggle)))

结果应该是这样的

emacs 截图

于 2012-12-28T16:20:00.070 回答