diff --git a/etc/NEWS b/etc/NEWS index 6bb32667731..d7c04f38ab4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2268,6 +2268,11 @@ string instead of preprending it and 'tmm-mid-prompt' to said entry. ** 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'. This command widens the view to the current fold level when in a fold, diff --git a/lisp/foldout.el b/lisp/foldout.el index fcc5e294561..748f56c0c9c 100644 --- a/lisp/foldout.el +++ b/lisp/foldout.el @@ -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. 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") (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 (if (null foldout-fold-list) @@ -369,7 +369,10 @@ exited and text is left visible." (if end-marker (1- (marker-position end-marker)) (point-max))))) - (recenter) + + (if hide-fold + (recenter) + (goto-char original-point)) ;; update the mode line (foldout-update-mode-line)))