From ff644701393431f59a4bfc8764f3c9f719f42c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Wed, 14 Jan 2026 22:06:01 -0600 Subject: [PATCH] hideshow: Use 'message' instead of 'user-error'. (Bug#80201) Using 'user-error' in 'hs-minor-mode', prevents the major-mode from initializing correctly when hideshow is not supported in that mode, using 'message' instead fixes this. * lisp/progmodes/hideshow.el (hs-minor-mode): Tweak. --- lisp/progmodes/hideshow.el | 60 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index 4f2942ee9e9..3043b04c5ad 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -1498,36 +1498,38 @@ Key bindings: :keymap hs-minor-mode-map (setq hs-headline nil) - (if hs-minor-mode - (progn - (unless (and comment-start comment-end) - (setq hs-minor-mode nil) - (user-error "%S doesn't support the Hideshow minor mode" - major-mode)) + (cond + ((and hs-minor-mode + (not (and comment-start comment-end))) + (setq hs-minor-mode nil) + (message "%S doesn't support the Hideshow minor mode" + major-mode)) - ;; Set the old variables - (hs-grok-mode-type) - ;; Turn off this mode if we change major modes. - (add-hook 'change-major-mode-hook - #'turn-off-hideshow nil t) - (setq-local line-move-ignore-invisible t) - (add-to-invisibility-spec '(hs . t)) - ;; Add block indicators - (when (and hs-show-indicators - (or (and (integerp hs-indicator-maximum-buffer-size) - (< (buffer-size) hs-indicator-maximum-buffer-size)) - (not hs-indicator-maximum-buffer-size))) - (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))) + (hs-minor-mode + ;; Set the old variables + (hs-grok-mode-type) + ;; Turn off this mode if we change major modes. + (add-hook 'change-major-mode-hook + #'turn-off-hideshow nil t) + (setq-local line-move-ignore-invisible t) + (add-to-invisibility-spec '(hs . t)) + ;; Add block indicators + (when (and hs-show-indicators + (or (and (integerp hs-indicator-maximum-buffer-size) + (< (buffer-size) hs-indicator-maximum-buffer-size)) + (not hs-indicator-maximum-buffer-size))) + (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))) + (t (remove-from-invisibility-spec '(hs . t)) (remove-overlays nil nil 'hs-indicator t) (remove-overlays nil nil 'invisible 'hs) @@ -1539,7 +1541,7 @@ Key bindings: (kill-local-variable 'fringes-outside-margins) ;; Force removal of margins (when (eq (current-buffer) (window-buffer)) - (set-window-buffer nil (window-buffer))))))) + (set-window-buffer nil (window-buffer)))))))) ;;;; that's it