diff options
| author | Mauro Aranda | 2023-10-19 08:46:35 -0300 |
|---|---|---|
| committer | Stefan Kangas | 2023-10-22 18:39:52 +0200 |
| commit | 5f60913208f3fb2df9a2d3bda1655e01075bf446 (patch) | |
| tree | e0dbfc8f02dccdbbe163640c7428bbccc9244c8d /lisp | |
| parent | 27c71979ff11c4a6c433f4cd6f7a390124c5fc3d (diff) | |
| download | emacs-5f60913208f3fb2df9a2d3bda1655e01075bf446.tar.gz emacs-5f60913208f3fb2df9a2d3bda1655e01075bf446.zip | |
Fix State button for customize-icon (Bug#66635)
* lisp/cus-edit.el (custom-icon-action): New function.
(custom-icon): Use it as the :action. Otherwise, clicking the State
button is a noop. Remove irrelevant stuff from the docstring and
comment out some copy-pasta.
(custom-icon-extended-menu): New variable, the menu to show upon
:action.
(custom-icon-set): Really redraw the widget with the new settings.
Comment out strange call to custom-variable-backup-value.
(custom-icon-save): New function.
* lisp/emacs-lisp/icons.el (icons--merge-spec): Fix call to plist-get
and avoid infloop.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/cus-edit.el | 71 | ||||
| -rw-r--r-- | lisp/emacs-lisp/icons.el | 6 |
2 files changed, 62 insertions, 15 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 9ec10e63221..75d7d3ffaad 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -5332,11 +5332,6 @@ The following properties have special meanings for this widget: | |||
| 5332 | :hidden-states should be a list of widget states for which the | 5332 | :hidden-states should be a list of widget states for which the |
| 5333 | widget's initial contents are to be hidden. | 5333 | widget's initial contents are to be hidden. |
| 5334 | 5334 | ||
| 5335 | :custom-form should be a symbol describing how to display and | ||
| 5336 | edit the variable---either `edit' (using edit widgets), | ||
| 5337 | `lisp' (as a Lisp sexp), or `mismatch' (should not happen); | ||
| 5338 | if nil, use the return value of `custom-variable-default-form'. | ||
| 5339 | |||
| 5340 | :shown-value, if non-nil, should be a list whose `car' is the | 5335 | :shown-value, if non-nil, should be a list whose `car' is the |
| 5341 | variable value to display in place of the current value. | 5336 | variable value to display in place of the current value. |
| 5342 | 5337 | ||
| @@ -5349,11 +5344,34 @@ The following properties have special meanings for this widget: | |||
| 5349 | :custom-category 'option | 5344 | :custom-category 'option |
| 5350 | :custom-state nil | 5345 | :custom-state nil |
| 5351 | :custom-form nil | 5346 | :custom-form nil |
| 5352 | :value-create 'custom-icon-value-create | 5347 | :value-create #'custom-icon-value-create |
| 5353 | :hidden-states '(standard) | 5348 | :hidden-states '(standard) |
| 5354 | :custom-set 'custom-icon-set | 5349 | :action #'custom-icon-action |
| 5355 | :custom-reset-current 'custom-redraw | 5350 | :custom-set #'custom-icon-set |
| 5356 | :custom-reset-saved 'custom-variable-reset-saved) | 5351 | :custom-reset-current #'custom-redraw) |
| 5352 | ;; Not implemented yet. | ||
| 5353 | ;; :custom-reset-saved 'custom-icon-reset-saved) | ||
| 5354 | |||
| 5355 | (defvar custom-icon-extended-menu | ||
| 5356 | (let ((map (make-sparse-keymap))) | ||
| 5357 | (define-key-after map [custom-icon-set] | ||
| 5358 | '(menu-item "Set for Current Session" custom-icon-set | ||
| 5359 | :enable (eq (widget-get custom-actioned-widget :custom-state) | ||
| 5360 | 'modified))) | ||
| 5361 | (when (or custom-file init-file-user) | ||
| 5362 | (define-key-after map [custom-icon-save] | ||
| 5363 | '(menu-item "Save for Future Sessions" custom-icon-save | ||
| 5364 | :enable (memq | ||
| 5365 | (widget-get custom-actioned-widget :custom-state) | ||
| 5366 | '(modified set changed))))) | ||
| 5367 | (define-key-after map [custom-redraw] | ||
| 5368 | '(menu-item "Undo Edits" custom-redraw | ||
| 5369 | :enable (memq | ||
| 5370 | (widget-get custom-actioned-widget :custom-state) | ||
| 5371 | '(modified changed)))) | ||
| 5372 | map) | ||
| 5373 | "A menu for `custom-icon' widgets. | ||
| 5374 | Used in `custom-icon-action' to show a menu to the user.") | ||
| 5357 | 5375 | ||
| 5358 | (defun custom-icon-value-create (widget) | 5376 | (defun custom-icon-value-create (widget) |
| 5359 | "Here is where you edit the icon's specification." | 5377 | "Here is where you edit the icon's specification." |
| @@ -5483,6 +5501,24 @@ The following properties have special meanings for this widget: | |||
| 5483 | (custom-add-parent-links widget)) | 5501 | (custom-add-parent-links widget)) |
| 5484 | (custom-add-see-also widget))))) | 5502 | (custom-add-see-also widget))))) |
| 5485 | 5503 | ||
| 5504 | (defun custom-icon-action (widget &optional event) | ||
| 5505 | "Show the menu for `custom-icon' WIDGET. | ||
| 5506 | Optional EVENT is the location for the menu." | ||
| 5507 | (if (eq (widget-get widget :custom-state) 'hidden) | ||
| 5508 | (custom-toggle-hide widget) | ||
| 5509 | (unless (eq (widget-get widget :custom-state) 'modified) | ||
| 5510 | (custom-icon-state-set widget)) | ||
| 5511 | (custom-redraw-magic widget) | ||
| 5512 | (let* ((completion-ignore-case t) | ||
| 5513 | (custom-actioned-widget widget) | ||
| 5514 | (answer (widget-choose (concat "Operation on " | ||
| 5515 | (custom-unlispify-tag-name | ||
| 5516 | (widget-get widget :value))) | ||
| 5517 | custom-icon-extended-menu | ||
| 5518 | event))) | ||
| 5519 | (when answer | ||
| 5520 | (funcall answer widget))))) | ||
| 5521 | |||
| 5486 | (defun custom-toggle-hide-icon (visibility-widget &rest _ignore) | 5522 | (defun custom-toggle-hide-icon (visibility-widget &rest _ignore) |
| 5487 | "Toggle the visibility of a `custom-icon' parent widget. | 5523 | "Toggle the visibility of a `custom-icon' parent widget. |
| 5488 | By default, this signals an error if the parent has unsaved | 5524 | By default, this signals an error if the parent has unsaved |
| @@ -5519,10 +5555,21 @@ changes." | |||
| 5519 | (user-error "Cannot update hidden icon")) | 5555 | (user-error "Cannot update hidden icon")) |
| 5520 | 5556 | ||
| 5521 | (setq val (custom--icons-widget-value child)) | 5557 | (setq val (custom--icons-widget-value child)) |
| 5522 | (unless (equal val (icon-complete-spec symbol)) | 5558 | ;; FIXME: What was the intention here? |
| 5523 | (custom-variable-backup-value widget)) | 5559 | ;; (unless (equal val (icon-complete-spec symbol)) |
| 5560 | ;; (custom-variable-backup-value widget)) | ||
| 5524 | (custom-push-theme 'theme-icon symbol 'user 'set val) | 5561 | (custom-push-theme 'theme-icon symbol 'user 'set val) |
| 5525 | (custom-redraw-magic widget))) | 5562 | (custom-redraw widget))) |
| 5563 | |||
| 5564 | (defun custom-icon-save (widget) | ||
| 5565 | "Save value of icon edited by widget WIDGET." | ||
| 5566 | (custom-set-icons (cons (widget-value widget) | ||
| 5567 | (list | ||
| 5568 | (custom--icons-widget-value | ||
| 5569 | (car (widget-get widget :children)))))) | ||
| 5570 | (custom-save-all) | ||
| 5571 | (custom-icon-state-set widget) | ||
| 5572 | (custom-redraw-magic widget)) | ||
| 5526 | 5573 | ||
| 5527 | ;;;###autoload | 5574 | ;;;###autoload |
| 5528 | (defun customize-icon (icon) | 5575 | (defun customize-icon (icon) |
diff --git a/lisp/emacs-lisp/icons.el b/lisp/emacs-lisp/icons.el index cb08c1a6b81..9a6d26243c7 100644 --- a/lisp/emacs-lisp/icons.el +++ b/lisp/emacs-lisp/icons.el | |||
| @@ -181,9 +181,9 @@ present if the icon is represented by an image." | |||
| 181 | (let ((parent-keywords (icon-spec-keywords elem)) | 181 | (let ((parent-keywords (icon-spec-keywords elem)) |
| 182 | (current-keywords (icon-spec-keywords current))) | 182 | (current-keywords (icon-spec-keywords current))) |
| 183 | (while parent-keywords | 183 | (while parent-keywords |
| 184 | (unless (plist-get (car parent-keywords) current-keywords) | 184 | (unless (plist-get current-keywords (car parent-keywords)) |
| 185 | (nconc current (take 2 parent-keywords)) | 185 | (nconc current (take 2 parent-keywords))) |
| 186 | (setq parent-keywords (cddr parent-keywords)))))))) | 186 | (setq parent-keywords (cddr parent-keywords))))))) |
| 187 | merged) | 187 | merged) |
| 188 | 188 | ||
| 189 | (cl-defmethod icons--create ((_type (eql 'image)) icon keywords) | 189 | (cl-defmethod icons--create ((_type (eql 'image)) icon keywords) |