aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2021-03-07 20:52:39 +0200
committerJuri Linkov2021-03-07 20:52:39 +0200
commitc63d2ef59c511c1c48c69a202907b7edfcbb19b3 (patch)
treed698b785270c769a25ab57e2bdabb5e5d4f7b365
parentc1f4a16cf3d71aa3f67c1c209e7060dc71afc545 (diff)
downloademacs-c63d2ef59c511c1c48c69a202907b7edfcbb19b3.tar.gz
emacs-c63d2ef59c511c1c48c69a202907b7edfcbb19b3.zip
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
-rw-r--r--etc/NEWS13
-rw-r--r--etc/compilation.txt4
-rw-r--r--etc/grep.txt4
-rw-r--r--lisp/outline.el71
4 files changed, 42 insertions, 50 deletions
diff --git a/etc/NEWS b/etc/NEWS
index c4feabb5113..cf21a7b0f18 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -369,19 +369,18 @@ Typing 'TAB' on a heading line cycles the current section between
369anywhere in the buffer cycles the whole buffer between "only top-level 369anywhere in the buffer cycles the whole buffer between "only top-level
370headings", "all headings and subheadings", and "show all" states. 370headings", "all headings and subheadings", and "show all" states.
371 371
372*** New minor mode 'outline-cycle-minor-mode'. 372*** New option 'outline-minor-mode-cycle'.
373This mode is a variant of 'outline-minor-mode', with the difference 373This option customizes 'outline-minor-mode', with the difference
374that 'TAB' and 'S-TAB' on heading lines cycle heading visibility. 374that 'TAB' and 'S-TAB' on heading lines cycle heading visibility.
375Typing 'TAB' on a heading line cycles the current section between 375Typing 'TAB' on a heading line cycles the current section between
376"hide all", "subheadings", and "show all" states. Typing 'S-TAB' on a 376"hide all", "subheadings", and "show all" states. Typing 'S-TAB' on a
377heading line cycles the whole buffer between "only top-level 377heading line cycles the whole buffer between "only top-level
378headings", "all headings and subheadings", and "show all" states. 378headings", "all headings and subheadings", and "show all" states.
379 379
380*** New minor mode 'outline-cycle-highlight-minor-mode'. 380*** New option 'outline-minor-mode-highlight'.
381This mode is a variant of 'outline-cycle-minor-mode'. It puts 381This option customizes 'outline-minor-mode'. It puts highlighting
382highlighting on heading lines using standard outline faces. This 382on heading lines using standard outline faces. This works well only
383works well only when there are no conflicts with faces used by the 383when there are no conflicts with faces used by the major mode.
384major mode.
385 384
386 385
387* Changes in Specialized Modes and Packages in Emacs 28.1 386* Changes in Specialized Modes and Packages in Emacs 28.1
diff --git a/etc/compilation.txt b/etc/compilation.txt
index 05c04649bea..01d4df1b09d 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -696,5 +696,7 @@ COPYING PERMISSIONS:
696 696
697;;; Local Variables: 697;;; Local Variables:
698;;; outline-regexp: "\\*\\_>" 698;;; outline-regexp: "\\*\\_>"
699;;; eval: (outline-cycle-highlight-minor-mode) 699;;; outline-minor-mode-cycle: t
700;;; outline-minor-mode-highlight: t
701;;; eval: (outline-minor-mode 1)
700;;; End: 702;;; End:
diff --git a/etc/grep.txt b/etc/grep.txt
index a54ebf8a3b4..0370ae4e2c2 100644
--- a/etc/grep.txt
+++ b/etc/grep.txt
@@ -125,5 +125,7 @@ COPYING PERMISSIONS:
125;;; Local Variables: 125;;; Local Variables:
126;;; eval: (let ((inhibit-read-only t) (compilation-filter-start (point-min))) (save-excursion (goto-char (point-max)) (grep-filter) (set-buffer-modified-p nil))) 126;;; eval: (let ((inhibit-read-only t) (compilation-filter-start (point-min))) (save-excursion (goto-char (point-max)) (grep-filter) (set-buffer-modified-p nil)))
127;;; buffer-read-only: t 127;;; buffer-read-only: t
128;;; eval: (outline-cycle-highlight-minor-mode) 128;;; outline-minor-mode-cycle: t
129;;; outline-minor-mode-highlight: t
130;;; eval: (outline-minor-mode 1)
129;;; End: 131;;; End:
diff --git a/lisp/outline.el b/lisp/outline.el
index 640c0e06b9e..a859f9ac8f5 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -186,7 +186,7 @@ in the file it applies to.")
186 (define-key map (kbd "TAB") tab-binding) 186 (define-key map (kbd "TAB") tab-binding)
187 (define-key map (kbd "<backtab>") #'outline-cycle-buffer)) 187 (define-key map (kbd "<backtab>") #'outline-cycle-buffer))
188 map) 188 map)
189 "Keymap used by `outline-mode-map' and `outline-cycle-minor-mode'.") 189 "Keymap used by `outline-mode-map' and `outline-minor-mode-cycle'.")
190 190
191(defvar outline-mode-map 191(defvar outline-mode-map
192 (let ((map (make-sparse-keymap))) 192 (let ((map (make-sparse-keymap)))
@@ -199,16 +199,19 @@ in the file it applies to.")
199 '( 199 '(
200 ;; Highlight headings according to the level. 200 ;; Highlight headings according to the level.
201 (eval . (list (concat "^\\(?:" outline-regexp "\\).+") 201 (eval . (list (concat "^\\(?:" outline-regexp "\\).+")
202 0 '(if outline-minor-mode-cycle 202 0 '(if outline-minor-mode
203 (if outline-minor-mode-highlight 203 (if outline-minor-mode-cycle
204 (list 'face (outline-font-lock-face) 204 (if outline-minor-mode-highlight
205 'keymap outline-mode-cycle-map) 205 (list 'face (outline-font-lock-face)
206 (list 'face nil 206 'keymap outline-mode-cycle-map)
207 'keymap outline-mode-cycle-map)) 207 (list 'face nil
208 'keymap outline-mode-cycle-map)))
208 (outline-font-lock-face)) 209 (outline-font-lock-face))
209 nil 210 (when (and outline-minor-mode
210 (if (or outline-minor-mode-cycle 211 (eq outline-minor-mode-highlight 'override))
211 outline-minor-mode-highlight) 212 'append)
213 (if (and outline-minor-mode
214 (eq outline-minor-mode-highlight t))
212 'append 215 'append
213 t)))) 216 t))))
214 "Additional expressions to highlight in Outline mode.") 217 "Additional expressions to highlight in Outline mode.")
@@ -324,18 +327,28 @@ After that, changing the prefix key requires manipulating keymaps."
324 (define-key outline-minor-mode-map val outline-mode-prefix-map) 327 (define-key outline-minor-mode-map val outline-mode-prefix-map)
325 (set-default sym val))) 328 (set-default sym val)))
326 329
327(defvar outline-minor-mode-cycle nil 330(defcustom outline-minor-mode-cycle nil
328 "Enable cycling of headings in `outline-minor-mode'. 331 "Enable cycling of headings in `outline-minor-mode'.
332When enabled, it puts a keymap with cycling keys on heading lines.
329When point is on a heading line, then typing `TAB' cycles between `hide all', 333When point is on a heading line, then typing `TAB' cycles between `hide all',
330`headings only' and `show all' (`outline-cycle'). Typing `S-TAB' on 334`headings only' and `show all' (`outline-cycle'). Typing `S-TAB' on
331a heading line cycles the whole buffer (`outline-cycle-buffer'). 335a heading line cycles the whole buffer (`outline-cycle-buffer').
332Typing these keys anywhere outside heading lines uses their default bindings.") 336Typing these keys anywhere outside heading lines uses their default bindings."
337 :type 'boolean
338 :version "28.1")
333;;;###autoload(put 'outline-minor-mode-cycle 'safe-local-variable 'booleanp) 339;;;###autoload(put 'outline-minor-mode-cycle 'safe-local-variable 'booleanp)
334 340
335(defvar outline-minor-mode-highlight nil 341(defcustom outline-minor-mode-highlight nil
336 "Highlight headings in `outline-minor-mode' using font-lock keywords. 342 "Highlight headings in `outline-minor-mode' using font-lock keywords.
337Non-nil value works well only when outline font-lock keywords 343Non-nil value works well only when outline font-lock keywords
338don't conflict with the major mode's font-lock keywords.") 344don't conflict with the major mode's font-lock keywords.
345When t, it puts outline faces only if there are no major mode's faces
346on headings. When `override', it tries to append outline faces
347to major mode's faces."
348 :type '(choice (const :tag "No highlighting" nil)
349 (const :tag "Append to major mode faces" override)
350 (const :tag "Highlight separately from major mode faces" t))
351 :version "28.1")
339;;;###autoload(put 'outline-minor-mode-highlight 'safe-local-variable 'booleanp) 352;;;###autoload(put 'outline-minor-mode-highlight 'safe-local-variable 'booleanp)
340 353
341(defun outline-minor-mode-highlight-buffer () 354(defun outline-minor-mode-highlight-buffer ()
@@ -347,7 +360,9 @@ don't conflict with the major mode's font-lock keywords.")
347 (let ((overlay (make-overlay (match-beginning 0) 360 (let ((overlay (make-overlay (match-beginning 0)
348 (match-end 0)))) 361 (match-end 0))))
349 (overlay-put overlay 'outline-overlay t) 362 (overlay-put overlay 'outline-overlay t)
350 (when outline-minor-mode-highlight 363 (when (or (eq outline-minor-mode-highlight 'override)
364 (and (eq outline-minor-mode-highlight t)
365 (not (get-text-property (point) 'face))))
351 (overlay-put overlay 'face (outline-font-lock-face))) 366 (overlay-put overlay 'face (outline-font-lock-face)))
352 (when outline-minor-mode-cycle 367 (when outline-minor-mode-cycle
353 (overlay-put overlay 'keymap outline-mode-cycle-map))) 368 (overlay-put overlay 'keymap outline-mode-cycle-map)))
@@ -386,32 +401,6 @@ See the command `outline-mode' for more information on this mode."
386 ;; When turning off outline mode, get rid of any outline hiding. 401 ;; When turning off outline mode, get rid of any outline hiding.
387 (outline-show-all))) 402 (outline-show-all)))
388 403
389;;;###autoload
390(define-minor-mode outline-cycle-minor-mode
391 "Toggle Outline-Cycle minor mode.
392Set the buffer-local variable `outline-minor-mode-cycle' to t
393and enable `outline-minor-mode'."
394 nil nil nil
395 (if outline-cycle-minor-mode
396 (progn
397 (setq-local outline-minor-mode-cycle t)
398 (outline-minor-mode +1))
399 (outline-minor-mode -1)
400 (kill-local-variable 'outline-minor-mode-cycle)))
401
402;;;###autoload
403(define-minor-mode outline-cycle-highlight-minor-mode
404 "Toggle Outline-Cycle-Highlight minor mode.
405Set the buffer-local variable `outline-minor-mode-highlight' to t
406and enable `outline-cycle-minor-mode'."
407 nil nil nil
408 (if outline-cycle-highlight-minor-mode
409 (progn
410 (setq-local outline-minor-mode-highlight t)
411 (outline-cycle-minor-mode +1))
412 (outline-cycle-minor-mode -1)
413 (kill-local-variable 'outline-minor-mode-highlight)))
414
415(defvar-local outline-heading-alist () 404(defvar-local outline-heading-alist ()
416 "Alist associating a heading for every possible level. 405 "Alist associating a heading for every possible level.
417Each entry is of the form (HEADING . LEVEL). 406Each entry is of the form (HEADING . LEVEL).