From 06e9943412fccda47c3ce18344e8b0f4eb42f8fe Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 9 Dec 2025 09:44:24 +0200 Subject: [PATCH] * lisp/progmodes/hideshow.el (hs-minor-mode): Show/hide margins. Increment 'left-margin-width' when 'hs-indicator-type' is 'margin', and decrement it on disabling 'hs-minor-mode'. --- lisp/progmodes/hideshow.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index 1317b1a4f43..f0bea28ceac 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -1497,13 +1497,26 @@ Key bindings: (when (and (not (display-graphic-p)) (eq hs-indicator-type 'fringe)) (setq-local hs-indicator-type 'margin)) + (when (eq hs-indicator-type 'margin) + (setq-local left-margin-width (1+ left-margin-width)) + (setq-local fringes-outside-margins t) + ;; Force display of margins + (when (eq (current-buffer) (window-buffer)) + (set-window-buffer nil (window-buffer)))) (jit-lock-register #'hs--add-indicators))) (remove-from-invisibility-spec '(hs . t)) (remove-overlays nil nil 'hs-indicator t) (remove-overlays nil nil 'invisible 'hs) (when hs-show-indicators - (jit-lock-unregister #'hs--add-indicators)))) + (jit-lock-unregister #'hs--add-indicators) + (when (and (eq hs-indicator-type 'margin) + (< 0 left-margin-width)) + (setq-local left-margin-width (1- left-margin-width)) + (kill-local-variable 'fringes-outside-margins) + ;; Force removal of margins + (when (eq (current-buffer) (window-buffer)) + (set-window-buffer nil (window-buffer))))))) ;;;; that's it