* lisp/outline.el (outline-minor-mode-insert-buttons): New defvar-local.
(outline--make-button-overlay, outline--insert-open-button) (outline--insert-close-button): Insert button when outline-minor-mode-insert-buttons is non-nil, otherwise put an overlay with before-string. (bug#57813) * lisp/help.el (describe-bindings): Set buffer-local outline-minor-mode-insert-buttons to t. * lisp/textmodes/emacs-news-mode.el (emacs-news--mode-common): Set buffer-local outline-minor-mode-use-margins to t. Don't set outline-regexp for leading spaces because now spaces are not added in the NEWS buffer.
This commit is contained in:
parent
a9f183c760
commit
ab1b491f83
3 changed files with 25 additions and 18 deletions
|
@ -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))
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue