[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master fd49e3c62b: Add new command to toggle hiding all widgets in a Cus
From: |
Lars Ingebrigtsen |
Subject: |
master fd49e3c62b: Add new command to toggle hiding all widgets in a Customize buffer |
Date: |
Tue, 10 May 2022 11:48:43 -0400 (EDT) |
branch: master
commit fd49e3c62bf162bbe27de6ecc107a4e934a21708
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add new command to toggle hiding all widgets in a Customize buffer
* lisp/cus-edit.el (custom-commands): Add menu entry.
(custom-toggle-hide-all-variables): New command (bug#15748).
---
etc/NEWS | 7 +++++++
lisp/cus-edit.el | 30 +++++++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index 1c89493a1f..ac357a2886 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -780,6 +780,13 @@ so automatically.
* Changes in Specialized Modes and Packages in Emacs 29.1
+** Customize
+
+---
+*** New command 'custom-toggle-hide-all-variables'.
+This is bound to 'H' and toggles whether to hide or show the widget
+contents.
+
** ispell
---
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index dae97b0230..0870bf6782 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -441,6 +441,7 @@ Use group `text' for this instead. This group is
deprecated."
(define-key map "u" 'Custom-goto-parent)
(define-key map "n" 'widget-forward)
(define-key map "p" 'widget-backward)
+ (define-key map "H" 'custom-toggle-hide-all-variables)
map)
"Keymap for `Custom-mode'.")
@@ -745,6 +746,9 @@ groups after non-groups, if nil do not order groups at all."
(or custom-file user-init-file)
"Un-customize settings in this and future sessions." "delete"
"Uncustomize"
(modified set changed rogue saved))
+ (" Toggle hiding all values " custom-toggle-hide-all-variables
+ t "Toggle hiding all values."
+ "hide" "Hide" t)
(" Help for Customize " Custom-help t "Get help for using Customize."
"help" "Help" t)
(" Exit " Custom-buffer-done t "Exit Customize." "exit" "Exit" t))
@@ -2834,6 +2838,29 @@ try matching its doc string against
`custom-guess-doc-alist'."
(custom-add-parent-links widget))
(custom-add-see-also widget)))))
+(defvar custom--hidden-state)
+
+(defun custom-toggle-hide-all-variables ()
+ "Toggle whether to show contents of the widgets in the current buffer."
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ ;; Surely there's a better way to find all the "top level" widgets
+ ;; in a buffer, but I couldn't find it.
+ (while (not (eobp))
+ (when-let* ((widget (widget-at (point)))
+ (parent (widget-get widget :parent))
+ (state (widget-get parent :custom-state)))
+ (when (eq state custom--hidden-state)
+ (custom-toggle-hide-variable widget)))
+ (forward-line 1)))
+ (setq custom--hidden-state (if (eq custom--hidden-state 'hidden)
+ 'standard
+ 'hidden))
+ (if (eq custom--hidden-state 'hidden)
+ (message "All variables hidden")
+ (message "All variables shown")))
+
(defun custom-toggle-hide-variable (visibility-widget &rest _ignore)
"Toggle the visibility of a `custom-variable' parent widget.
By default, this signals an error if the parent has unsaved
@@ -5230,7 +5257,8 @@ if that value is non-nil."
:label (nth 5 arg)))
custom-commands)
(setq custom-tool-bar-map map))))
- (setq-local custom--invocation-options nil)
+ (setq-local custom--invocation-options nil
+ custom--hidden-state 'hidden)
(setq-local revert-buffer-function #'custom--revert-buffer)
(make-local-variable 'custom-options)
(make-local-variable 'custom-local-buffer)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master fd49e3c62b: Add new command to toggle hiding all widgets in a Customize buffer,
Lars Ingebrigtsen <=