org给header标题添加鼠标点击自动展开

灵感来自org-bullets,另外参考了Adding keymaps to src blocks via org-font-lock-hook 搜索了下论坛好像没人发过?

(use-package org
  :defer t
  :config
  (defvar org-level-click-map '(keymap (mouse-1 . org-cycle))
    "")
  (defun org-add-keymap-to-level (limit)
    (let ((case-fold-search t))
      (while (re-search-forward org-heading-regexp limit t)
        (put-text-property
         (match-beginning 0)
         (match-end 0)
         'keymap
         org-level-click-map))))
  (add-hook 'org-font-lock-hook #'org-add-keymap-to-level))

效果如图:

orggif

4 个赞

这个不错~收了, 谢谢