summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/help.el3
-rw-r--r--lisp/outline.el31
-rw-r--r--lisp/textmodes/emacs-news-mode.el9
3 files changed, 25 insertions, 18 deletions
diff --git a/lisp/help.el b/lisp/help.el
index 1cfd044db8c..0f5342b77d3 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -744,7 +744,8 @@ or a buffer name."
(setq-local outline-heading-end-regexp ":\n")
(setq-local outline-level (lambda () 1))
(setq-local outline-minor-mode-cycle t
- outline-minor-mode-highlight t)
+ outline-minor-mode-highlight t
+ outline-minor-mode-insert-buttons t)
(outline-minor-mode 1)
(save-excursion
(goto-char (point-min))
diff --git a/lisp/outline.el b/lisp/outline.el
index 0d0974b5a95..2209964577f 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -295,6 +295,9 @@ buffers (yet) -- that will be amended in a future version."
(defvar-local outline--use-buttons nil
"Non-nil when buffer displays clickable buttons on the headings.")
+(defvar-local outline-minor-mode-insert-buttons nil
+ "Non-nil when it's allowed to modify buffer to insert buttons.")
+
(defvar-local outline--use-rtl nil
"Non-nil when direction of clickable buttons is right-to-left.")
@@ -1668,18 +1671,24 @@ With a prefix argument, show headings up to that LEVEL."
(if outline--use-rtl
'outline-close-rtl
'outline-close)
- 'outline-open)))
- (inhibit-read-only t))
+ 'outline-open))))
;; In editing buffers we use overlays only, but in other buffers
;; we use a mix of text properties, text and overlays to make
;; movement commands work more logically.
- (when (derived-mode-p 'special-mode)
- (put-text-property (point) (1+ (point)) 'face (plist-get icon 'face)))
- (if-let ((image (plist-get icon 'image)))
- (overlay-put o 'display image)
- (overlay-put o 'display (concat (plist-get icon 'string)
- (string (char-after (point)))))
- (overlay-put o 'face (plist-get icon 'face))))
+ (if outline-minor-mode-insert-buttons
+ (let ((inhibit-read-only t))
+ (put-text-property (point) (1+ (point)) 'face (plist-get icon 'face))
+ (if-let ((image (plist-get icon 'image)))
+ (overlay-put o 'display image)
+ (overlay-put o 'display (concat (plist-get icon 'string)
+ (string (char-after (point)))))
+ (overlay-put o 'face (plist-get icon 'face))))
+ (overlay-put
+ o 'before-string
+ (propertize " "
+ 'display
+ (or (plist-get icon 'image)
+ (plist-get icon 'string))))))
o))
(defun outline--make-margin-overlay (type)
@@ -1710,7 +1719,7 @@ With a prefix argument, show headings up to that LEVEL."
(beginning-of-line)
(if use-margins
(outline--make-margin-overlay 'open)
- (when (derived-mode-p 'special-mode)
+ (when outline-minor-mode-insert-buttons
(let ((inhibit-read-only t))
(insert " ")
(beginning-of-line)))
@@ -1727,7 +1736,7 @@ With a prefix argument, show headings up to that LEVEL."
(beginning-of-line)
(if use-margins
(outline--make-margin-overlay 'close)
- (when (derived-mode-p 'special-mode)
+ (when outline-minor-mode-insert-buttons
(let ((inhibit-read-only t))
(insert " ")
(beginning-of-line)))
diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el
index d9decae4df6..d57d053a7ad 100644
--- a/lisp/textmodes/emacs-news-mode.el
+++ b/lisp/textmodes/emacs-news-mode.el
@@ -73,12 +73,9 @@
(defun emacs-news--mode-common ()
(setq-local font-lock-defaults '(emacs-news-mode-font-lock-keywords t))
- ;; This `outline-regexp' matches leading spaces inserted
- ;; by the current implementation of `outline-minor-mode-use-buttons'.
- (setq-local outline-regexp "\\(?: +\\)?\\(\\*+\\) "
- outline-level (lambda () (length (match-string 1)))
- outline-minor-mode-cycle t
- outline-minor-mode-highlight 'append)
+ (setq-local outline-minor-mode-cycle t
+ outline-minor-mode-highlight 'append
+ outline-minor-mode-use-margins t)
(outline-minor-mode)
(setq-local imenu-generic-expression outline-imenu-generic-expression)
(emacs-etc--hide-local-variables))