From c6f5654af57a6fb99300c9421280715d59ec8df5 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 13 Jul 2024 17:50:51 +0200 Subject: [PATCH] cus-edit: Add minibuffer actions, and mark mode-specific commands --- lisp/cus-edit.el | 57 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 6de308ea639..21e79202a0b 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -842,7 +842,7 @@ has been executed, nil otherwise." (defun Custom-set (&rest _ignore) "Set the current value of all edited settings in the buffer." - (interactive) + (interactive "" Custom-mode) (custom-command-apply (lambda (child) (when (eq (widget-get child :custom-state) 'modified) @@ -853,7 +853,7 @@ has been executed, nil otherwise." "Set all edited settings, then save all settings that have been set. If a setting was edited and set before, this saves it. If a setting was merely edited before, this sets it then saves it." - (interactive) + (interactive "" Custom-mode) (let (edited-widgets) (when (custom-command-apply (lambda (child) @@ -880,7 +880,7 @@ setting was merely edited before, this sets it then saves it." (defun Custom-reset-current (&rest _ignore) "Reset all edited settings in the buffer to show their current values." - (interactive) + (interactive "" Custom-mode) (custom-command-apply (lambda (widget) (if (memq (widget-get widget :custom-state) '(modified changed)) @@ -890,7 +890,7 @@ setting was merely edited before, this sets it then saves it." (defun Custom-reset-saved (&rest _ignore) "Reset all edited or set settings in the buffer to their saved value. This also shows the saved values in the buffer." - (interactive) + (interactive "" Custom-mode) (custom-command-apply (lambda (widget) (if (memq (widget-get widget :custom-state) '(modified set changed rogue)) @@ -944,7 +944,7 @@ This also shows the saved values in the buffer." The immediate result is to restore them to their standard values. This operation eliminates any saved values for the group members, making them as if they had never been customized at all." - (interactive) + (interactive "" Custom-mode) ;; Bind these temporarily. (let ((custom-reset-standard-variables-list '(t)) (custom-reset-standard-faces-list '(t))) @@ -1171,6 +1171,10 @@ for the MODE to customize." t nil nil (if group (symbol-name major-mode)))))))) (customize-group (custom-group-of-mode mode))) +(put 'customize-mode 'minibuffer-action + (cons (lambda (m) (save-selected-window (customize-mode (intern m)))) + "customize")) + (defun customize-read-group () (let* ((sym (symbol-at-point)) (def (or (and sym @@ -1212,12 +1216,18 @@ If OTHER-WINDOW is non-nil, display in another window." (t (pop-to-buffer-same-window name))))) +(put 'customize-group 'minibuffer-action + (cons (lambda (g) (save-selected-window (customize-group g))) + "customize")) + ;;;###autoload (defun customize-group-other-window (&optional group) "Customize GROUP, which must be a customization group, in another window." (interactive (list (customize-read-group))) (customize-group group t)) +(put 'customize-group 'minibuffer-action 'customize-group) + ;;;###autoload (defalias 'customize-variable 'customize-option) @@ -1234,6 +1244,10 @@ If OTHER-WINDOW is non-nil, display in another window." (unless (eq symbol basevar) (message "`%s' is an alias for `%s'" symbol basevar)))) +(put 'customize-option 'minibuffer-action + (cons (lambda (v) (save-selected-window (customize-option (intern v)))) + "customize")) + (defface custom-boolean-option-on '((t :inherit success)) "Face for the \"ON\" indicator of boolean user option.") @@ -1310,6 +1324,8 @@ Show the buffer in another window, but don't select it." (unless (eq symbol basevar) (message "`%s' is an alias for `%s'" symbol basevar)))) +(put 'customize-option-other-window 'minibuffer-action 'customize-option) + (defvar customize-changed-options-previous-release "30.1" "Version for `customize-changed' to refer back to by default.") @@ -1360,7 +1376,6 @@ release. With argument SINCE-VERSION (a string), customize all settings that were added or redefined since that version." - (interactive (list (read-from-minibuffer @@ -1493,6 +1508,10 @@ suggest to customize that face, if it's customizable." (format "*Customize Face: %s*" (custom-unlispify-tag-name face)))))) +(put 'customize-face 'minibuffer-action + (cons (lambda (f) (save-selected-window (customize-face (intern f)))) + "customize")) + ;;;###autoload (defun customize-face-other-window (&optional face) "Show customization buffer for face FACE in other window. @@ -1504,6 +1523,8 @@ suggest to customize that face, if it's customizable." (or (face-at-point t t) "all faces") t))) (customize-face face t)) +(put 'customize-face-other-window 'minibuffer-action 'customize-face) + (defun custom-unsaved-options () "List of options and faces set in this session but not saved. Each entry is of the form (SYMBOL TYPE), where TYPE is one of the @@ -1615,24 +1636,34 @@ If TYPE is `groups', include only groups." (custom-sort-items found t custom-buffer-order-groups)) "*Customize Apropos*"))) +(put 'customize-apropos 'minibuffer-action + (cons (lambda (p) (save-selected-window (customize-apropos p))) + "customize-apropos")) + ;;;###autoload (defun customize-apropos-options (regexp &optional _ignored) "Customize all loaded customizable options matching REGEXP." (interactive (list (apropos-read-pattern "options"))) (customize-apropos regexp 'options)) +(put 'customize-apropos-options 'minibuffer-action 'customize-apropos) + ;;;###autoload (defun customize-apropos-faces (regexp) "Customize all loaded faces matching REGEXP." (interactive (list (apropos-read-pattern "faces"))) (customize-apropos regexp 'faces)) +(put 'customize-apropos-faces 'minibuffer-action 'customize-apropos) + ;;;###autoload (defun customize-apropos-groups (regexp) "Customize all loaded groups matching REGEXP." (interactive (list (apropos-read-pattern "groups"))) (customize-apropos regexp 'groups)) +(put 'customize-apropos-groups 'minibuffer-action 'customize-apropos) + ;;;###autoload (defun custom-prompt-customize-unsaved-options () "Prompt user to customize any unsaved customization options. @@ -1734,7 +1765,7 @@ This button will have a menu with all three reset operations." (defun Custom-buffer-done (&rest _ignore) "Exit current Custom buffer according to `custom-buffer-done-kill'." - (interactive) + (interactive "" Custom-mode) (quit-window custom-buffer-done-kill)) (defvar custom-button nil @@ -2955,7 +2986,7 @@ between the expanded view, where the values of the settings and the value menus to change them are visible; and the concise view, where only the minimal details are shown, usually the name, the doc string and little else." - (interactive) + (interactive "" Custom-mode) (save-excursion (goto-char (point-min)) ;; Surely there's a better way to find all the "top level" widgets @@ -5341,7 +5372,7 @@ The format is suitable for use with `easy-menu-define'." (defun Custom-no-edit (_pos &optional _event) "Invoke button at POS, or refuse to allow editing of Custom buffer." - (interactive "@d") + (interactive "" Custom-mode) (error "You can't edit this part of the Custom buffer")) (defun Custom-newline (pos &optional event) @@ -5349,7 +5380,7 @@ The format is suitable for use with `easy-menu-define'." To see what function the widget will call, use the `widget-describe' command." - (interactive "@d") + (interactive "" Custom-mode) (let ((button (get-char-property pos 'button))) ;; If there is no button at point, then use the one at the start ;; of the line, if it is a custom-group-link (bug#2298). @@ -5364,7 +5395,7 @@ To see what function the widget will call, use the (defun Custom-goto-parent () "Go to the parent group listed at the top of this buffer. If several parents are listed, go to the first of them." - (interactive) + (interactive "" Custom-mode) (save-excursion (goto-char (point-min)) (if (search-forward "\nParent groups: " nil t) @@ -5777,6 +5808,10 @@ changes." (format "*Customize Icon: %s*" (custom-unlispify-tag-name icon)))) +(put 'customize-icon 'minibuffer-action + (cons (lambda (i) (save-selected-window (customize-icon (intern i)))) + "customize")) + (defun custom-icon-state-set (widget &optional state) "Set the state of WIDGET to STATE." (let ((value (custom--icons-widget-value -- 2.39.2