* lisp/foldout.el (foldout-widen-to-current-fold): New command.
* doc/emacs/text.texi (Foldout): Document it.
* etc/NEWS: Announce it. (Bug#73286)
(cherry picked from commit
ebfd5874f0b74cec06572ffc3e9bf7288bd5e77b)
subheadings, specify a negative argument. For example, @w{@kbd{M--2 C-c
C-x}} exits two folds and leaves the text and subheadings exposed.
+@findex foldout-widen-to-current-fold
+ While working within a fold, you may wish to use Emacs's standard
+narrowing commands such as @kbd{C-x n n} (@code{narrow-to-region}) or
+@kbd{C-x n d} (@code{narrow-to-defun}). After using these commands,
+@code{foldout-widen-to-current-fold}) allows you to widen back to the
+current fold level, rather than the entire buffer. If you're not
+currently in a fold, it behaves like @code{widen}.
+
Foldout mode also provides mouse commands for entering and exiting
folds, and for showing and hiding text:
customize these variables to "python3" if you want to use Python 3
instead.
+** Foldout
+
+---
+*** New command 'foldout-widen-to-current-fold'.
+This command widens the view to the current fold level when in a fold,
+or behaves like 'widen' if not in a fold.
+
\f
* New Modes and Packages in Emacs 31.1
(error "Not a heading line")))
\f
+(defun foldout-widen-to-current-fold ()
+ "Widen to the current fold level.
+If in a fold, widen to that fold's boundaries.
+If not in a fold, acts like `widen'."
+ (interactive)
+ (if foldout-fold-list
+ (let* ((last-fold (car foldout-fold-list))
+ (start (car last-fold))
+ (end (cdr last-fold)))
+ (widen)
+ (narrow-to-region start
+ (if end (1- (marker-position end)) (point-max))))
+ (widen)))
+\f
+
;;; Keymaps:
(defvar foldout-inhibit-key-bindings nil