diff options
author | Eli Zaretskii <eliz@gnu.org> | 2023-10-28 04:56:22 -0400 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2023-10-28 04:56:22 -0400 |
commit | a2f88746b8a65a22119805174dd6f0d2aedf01c7 (patch) | |
tree | 7da9193d18863f6bd369923c0536e090f8656d14 /lisp/cus-edit.el | |
parent | 12d10872f479f93cb2e0e1a6e919a185af621b21 (diff) | |
parent | 5f60913208f3fb2df9a2d3bda1655e01075bf446 (diff) | |
download | emacs-a2f88746b8a65a22119805174dd6f0d2aedf01c7.tar.gz emacs-a2f88746b8a65a22119805174dd6f0d2aedf01c7.tar.bz2 emacs-a2f88746b8a65a22119805174dd6f0d2aedf01c7.zip |
Merge from origin/emacs-29
5f60913208f Fix State button for customize-icon (Bug#66635)
27c71979ff1 ; Another Texinfo fix
889a550ca08 ; Fix Texinfo warnings
893c344b4e4 Fix the use of adaptive-fill-regexp in treesit indent preset
1098c114b74 Fix treesit-install-language-grammar (bug#66673)
491ee428c08 Fix treesit-explore-mode (bug#66431)
ee043a2703d tsx-ts-mode--font-lock-compatibility-bb1f97b: Re-fix the ...
Diffstat (limited to 'lisp/cus-edit.el')
-rw-r--r-- | lisp/cus-edit.el | 71 |
1 files changed, 59 insertions, 12 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 706e08d5657..953b8b8b80f 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -5366,11 +5366,6 @@ The following properties have special meanings for this widget: :hidden-states should be a list of widget states for which the widget's initial contents are to be hidden. -:custom-form should be a symbol describing how to display and - edit the variable---either `edit' (using edit widgets), - `lisp' (as a Lisp sexp), or `mismatch' (should not happen); - if nil, use the return value of `custom-variable-default-form'. - :shown-value, if non-nil, should be a list whose `car' is the variable value to display in place of the current value. @@ -5383,11 +5378,34 @@ The following properties have special meanings for this widget: :custom-category 'option :custom-state nil :custom-form nil - :value-create 'custom-icon-value-create + :value-create #'custom-icon-value-create :hidden-states '(standard) - :custom-set 'custom-icon-set - :custom-reset-current 'custom-redraw - :custom-reset-saved 'custom-variable-reset-saved) + :action #'custom-icon-action + :custom-set #'custom-icon-set + :custom-reset-current #'custom-redraw) + ;; Not implemented yet. + ;; :custom-reset-saved 'custom-icon-reset-saved) + +(defvar custom-icon-extended-menu + (let ((map (make-sparse-keymap))) + (define-key-after map [custom-icon-set] + '(menu-item "Set for Current Session" custom-icon-set + :enable (eq (widget-get custom-actioned-widget :custom-state) + 'modified))) + (when (or custom-file init-file-user) + (define-key-after map [custom-icon-save] + '(menu-item "Save for Future Sessions" custom-icon-save + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set changed))))) + (define-key-after map [custom-redraw] + '(menu-item "Undo Edits" custom-redraw + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified changed)))) + map) + "A menu for `custom-icon' widgets. +Used in `custom-icon-action' to show a menu to the user.") (defun custom-icon-value-create (widget) "Here is where you edit the icon's specification." @@ -5517,6 +5535,24 @@ The following properties have special meanings for this widget: (custom-add-parent-links widget)) (custom-add-see-also widget))))) +(defun custom-icon-action (widget &optional event) + "Show the menu for `custom-icon' WIDGET. +Optional EVENT is the location for the menu." + (if (eq (widget-get widget :custom-state) 'hidden) + (custom-toggle-hide widget) + (unless (eq (widget-get widget :custom-state) 'modified) + (custom-icon-state-set widget)) + (custom-redraw-magic widget) + (let* ((completion-ignore-case t) + (custom-actioned-widget widget) + (answer (widget-choose (concat "Operation on " + (custom-unlispify-tag-name + (widget-get widget :value))) + custom-icon-extended-menu + event))) + (when answer + (funcall answer widget))))) + (defun custom-toggle-hide-icon (visibility-widget &rest _ignore) "Toggle the visibility of a `custom-icon' parent widget. By default, this signals an error if the parent has unsaved @@ -5553,10 +5589,21 @@ changes." (user-error "Cannot update hidden icon")) (setq val (custom--icons-widget-value child)) - (unless (equal val (icon-complete-spec symbol)) - (custom-variable-backup-value widget)) + ;; FIXME: What was the intention here? + ;; (unless (equal val (icon-complete-spec symbol)) + ;; (custom-variable-backup-value widget)) (custom-push-theme 'theme-icon symbol 'user 'set val) - (custom-redraw-magic widget))) + (custom-redraw widget))) + +(defun custom-icon-save (widget) + "Save value of icon edited by widget WIDGET." + (custom-set-icons (cons (widget-value widget) + (list + (custom--icons-widget-value + (car (widget-get widget :children)))))) + (custom-save-all) + (custom-icon-state-set widget) + (custom-redraw-magic widget)) ;;;###autoload (defun customize-icon (icon) |