如何让当前子树更清晰可识别?
将“行号”加粗是好的,或者只是强调当前子树的整个文本也会很好。
我的意思是,有人可以帮我提供一些 elisp 代码吗?实现这一点(例如,强调整个子树)?
我无法向您展示下划线,因此我粗体示例:
* [1]这是一个子树
一些文字
** [1.1]子树n°2
和文字
*** [1.1.1]子树你好
** [2]度过愉快的一天
答案 0 :(得分: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)))
结果应该是这样的