1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

Add foldout command for widening to current fold

* lisp/foldout.el (foldout-widen-to-current-fold): New command.
* doc/emacs/text.texi (Foldout): Document it.
* etc/NEWS: Announce it.  (Bug#73286)
This commit is contained in:
Paul Nelson 2024-09-16 01:33:53 +02:00 committed by Eli Zaretskii
parent 0e9502b10e
commit ebfd5874f0
3 changed files with 30 additions and 0 deletions

View File

@ -1396,6 +1396,14 @@ exits all folds.
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:

View File

@ -535,6 +535,13 @@ instead.
*** A new shortcut to navigate to previous menu.
The hardcoded "^" shortcut gets you back to the previous menu.
** 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.
* New Modes and Packages in Emacs 31.1

View File

@ -490,6 +490,21 @@ Signal an error if the event didn't occur on a heading."
(error "Not a heading line")))
(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)))
;;; Keymaps:
(defvar foldout-inhibit-key-bindings nil