[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ebfd5874f0b: Add foldout command for widening to current fold
From: |
Eli Zaretskii |
Subject: |
master ebfd5874f0b: Add foldout command for widening to current fold |
Date: |
Sat, 12 Oct 2024 07:53:06 -0400 (EDT) |
branch: master
commit ebfd5874f0b74cec06572ffc3e9bf7288bd5e77b
Author: Paul Nelson <ultrono@gmail.com>
Commit: Eli Zaretskii <eliz@gnu.org>
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)
---
doc/emacs/text.texi | 8 ++++++++
etc/NEWS | 7 +++++++
lisp/foldout.el | 15 +++++++++++++++
3 files changed, 30 insertions(+)
diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi
index 9bc2a6407d5..a6d19a32bc5 100644
--- a/doc/emacs/text.texi
+++ b/doc/emacs/text.texi
@@ -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:
diff --git a/etc/NEWS b/etc/NEWS
index c2919169bbf..daaae54d7d3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
diff --git a/lisp/foldout.el b/lisp/foldout.el
index 5799318fc6f..a4b6a402c5c 100644
--- a/lisp/foldout.el
+++ b/lisp/foldout.el
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master ebfd5874f0b: Add foldout command for widening to current fold,
Eli Zaretskii <=