]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove outline-cycle-minor-mode and outline-cycle-highlight-minor-mode
authorJuri Linkov <juri@linkov.net>
Sun, 7 Mar 2021 18:52:39 +0000 (20:52 +0200)
committerJuri Linkov <juri@linkov.net>
Sun, 7 Mar 2021 18:52:39 +0000 (20:52 +0200)
* 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

etc/NEWS
etc/compilation.txt
etc/grep.txt
lisp/outline.el

index c4feabb511321c9fef2874235778f1acde58fe77..cf21a7b0f189f6286e11c75260404b9f7ef06638 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
 headings", "all headings and subheadings", and "show all" states.
 
-*** New minor mode 'outline-cycle-minor-mode'.
-This mode is a variant of 'outline-minor-mode', with the difference
+*** New option 'outline-minor-mode-cycle'.
+This option customizes 'outline-minor-mode', with the difference
 that 'TAB' and 'S-TAB' on heading lines cycle heading visibility.
 Typing 'TAB' on a heading line cycles the current section between
 "hide all", "subheadings", and "show all" states.  Typing 'S-TAB' on a
 heading line cycles the whole buffer between "only top-level
 headings", "all headings and subheadings", and "show all" states.
 
-*** New minor mode 'outline-cycle-highlight-minor-mode'.
-This mode is a variant of 'outline-cycle-minor-mode'.  It puts
-highlighting on heading lines using standard outline faces.  This
-works well only when there are no conflicts with faces used by the
-major mode.
+*** New option 'outline-minor-mode-highlight'.
+This option customizes 'outline-minor-mode'.  It puts highlighting
+on heading lines using standard outline faces.  This works well only
+when there are no conflicts with faces used by the major mode.
 
 \f
 * Changes in Specialized Modes and Packages in Emacs 28.1
index 05c04649bea9014e2a99c092349b817becf7f90b..01d4df1b09d0c126dfa9c38019eb36798738a3ec 100644 (file)
@@ -696,5 +696,7 @@ COPYING PERMISSIONS:
 
 ;;; Local Variables:
 ;;; outline-regexp: "\\*\\_>"
-;;; eval: (outline-cycle-highlight-minor-mode)
+;;; outline-minor-mode-cycle: t
+;;; outline-minor-mode-highlight: t
+;;; eval: (outline-minor-mode 1)
 ;;; End:
index a54ebf8a3b47bcec00ed4e4fc4a1b497860ea175..0370ae4e2c25edf07a04d4784be04c053f5cc906 100644 (file)
@@ -125,5 +125,7 @@ COPYING PERMISSIONS:
 ;;; 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)))
 ;;; 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:
index 640c0e06b9e2eae315207558bec15e1c637af92e..a859f9ac8f51fc93de214e2f3991678e5dc66997 100644 (file)
@@ -186,7 +186,7 @@ in the file it applies to.")
       (define-key map (kbd "TAB") tab-binding)
       (define-key map (kbd "<backtab>") #'outline-cycle-buffer))
     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
   (let ((map (make-sparse-keymap)))
@@ -199,16 +199,19 @@ in the file it applies to.")
   '(
     ;; Highlight headings according to the level.
     (eval . (list (concat "^\\(?:" outline-regexp "\\).+")
-                  0 '(if outline-minor-mode-cycle
-                         (if outline-minor-mode-highlight
-                             (list 'face (outline-font-lock-face)
-                                   'keymap outline-mode-cycle-map)
-                           (list 'face nil
-                                 'keymap outline-mode-cycle-map))
+                  0 '(if outline-minor-mode
+                         (if outline-minor-mode-cycle
+                             (if outline-minor-mode-highlight
+                                 (list 'face (outline-font-lock-face)
+                                       'keymap outline-mode-cycle-map)
+                               (list 'face nil
+                                     'keymap outline-mode-cycle-map)))
                        (outline-font-lock-face))
-                  nil
-                  (if (or outline-minor-mode-cycle
-                          outline-minor-mode-highlight)
+                  (when (and outline-minor-mode
+                             (eq outline-minor-mode-highlight 'override))
+                    'append)
+                  (if (and outline-minor-mode
+                           (eq outline-minor-mode-highlight t))
                       'append
                     t))))
   "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)
          (set-default sym val)))
 
-(defvar outline-minor-mode-cycle nil
+(defcustom outline-minor-mode-cycle nil
   "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',
 `headings only' and `show all' (`outline-cycle').  Typing `S-TAB' on
 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)
 
-(defvar outline-minor-mode-highlight nil
+(defcustom outline-minor-mode-highlight nil
   "Highlight headings in `outline-minor-mode' using 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)
 
 (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)
                                      (match-end 0))))
           (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)))
           (when outline-minor-mode-cycle
             (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.
     (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 ()
   "Alist associating a heading for every possible level.
 Each entry is of the form (HEADING . LEVEL).