UP | HOME

▼ 本文更新于 [2026-03-17 周二 16:13]

emacs-修复org-habit的链接face继承问题


长话短说:在org-habit中,如果你的任务标题为单纯的一个链接,则会发现在标题到habit graph之间的填充空格都继承了标题的链接face。

请用以下代码修复:

(defun my/org-habit-prevent-underline-leak (orig-fn &rest args)
  "防止 org-habit 插入对齐空格时继承链接的下划线(face等属性)。"
  (let ((text-property-default-nonsticky
         ;; 临时声明这四个属性在插入新文本时不向后继承
         (append '((face . t)
                   (mouse-face . t)
                   (keymap . t)
                   (help-echo . t))
                 text-property-default-nonsticky)))
    ;; 执行原本的 org-habit-insert-consistency-graphs 函数
    (apply orig-fn args)))

;; 使用 Advice 包装该函数
(advice-add 'org-habit-insert-consistency-graphs :around #'my/org-habit-prevent-underline-leak)

© Published by Emacs 31.0.50 (Org mode 10.0-pre) | RSS Comment