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

Improve foldout-exit-fold with negative arg (bug#77370)

* lisp/foldout.el (foldout-exit-fold): When called with a
negative prefix argument (so that the exited fold is not
hidden), preserve the position of point and do not recenter.
This commit is contained in:
Paul Nelson 2025-03-29 19:07:13 +01:00 committed by Juri Linkov
parent c9372ced9c
commit a0761ddb4b
2 changed files with 11 additions and 3 deletions

View file

@ -2268,6 +2268,11 @@ string instead of preprending it and 'tmm-mid-prompt' to said entry.
** Foldout ** Foldout
*** Improved behavior of 'foldout-exit-fold' with negative prefix argument.
When 'foldout-exit-fold' is called with a negative argument (so that the
exited fold remains visible), the position of point and window view are
preserved.
--- ---
*** New command 'foldout-widen-to-current-fold'. *** New command 'foldout-widen-to-current-fold'.
This command widens the view to the current fold level when in a fold, This command widens the view to the current fold level when in a fold,

View file

@ -290,10 +290,10 @@ optional arg EXPOSURE \(interactively with prefix arg) changes this:-
"Return to the ARG'th enclosing fold view. With ARG = 0 exit all folds. "Return to the ARG'th enclosing fold view. With ARG = 0 exit all folds.
Normally causes exited folds to be hidden, but with ARG < 0, -ARG folds are Normally causes exited folds to be hidden, but with ARG < 0, -ARG folds are
exited and text is left visible." exited, text is left visible, and point position is preserved."
(interactive "p") (interactive "p")
(let ((hide-fold t) start-marker end-marker (let ((hide-fold t) start-marker end-marker
beginning-of-heading end-of-subtree) beginning-of-heading end-of-subtree (original-point (point)))
;; check there are some folds to leave ;; check there are some folds to leave
(if (null foldout-fold-list) (if (null foldout-fold-list)
@ -369,7 +369,10 @@ exited and text is left visible."
(if end-marker (if end-marker
(1- (marker-position end-marker)) (1- (marker-position end-marker))
(point-max))))) (point-max)))))
(recenter)
(if hide-fold
(recenter)
(goto-char original-point))
;; update the mode line ;; update the mode line
(foldout-update-mode-line))) (foldout-update-mode-line)))