(goto-char (match-beginning 0))
(not (get-text-property (point) 'face))))
(overlay-put overlay 'face (outline-font-lock-face)))
- (when (outline--use-buttons-p)
+ (when (and (outline--use-buttons-p) (outline-on-heading-p))
(outline--insert-open-button)))
(goto-char (match-end 0))))))
(if outline-minor-mode
(progn
(when outline-minor-mode-highlight
- (if (and global-font-lock-mode (font-lock-specified-p major-mode))
- (progn
- (font-lock-add-keywords nil outline-font-lock-keywords t)
- (font-lock-flush))
- (outline-minor-mode-highlight-buffer)))
+ (when (and global-font-lock-mode (font-lock-specified-p major-mode))
+ (font-lock-add-keywords nil outline-font-lock-keywords t)
+ (font-lock-flush))
+ (outline-minor-mode-highlight-buffer))
;; Turn off this mode if we change major modes.
(add-hook 'change-major-mode-hook
(lambda () (outline-minor-mode -1))
o))
(defun outline--insert-open-button ()
- (save-excursion
- (beginning-of-line)
- (when (derived-mode-p 'special-mode)
- (let ((inhibit-read-only t))
- (insert " ")
- (beginning-of-line)))
- (let ((o (outline--make-button-overlay 'open)))
- (overlay-put o 'help-echo "Click to hide")
- (overlay-put o 'keymap
- (define-keymap
- "RET" #'outline-hide-subtree
- "<mouse-2>" #'outline-hide-subtree)))))
+ (with-silent-modifications
+ (save-excursion
+ (beginning-of-line)
+ (when (derived-mode-p 'special-mode)
+ (let ((inhibit-read-only t))
+ (insert " ")
+ (beginning-of-line)))
+ (let ((o (outline--make-button-overlay 'open)))
+ (overlay-put o 'help-echo "Click to hide")
+ (overlay-put o 'keymap
+ (define-keymap
+ "RET" #'outline-hide-subtree
+ "<mouse-2>" #'outline-hide-subtree))))))
(defun outline--insert-close-button ()
- (save-excursion
- (beginning-of-line)
- (when (derived-mode-p 'special-mode)
- (let ((inhibit-read-only t))
- (insert " ")
- (beginning-of-line)))
- (let ((o (outline--make-button-overlay 'close)))
- (overlay-put o 'help-echo "Click to show")
- (overlay-put o 'keymap
- (define-keymap
- "RET" #'outline-show-subtree
- "<mouse-2>" #'outline-show-subtree)))))
+ (with-silent-modifications
+ (save-excursion
+ (beginning-of-line)
+ (when (derived-mode-p 'special-mode)
+ (let ((inhibit-read-only t))
+ (insert " ")
+ (beginning-of-line)))
+ (let ((o (outline--make-button-overlay 'close)))
+ (overlay-put o 'help-echo "Click to show")
+ (overlay-put o 'keymap
+ (define-keymap
+ "RET" #'outline-show-subtree
+ "<mouse-2>" #'outline-show-subtree))))))
(defun outline--fix-up-all-buttons (&optional from to)
(when from
(defun emacs-news--mode-common ()
(setq-local font-lock-defaults '(emacs-news-mode-font-lock-keywords t))
- (setq-local outline-regexp "\\*+ "
+ (setq-local outline-regexp "\\(:? +\\)?\\(\\*+\\) "
outline-minor-mode-cycle t
- ;; We subtract one from the level, because we have a
- ;; space after the asterisks.
- outline-level (lambda () (1- (length (match-string 0))))
+ outline-level (lambda () (length (match-string 2)))
outline-minor-mode-highlight 'append)
(outline-minor-mode))