diff options
| author | Juri Linkov | 2022-10-13 10:13:07 +0300 |
|---|---|---|
| committer | Juri Linkov | 2022-10-13 10:13:07 +0300 |
| commit | 3d41cc03d96b0383ad87c985ff48077e39cac985 (patch) | |
| tree | 0e5f222cb6fd83701ee7208a8ff0a84e29eba7c7 | |
| parent | c522021a3019fa8f8598319a867326ec59b2bfaf (diff) | |
| download | emacs-3d41cc03d96b0383ad87c985ff48077e39cac985.tar.gz emacs-3d41cc03d96b0383ad87c985ff48077e39cac985.zip | |
* lisp/outline.el (outline--fix-buttons-after-change): New function.
(outline-minor-mode): Use it.
(outline--make-margin-overlay): Remove inhibit-read-only.
| -rw-r--r-- | lisp/outline.el | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lisp/outline.el b/lisp/outline.el index 93a9247f613..b2b36a764ce 100644 --- a/lisp/outline.el +++ b/lisp/outline.el | |||
| @@ -516,13 +516,7 @@ See the command `outline-mode' for more information on this mode." | |||
| 516 | (set-window-buffer nil (window-buffer))) | 516 | (set-window-buffer nil (window-buffer))) |
| 517 | (when (or outline--use-buttons outline--use-margins) | 517 | (when (or outline--use-buttons outline--use-margins) |
| 518 | (add-hook 'after-change-functions | 518 | (add-hook 'after-change-functions |
| 519 | (lambda (beg end _len) | 519 | #'outline--fix-buttons-after-change nil t)) |
| 520 | (when outline--use-buttons | ||
| 521 | (remove-overlays beg end 'outline-button t)) | ||
| 522 | (when outline--use-margins | ||
| 523 | (remove-overlays beg end 'outline-margin t)) | ||
| 524 | (outline--fix-up-all-buttons beg end)) | ||
| 525 | nil t)) | ||
| 526 | (when outline-minor-mode-highlight | 520 | (when outline-minor-mode-highlight |
| 527 | (if (and global-font-lock-mode (font-lock-specified-p major-mode)) | 521 | (if (and global-font-lock-mode (font-lock-specified-p major-mode)) |
| 528 | (progn | 522 | (progn |
| @@ -1105,8 +1099,7 @@ If non-nil, EVENT should be a mouse event." | |||
| 1105 | (if outline--use-rtl | 1099 | (if outline--use-rtl |
| 1106 | 'outline-close-rtl-in-margins | 1100 | 'outline-close-rtl-in-margins |
| 1107 | 'outline-close-in-margins) | 1101 | 'outline-close-in-margins) |
| 1108 | 'outline-open-in-margins))) | 1102 | 'outline-open-in-margins)))) |
| 1109 | (inhibit-read-only t)) | ||
| 1110 | (overlay-put | 1103 | (overlay-put |
| 1111 | o 'before-string | 1104 | o 'before-string |
| 1112 | (propertize " " 'display | 1105 | (propertize " " 'display |
| @@ -1451,6 +1444,9 @@ convenient way to make a table of contents of the buffer." | |||
| 1451 | (insert "\n\n")))))) | 1444 | (insert "\n\n")))))) |
| 1452 | (kill-new (buffer-string))))))) | 1445 | (kill-new (buffer-string))))))) |
| 1453 | 1446 | ||
| 1447 | |||
| 1448 | ;;; Initial visibility | ||
| 1449 | |||
| 1454 | (defcustom outline-default-state nil | 1450 | (defcustom outline-default-state nil |
| 1455 | "If non-nil, some headings are initially outlined. | 1451 | "If non-nil, some headings are initially outlined. |
| 1456 | 1452 | ||
| @@ -1629,6 +1625,9 @@ LEVEL, decides of subtree visibility according to | |||
| 1629 | beg end))) | 1625 | beg end))) |
| 1630 | (run-hooks 'outline-view-change-hook))) | 1626 | (run-hooks 'outline-view-change-hook))) |
| 1631 | 1627 | ||
| 1628 | |||
| 1629 | ;;; Visibility cycling | ||
| 1630 | |||
| 1632 | (defun outline--cycle-state () | 1631 | (defun outline--cycle-state () |
| 1633 | "Return the cycle state of current heading. | 1632 | "Return the cycle state of current heading. |
| 1634 | Return either `hide-all', `headings-only', or `show-all'." | 1633 | Return either `hide-all', `headings-only', or `show-all'." |
| @@ -1742,6 +1741,19 @@ With a prefix argument, show headings up to that LEVEL." | |||
| 1742 | (message "Show all"))))) | 1741 | (message "Show all"))))) |
| 1743 | 1742 | ||
| 1744 | 1743 | ||
| 1744 | ;;; Button/margin indicators | ||
| 1745 | |||
| 1746 | (defun outline--fix-buttons-after-change (beg end _len) | ||
| 1747 | ;; Handle whole lines | ||
| 1748 | (save-excursion (goto-char beg) (setq beg (pos-bol))) | ||
| 1749 | (save-excursion (goto-char end) (setq end (pos-eol))) | ||
| 1750 | (when outline--use-buttons | ||
| 1751 | (remove-overlays beg end 'outline-button t)) | ||
| 1752 | (when outline--use-margins | ||
| 1753 | (remove-overlays beg end 'outline-margin t)) | ||
| 1754 | (outline--fix-up-all-buttons beg end)) | ||
| 1755 | |||
| 1756 | |||
| 1745 | (defvar-keymap outline-navigation-repeat-map | 1757 | (defvar-keymap outline-navigation-repeat-map |
| 1746 | "C-b" #'outline-backward-same-level | 1758 | "C-b" #'outline-backward-same-level |
| 1747 | "b" #'outline-backward-same-level | 1759 | "b" #'outline-backward-same-level |