lang/org: make org-bullets respect org-hide

This commit is contained in:
Henrik Lissner 2017-05-04 08:57:51 +02:00
parent 0d53c3cbc7
commit 694e3c4e28

View file

@ -367,6 +367,30 @@
(org-remove-occur-highlights)))
(advice-add #'evil-force-normal-state :before #'+org*remove-occur-highlights)
;; Don't reset org-hide!
(advice-add #'org-find-invisible-foreground :override #'ignore))
(after! org-bullets
(define-minor-mode org-bullets-mode
"Modified version of `org-bullets-mode' that respects the `org-hide' face."
nil nil nil
(let* ((keyword
`((,org-outline-regexp-bol
(0 (let ((level (- (match-end 0) (match-beginning 0) 1)))
(compose-region (- (match-end 0) 2)
(- (match-end 0) 1)
(org-bullets-level-char level))
(when (facep org-bullets-face-name)
(put-text-property (- (match-end 0) 2)
(- (match-end 0) 1)
'face org-bullets-face-name))
(put-text-property (match-beginning 0) (match-end 0)
'keymap org-bullets-bullet-map)
nil))))))
(if org-bullets-mode
(progn (font-lock-add-keywords nil keyword)
(font-lock-fontify-buffer))
(save-excursion
(goto-char (point-min))
(font-lock-remove-keywords nil keyword)
(while (re-search-forward org-outline-regexp-bol nil t)
(decompose-region (match-beginning 0) (match-end 0)))
(font-lock-fontify-buffer)))))))