diff options
| author | Juri Linkov | 2021-03-07 20:52:39 +0200 |
|---|---|---|
| committer | Juri Linkov | 2021-03-07 20:52:39 +0200 |
| commit | c63d2ef59c511c1c48c69a202907b7edfcbb19b3 (patch) | |
| tree | d698b785270c769a25ab57e2bdabb5e5d4f7b365 | |
| parent | c1f4a16cf3d71aa3f67c1c209e7060dc71afc545 (diff) | |
| download | emacs-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/NEWS | 13 | ||||
| -rw-r--r-- | etc/compilation.txt | 4 | ||||
| -rw-r--r-- | etc/grep.txt | 4 | ||||
| -rw-r--r-- | lisp/outline.el | 71 |
4 files changed, 42 insertions, 50 deletions
| @@ -369,19 +369,18 @@ Typing 'TAB' on a heading line cycles the current section between | |||
| 369 | anywhere in the buffer cycles the whole buffer between "only top-level | 369 | anywhere in the buffer cycles the whole buffer between "only top-level |
| 370 | headings", "all headings and subheadings", and "show all" states. | 370 | headings", "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'. |
| 373 | This mode is a variant of 'outline-minor-mode', with the difference | 373 | This option customizes 'outline-minor-mode', with the difference |
| 374 | that 'TAB' and 'S-TAB' on heading lines cycle heading visibility. | 374 | that 'TAB' and 'S-TAB' on heading lines cycle heading visibility. |
| 375 | Typing 'TAB' on a heading line cycles the current section between | 375 | Typing '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 |
| 377 | heading line cycles the whole buffer between "only top-level | 377 | heading line cycles the whole buffer between "only top-level |
| 378 | headings", "all headings and subheadings", and "show all" states. | 378 | headings", "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'. |
| 381 | This mode is a variant of 'outline-cycle-minor-mode'. It puts | 381 | This option customizes 'outline-minor-mode'. It puts highlighting |
| 382 | highlighting on heading lines using standard outline faces. This | 382 | on heading lines using standard outline faces. This works well only |
| 383 | works well only when there are no conflicts with faces used by the | 383 | when there are no conflicts with faces used by the major mode. |
| 384 | major 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'. |
| 332 | When enabled, it puts a keymap with cycling keys on heading lines. | ||
| 329 | When point is on a heading line, then typing `TAB' cycles between `hide all', | 333 | When 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 |
| 331 | a heading line cycles the whole buffer (`outline-cycle-buffer'). | 335 | a heading line cycles the whole buffer (`outline-cycle-buffer'). |
| 332 | Typing these keys anywhere outside heading lines uses their default bindings.") | 336 | Typing 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. |
| 337 | Non-nil value works well only when outline font-lock keywords | 343 | Non-nil value works well only when outline font-lock keywords |
| 338 | don't conflict with the major mode's font-lock keywords.") | 344 | don't conflict with the major mode's font-lock keywords. |
| 345 | When t, it puts outline faces only if there are no major mode's faces | ||
| 346 | on headings. When `override', it tries to append outline faces | ||
| 347 | to 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. | ||
| 392 | Set the buffer-local variable `outline-minor-mode-cycle' to t | ||
| 393 | and 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. | ||
| 405 | Set the buffer-local variable `outline-minor-mode-highlight' to t | ||
| 406 | and 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. |
| 417 | Each entry is of the form (HEADING . LEVEL). | 406 | Each entry is of the form (HEADING . LEVEL). |