summaryrefslogtreecommitdiff
path: root/lisp/cus-edit.el
diff options
context:
space:
mode:
authorDavid Ponce <da_vid@orange.fr>2025-01-09 11:01:40 +0100
committerEli Zaretskii <eliz@gnu.org>2025-01-09 16:33:59 +0200
commit6d02539dd48255e1b53f48dbdc8069b50be63767 (patch)
tree25e9bf502a78ed0946fc0e18ad6c9551baa32e7b /lisp/cus-edit.el
parent81cf42c8af75b9ee2f2cee36254e3286b2077cbc (diff)
downloademacs-6d02539dd48255e1b53f48dbdc8069b50be63767.tar.gz
emacs-6d02539dd48255e1b53f48dbdc8069b50be63767.tar.bz2
emacs-6d02539dd48255e1b53f48dbdc8069b50be63767.zip
Improve UI of customizing icons
* lisp/cus-edit.el (custom-icon--images-sub-type) (custom-icon--emojis-sub-type, custom-icon--symbols-sub-type) (custom-icon--texts-sub-type, custom-icon--type): New defconst's. (custom-icon-value-create): Use them. (Bug#73178)
Diffstat (limited to 'lisp/cus-edit.el')
-rw-r--r--lisp/cus-edit.el55
1 files changed, 48 insertions, 7 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index be08e0d5d46..95dd4c9e354 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -5552,6 +5552,53 @@ its standard value."
"A menu for `custom-icon' widgets.
Used in `custom-icon-action' to show a menu to the user.")
+(defconst custom-icon--images-sub-type
+ '(list :format "%{%t%}:\n%v\n"
+ :tag "Images"
+ (const :tag "" image)
+ (repeat :tag "Values"
+ (string :tag "Image filename"))
+ (plist :tag "Image attributes")))
+
+(defconst custom-icon--emojis-sub-type
+ '(list :format "%{%t%}:\n%v\n"
+ :tag "Colorful Emojis"
+ (const :tag "" emoji)
+ (repeat :tag "Values"
+ (string :tag "Emoji text"))
+ (plist :tag "Emoji text properties")))
+
+(defconst custom-icon--symbols-sub-type
+ '(list :format "%{%t%}:\n%v\n"
+ :tag "Monochrome Symbols"
+ (const :tag "" symbol)
+ (repeat :tag "Values"
+ (string :tag "Symbol text"))
+ (plist :tag "Symbol text properties")))
+
+(defconst custom-icon--texts-sub-type
+ '(list :format "%{%t%}:\n%v\n"
+ :tag "Texts Only"
+ (const :tag "" text)
+ (repeat :tag "Values"
+ (string :tag "Text"))
+ (plist :tag "Text properties")))
+
+(defconst custom-icon--type
+ `(repeat :format ,(concat "%{%t%}"
+ (propertize ":" 'display "")
+ "\n\n%v%i\n")
+ :tag "Icon elements:
+- Only the first occurrence of a same element counts.
+- Missing elements will take their default value.
+- At least one element should be provided with a valid value."
+ (choice :void ,custom-icon--texts-sub-type
+ :extra-offset -3
+ ,custom-icon--images-sub-type
+ ,custom-icon--emojis-sub-type
+ ,custom-icon--symbols-sub-type
+ ,custom-icon--texts-sub-type)))
+
(defun custom-icon-value-create (widget)
"Here is where you edit the icon's specification."
(custom-load-widget widget)
@@ -5562,13 +5609,7 @@ Used in `custom-icon-action' to show a menu to the user.")
(form (widget-get widget :custom-form))
(symbol (widget-get widget :value))
(tag (widget-get widget :tag))
- (type '(repeat
- (list (choice (const :tag "Images" image)
- (const :tag "Colorful Emojis" emoji)
- (const :tag "Monochrome Symbols" symbol)
- (const :tag "Text Only" text))
- (repeat string)
- plist)))
+ (type custom-icon--type)
(prefix (widget-get widget :custom-prefix))
(last (widget-get widget :custom-last))
(style (widget-get widget :custom-style))