]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/outline.el (outline--fix-buttons-after-change): New function.
authorJuri Linkov <juri@linkov.net>
Thu, 13 Oct 2022 07:13:07 +0000 (10:13 +0300)
committerJuri Linkov <juri@linkov.net>
Thu, 13 Oct 2022 07:13:07 +0000 (10:13 +0300)
(outline-minor-mode): Use it.
(outline--make-margin-overlay): Remove inhibit-read-only.

lisp/outline.el

index 93a9247f613269045fdd6e89c67cc53dcf6db95e..b2b36a764ceb67caee3a0a8c69174c27b53f6b56 100644 (file)
@@ -516,13 +516,7 @@ See the command `outline-mode' for more information on this mode."
           (set-window-buffer nil (window-buffer)))
         (when (or outline--use-buttons outline--use-margins)
           (add-hook 'after-change-functions
-                    (lambda (beg end _len)
-                      (when outline--use-buttons
-                        (remove-overlays beg end 'outline-button t))
-                      (when outline--use-margins
-                        (remove-overlays beg end 'outline-margin t))
-                      (outline--fix-up-all-buttons beg end))
-                    nil t))
+                    #'outline--fix-buttons-after-change nil t))
         (when outline-minor-mode-highlight
           (if (and global-font-lock-mode (font-lock-specified-p major-mode))
               (progn
@@ -1105,8 +1099,7 @@ If non-nil, EVENT should be a mouse event."
                                    (if outline--use-rtl
                                        'outline-close-rtl-in-margins
                                      'outline-close-in-margins)
-                                 'outline-open-in-margins)))
-          (inhibit-read-only t))
+                                 'outline-open-in-margins))))
       (overlay-put
        o 'before-string
        (propertize " " 'display
@@ -1451,6 +1444,9 @@ convenient way to make a table of contents of the buffer."
                     (insert "\n\n"))))))
           (kill-new (buffer-string)))))))
 
+\f
+;;; Initial visibility
+
 (defcustom outline-default-state nil
   "If non-nil, some headings are initially outlined.
 
@@ -1629,6 +1625,9 @@ LEVEL, decides of subtree visibility according to
          beg end)))
     (run-hooks 'outline-view-change-hook)))
 
+\f
+;;; Visibility cycling
+
 (defun outline--cycle-state ()
   "Return the cycle state of current heading.
 Return either `hide-all', `headings-only', or `show-all'."
@@ -1741,6 +1740,19 @@ With a prefix argument, show headings up to that LEVEL."
       (setq outline--cycle-buffer-state 'show-all)
       (message "Show all")))))
 
+\f
+;;; Button/margin indicators
+
+(defun outline--fix-buttons-after-change (beg end _len)
+  ;; Handle whole lines
+  (save-excursion (goto-char beg) (setq beg (pos-bol)))
+  (save-excursion (goto-char end) (setq end (pos-eol)))
+  (when outline--use-buttons
+    (remove-overlays beg end 'outline-button t))
+  (when outline--use-margins
+    (remove-overlays beg end 'outline-margin t))
+  (outline--fix-up-all-buttons beg end))
+
 \f
 (defvar-keymap outline-navigation-repeat-map
   "C-b" #'outline-backward-same-level