From: Mauro Aranda <maurooaranda@gmail.com>
To: 66947@debbugs.gnu.org
Subject: bug#66947: 30.0.50; Implement missing functions for custom-icon widget
Date: Sun, 5 Nov 2023 07:26:19 -0300 [thread overview]
Message-ID: <b2142b70-aa71-4150-8c79-e684dd4a4fa1@gmail.com> (raw)
In-Reply-To: <dd209b3d-b070-433d-b267-1652b91010aa@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 41 bytes --]
tags 66947 patch
quit
Patch attached.
[-- Attachment #2: 0001-Implement-missing-functions-for-custom-icon-widget.patch --]
[-- Type: text/x-patch, Size: 3904 bytes --]
From ffb296a5c45f5173d7edff4dbf6b29a38a92dac2 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Sun, 5 Nov 2023 07:23:55 -0300
Subject: [PATCH] Implement missing functions for custom-icon widget
* lisp/cus-edit.el (custom-icon-reset-saved, custom-icon-mark-to-save)
(custom-icon-state-set-and-redraw, custom-icon-reset-standard)
(custom-icon-mark-to-reset-standard): New functions.
(custom-icon, custom-icon-extended-menu): Register and add them to the
menu. (Bug#66947)
---
lisp/cus-edit.el | 58 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 3 deletions(-)
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 6442ffeac24..4b8de6b9468 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -5389,9 +5389,49 @@ 'custom-icon
:hidden-states '(standard)
:action #'custom-icon-action
:custom-set #'custom-icon-set
- :custom-reset-current #'custom-redraw)
- ;; Not implemented yet.
- ;; :custom-reset-saved 'custom-icon-reset-saved)
+ :custom-mark-to-save #'custom-icon-mark-to-save
+ :custom-reset-current #'custom-redraw
+ :custom-reset-saved #'custom-icon-reset-saved
+ :custom-state-set-and-redraw #'custom-icon-state-set-and-redraw
+ :custom-reset-standard #'custom-icon-reset-standard
+ :custom-mark-to-reset-standard #'custom-icon-mark-to-reset-standard)
+
+(defun custom-icon-mark-to-save (widget)
+ "Mark user customization for icon edited by WIDGET to be saved later."
+ (let* ((icon (widget-value widget))
+ (value (custom--icons-widget-value
+ (car (widget-get widget :children)))))
+ (custom-push-theme 'theme-icon icon 'user 'set value)))
+
+(defun custom-icon-reset-saved (widget)
+ "Restore icon customized by WIDGET to the icon's default attributes.
+
+If there's a theme value for the icon, resets to that. Otherwise, resets to
+its standard value."
+ (let* ((icon (widget-value widget)))
+ (custom-push-theme 'theme-icon icon 'user 'reset)
+ (custom-icon-state-set widget)
+ (custom-redraw widget)))
+
+(defun custom-icon-state-set-and-redraw (widget)
+ "Set state of icon widget WIDGET and redraw it with up-to-date settings."
+ (custom-icon-state-set widget)
+ (custom-redraw-magic widget))
+
+(defun custom-icon-reset-standard (widget)
+ "Reset icon edited by WIDGET to its standard value."
+ (let* ((icon (widget-value widget))
+ (themes (get icon 'theme-icon)))
+ (dolist (theme themes)
+ (custom-push-theme 'theme-icon icon (car theme) 'reset))
+ (custom-save-all))
+ (widget-put widget :custom-state 'unknown)
+ (custom-redraw widget))
+
+(defun custom-icon-mark-to-reset-standard (widget)
+ "Reset icon edited by WIDGET to its standard value."
+ ;; Don't mark for now, there aren't that many icons.
+ (custom-icon-reset-standard widget))
(defvar custom-icon-extended-menu
(let ((map (make-sparse-keymap)))
@@ -5410,6 +5450,18 @@ custom-icon-extended-menu
:enable (memq
(widget-get custom-actioned-widget :custom-state)
'(modified changed))))
+ (define-key-after map [custom-icon-reset-saved]
+ '(menu-item "Revert This Session's Customization"
+ custom-icon-reset-saved
+ :enable (memq
+ (widget-get custom-actioned-widget :custom-state)
+ '(modified set changed rogue))))
+ (when (or custom-file init-file-user)
+ (define-key-after map [custom-icon-reset-standard]
+ '(menu-item "Erase Customization" custom-icon-reset-standard
+ :enable (memq
+ (widget-get custom-actioned-widget :custom-state)
+ '(modified set changed saved rogue)))))
map)
"A menu for `custom-icon' widgets.
Used in `custom-icon-action' to show a menu to the user.")
--
2.34.1
next prev parent reply other threads:[~2023-11-05 10:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-05 10:20 bug#66947: 30.0.50; Implement missing functions for custom-icon widget Mauro Aranda
2023-11-05 10:26 ` Mauro Aranda [this message]
2024-01-10 17:55 ` Stefan Kangas
2024-01-10 18:20 ` Eli Zaretskii
2024-01-10 18:27 ` Stefan Kangas
2023-11-05 14:24 ` Stefan Kangas
2023-11-05 22:38 ` Mauro Aranda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b2142b70-aa71-4150-8c79-e684dd4a4fa1@gmail.com \
--to=maurooaranda@gmail.com \
--cc=66947@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).