Remove outline-cycle-minor-mode and outline-cycle-highlight-minor-mode

* lisp/outline.el (outline-font-lock-keywords): Use OVERRIDE or
LAXMATCH depending on outline-minor-mode-highlight in outline-minor-mode.
(outline-minor-mode-cycle, outline-minor-mode-highlight): Promote
defvar to defcustom.
(outline-minor-mode-highlight-buffer): Don't override existing faces.
(outline-cycle-minor-mode, outline-cycle-highlight-minor-mode):
Remove minor modes.

* etc/compilation.txt:
* etc/grep.txt: Enable outline-minor-mode-cycle and
outline-minor-mode-highlight with outline-minor-mode.
https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00144.html
This commit is contained in:
Juri Linkov 2021-03-07 20:52:39 +02:00
parent c1f4a16cf3
commit c63d2ef59c
4 changed files with 42 additions and 50 deletions

View file

@ -369,19 +369,18 @@ Typing 'TAB' on a heading line cycles the current section between
anywhere in the buffer cycles the whole buffer between "only top-level anywhere in the buffer cycles the whole buffer between "only top-level
headings", "all headings and subheadings", and "show all" states. headings", "all headings and subheadings", and "show all" states.
*** New minor mode 'outline-cycle-minor-mode'. *** New option 'outline-minor-mode-cycle'.
This mode is a variant of 'outline-minor-mode', with the difference This option customizes 'outline-minor-mode', with the difference
that 'TAB' and 'S-TAB' on heading lines cycle heading visibility. that 'TAB' and 'S-TAB' on heading lines cycle heading visibility.
Typing 'TAB' on a heading line cycles the current section between Typing 'TAB' on a heading line cycles the current section between
"hide all", "subheadings", and "show all" states. Typing 'S-TAB' on a "hide all", "subheadings", and "show all" states. Typing 'S-TAB' on a
heading line cycles the whole buffer between "only top-level heading line cycles the whole buffer between "only top-level
headings", "all headings and subheadings", and "show all" states. headings", "all headings and subheadings", and "show all" states.
*** New minor mode 'outline-cycle-highlight-minor-mode'. *** New option 'outline-minor-mode-highlight'.
This mode is a variant of 'outline-cycle-minor-mode'. It puts This option customizes 'outline-minor-mode'. It puts highlighting
highlighting on heading lines using standard outline faces. This on heading lines using standard outline faces. This works well only
works well only when there are no conflicts with faces used by the when there are no conflicts with faces used by the major mode.
major mode.
* Changes in Specialized Modes and Packages in Emacs 28.1 * Changes in Specialized Modes and Packages in Emacs 28.1

View file

@ -696,5 +696,7 @@ COPYING PERMISSIONS:
;;; Local Variables: ;;; Local Variables:
;;; outline-regexp: "\\*\\_>" ;;; outline-regexp: "\\*\\_>"
;;; eval: (outline-cycle-highlight-minor-mode) ;;; outline-minor-mode-cycle: t
;;; outline-minor-mode-highlight: t
;;; eval: (outline-minor-mode 1)
;;; End: ;;; End:

View file

@ -125,5 +125,7 @@ COPYING PERMISSIONS:
;;; Local Variables: ;;; Local Variables:
;;; eval: (let ((inhibit-read-only t) (compilation-filter-start (point-min))) (save-excursion (goto-char (point-max)) (grep-filter) (set-buffer-modified-p nil))) ;;; eval: (let ((inhibit-read-only t) (compilation-filter-start (point-min))) (save-excursion (goto-char (point-max)) (grep-filter) (set-buffer-modified-p nil)))
;;; buffer-read-only: t ;;; buffer-read-only: t
;;; eval: (outline-cycle-highlight-minor-mode) ;;; outline-minor-mode-cycle: t
;;; outline-minor-mode-highlight: t
;;; eval: (outline-minor-mode 1)
;;; End: ;;; End:

View file

@ -186,7 +186,7 @@ in the file it applies to.")
(define-key map (kbd "TAB") tab-binding) (define-key map (kbd "TAB") tab-binding)
(define-key map (kbd "<backtab>") #'outline-cycle-buffer)) (define-key map (kbd "<backtab>") #'outline-cycle-buffer))
map) map)
"Keymap used by `outline-mode-map' and `outline-cycle-minor-mode'.") "Keymap used by `outline-mode-map' and `outline-minor-mode-cycle'.")
(defvar outline-mode-map (defvar outline-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -199,16 +199,19 @@ in the file it applies to.")
'( '(
;; Highlight headings according to the level. ;; Highlight headings according to the level.
(eval . (list (concat "^\\(?:" outline-regexp "\\).+") (eval . (list (concat "^\\(?:" outline-regexp "\\).+")
0 '(if outline-minor-mode-cycle 0 '(if outline-minor-mode
(if outline-minor-mode-highlight (if outline-minor-mode-cycle
(list 'face (outline-font-lock-face) (if outline-minor-mode-highlight
'keymap outline-mode-cycle-map) (list 'face (outline-font-lock-face)
(list 'face nil 'keymap outline-mode-cycle-map)
'keymap outline-mode-cycle-map)) (list 'face nil
'keymap outline-mode-cycle-map)))
(outline-font-lock-face)) (outline-font-lock-face))
nil (when (and outline-minor-mode
(if (or outline-minor-mode-cycle (eq outline-minor-mode-highlight 'override))
outline-minor-mode-highlight) 'append)
(if (and outline-minor-mode
(eq outline-minor-mode-highlight t))
'append 'append
t)))) t))))
"Additional expressions to highlight in Outline mode.") "Additional expressions to highlight in Outline mode.")
@ -324,18 +327,28 @@ After that, changing the prefix key requires manipulating keymaps."
(define-key outline-minor-mode-map val outline-mode-prefix-map) (define-key outline-minor-mode-map val outline-mode-prefix-map)
(set-default sym val))) (set-default sym val)))
(defvar outline-minor-mode-cycle nil (defcustom outline-minor-mode-cycle nil
"Enable cycling of headings in `outline-minor-mode'. "Enable cycling of headings in `outline-minor-mode'.
When enabled, it puts a keymap with cycling keys on heading lines.
When point is on a heading line, then typing `TAB' cycles between `hide all', When point is on a heading line, then typing `TAB' cycles between `hide all',
`headings only' and `show all' (`outline-cycle'). Typing `S-TAB' on `headings only' and `show all' (`outline-cycle'). Typing `S-TAB' on
a heading line cycles the whole buffer (`outline-cycle-buffer'). a heading line cycles the whole buffer (`outline-cycle-buffer').
Typing these keys anywhere outside heading lines uses their default bindings.") Typing these keys anywhere outside heading lines uses their default bindings."
:type 'boolean
:version "28.1")
;;;###autoload(put 'outline-minor-mode-cycle 'safe-local-variable 'booleanp) ;;;###autoload(put 'outline-minor-mode-cycle 'safe-local-variable 'booleanp)
(defvar outline-minor-mode-highlight nil (defcustom outline-minor-mode-highlight nil
"Highlight headings in `outline-minor-mode' using font-lock keywords. "Highlight headings in `outline-minor-mode' using font-lock keywords.
Non-nil value works well only when outline font-lock keywords Non-nil value works well only when outline font-lock keywords
don't conflict with the major mode's font-lock keywords.") don't conflict with the major mode's font-lock keywords.
When t, it puts outline faces only if there are no major mode's faces
on headings. When `override', it tries to append outline faces
to major mode's faces."
:type '(choice (const :tag "No highlighting" nil)
(const :tag "Append to major mode faces" override)
(const :tag "Highlight separately from major mode faces" t))
:version "28.1")
;;;###autoload(put 'outline-minor-mode-highlight 'safe-local-variable 'booleanp) ;;;###autoload(put 'outline-minor-mode-highlight 'safe-local-variable 'booleanp)
(defun outline-minor-mode-highlight-buffer () (defun outline-minor-mode-highlight-buffer ()
@ -347,7 +360,9 @@ don't conflict with the major mode's font-lock keywords.")
(let ((overlay (make-overlay (match-beginning 0) (let ((overlay (make-overlay (match-beginning 0)
(match-end 0)))) (match-end 0))))
(overlay-put overlay 'outline-overlay t) (overlay-put overlay 'outline-overlay t)
(when outline-minor-mode-highlight (when (or (eq outline-minor-mode-highlight 'override)
(and (eq outline-minor-mode-highlight t)
(not (get-text-property (point) 'face))))
(overlay-put overlay 'face (outline-font-lock-face))) (overlay-put overlay 'face (outline-font-lock-face)))
(when outline-minor-mode-cycle (when outline-minor-mode-cycle
(overlay-put overlay 'keymap outline-mode-cycle-map))) (overlay-put overlay 'keymap outline-mode-cycle-map)))
@ -386,32 +401,6 @@ See the command `outline-mode' for more information on this mode."
;; When turning off outline mode, get rid of any outline hiding. ;; When turning off outline mode, get rid of any outline hiding.
(outline-show-all))) (outline-show-all)))
;;;###autoload
(define-minor-mode outline-cycle-minor-mode
"Toggle Outline-Cycle minor mode.
Set the buffer-local variable `outline-minor-mode-cycle' to t
and enable `outline-minor-mode'."
nil nil nil
(if outline-cycle-minor-mode
(progn
(setq-local outline-minor-mode-cycle t)
(outline-minor-mode +1))
(outline-minor-mode -1)
(kill-local-variable 'outline-minor-mode-cycle)))
;;;###autoload
(define-minor-mode outline-cycle-highlight-minor-mode
"Toggle Outline-Cycle-Highlight minor mode.
Set the buffer-local variable `outline-minor-mode-highlight' to t
and enable `outline-cycle-minor-mode'."
nil nil nil
(if outline-cycle-highlight-minor-mode
(progn
(setq-local outline-minor-mode-highlight t)
(outline-cycle-minor-mode +1))
(outline-cycle-minor-mode -1)
(kill-local-variable 'outline-minor-mode-highlight)))
(defvar-local outline-heading-alist () (defvar-local outline-heading-alist ()
"Alist associating a heading for every possible level. "Alist associating a heading for every possible level.
Each entry is of the form (HEADING . LEVEL). Each entry is of the form (HEADING . LEVEL).