summaryrefslogtreecommitdiff
path: root/lisp/outline.el
diff options
context:
space:
mode:
authorStephen Berman <stephen.berman@gmx.net>2022-08-09 20:21:09 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-08-09 20:44:07 +0200
commit744ed0ceeed7472a160fea7154939cf641205577 (patch)
tree733a28b74f8c036805b5fece3f3d05d660384a8d /lisp/outline.el
parent38f9d9bf060e08f3fe5edab9a13bc7eaabe7e2f1 (diff)
downloademacs-744ed0ceeed7472a160fea7154939cf641205577.tar.gz
emacs-744ed0ceeed7472a160fea7154939cf641205577.tar.bz2
emacs-744ed0ceeed7472a160fea7154939cf641205577.zip
Make outline buttons work in NEWS
* lisp/outline.el (outline-minor-mode-highlight-buffer): Fix button insertion. (outline-minor-mode): Ditto. (outline--insert-open-button): Don't mark buffer as modified when inserting buttons. (outline--insert-close-button): Ditto. * lisp/textmodes/emacs-news-mode.el (emacs-news--mode-common): Adjust outline regexp.
Diffstat (limited to 'lisp/outline.el')
-rw-r--r--lisp/outline.el61
1 files changed, 31 insertions, 30 deletions
diff --git a/lisp/outline.el b/lisp/outline.el
index 7750f9a75d0..35524a79a90 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -435,7 +435,7 @@ outline font-lock faces to those of major mode."
(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))))))
@@ -452,11 +452,10 @@ See the command `outline-mode' for more information on this mode."
(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))
@@ -1011,32 +1010,34 @@ If non-nil, EVENT should be a mouse event."
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