1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Improve margin handling in outline-minor-mode (bug#76193)

* lisp/outline.el (outline-minor-mode): Make margin changes
idempotent to multiple calls.  When enabling, check for
nil 'outline--margin-width' instead of relying on the value
of 'left-margin-width'.  When disabling, check for non-nil
'outline--margin-width' and set back to nil afterwards.
Use kill-local-variable for 'fringes-outside-margins'.
This commit is contained in:
Juri Linkov 2025-12-02 19:21:21 +02:00
parent df4d8c1475
commit d2ac3cfb90

View file

@ -570,8 +570,7 @@ See the command `outline-mode' for more information on this mode."
(setq-local outline--use-rtl t)) (setq-local outline--use-rtl t))
(setq-local outline--button-icons (outline--create-button-icons)) (setq-local outline--button-icons (outline--create-button-icons))
(when (and (eq outline-minor-mode-use-buttons 'in-margins) (when (and (eq outline-minor-mode-use-buttons 'in-margins)
(> 1 (if outline--use-rtl right-margin-width (null outline--margin-width))
left-margin-width)))
(setq outline--margin-width (setq outline--margin-width
(or outline-margin-width (or outline-margin-width
(ceiling (ceiling
@ -629,6 +628,7 @@ See the command `outline-mode' for more information on this mode."
(when outline-minor-mode-use-buttons (when outline-minor-mode-use-buttons
(outline--remove-buttons (point-min) (point-max)) (outline--remove-buttons (point-min) (point-max))
(when (and (eq outline-minor-mode-use-buttons 'in-margins) (when (and (eq outline-minor-mode-use-buttons 'in-margins)
outline--margin-width
(< 0 (if outline--use-rtl right-margin-width (< 0 (if outline--use-rtl right-margin-width
left-margin-width))) left-margin-width)))
(if outline--use-rtl (if outline--use-rtl
@ -636,7 +636,8 @@ See the command `outline-mode' for more information on this mode."
outline--margin-width)) outline--margin-width))
(setq-local left-margin-width (- left-margin-width (setq-local left-margin-width (- left-margin-width
outline--margin-width))) outline--margin-width)))
(setq-local fringes-outside-margins nil) (setq-local outline--margin-width nil)
(kill-local-variable 'fringes-outside-margins)
;; Force removal of margins ;; Force removal of margins
(when (eq (current-buffer) (window-buffer)) (when (eq (current-buffer) (window-buffer))
(set-window-buffer nil (window-buffer))))))) (set-window-buffer nil (window-buffer)))))))