Emacs widget icons

Emacs has few important widgets built-in. If you are using them, it would be helpful to know that you can customize their icons. You should look for :tag-glyph (buttons), :on-glyph and :off-glyph (radio, checkboxes and visibility) support in the widget. The value for these attributes should be a file name sans extension (xpm, xbm, gif, jpg, or png) located in `widget-image-directory' or otherwise where `find-image' will find it.

You can create an insert button with plus.png image as an icon using following code:

;; Use widget-convert to assign an instance of a widget to a variable
(setq w (widget-convert 'insert-button :tag-glyph "plus"))
(widget-create w)
 
;; Use widget-create to insert the widget into the buffer
(widget-create 'insert-button :tag-glyph "plus")
 
;; Following two lines are necessary to interact with the widget
(use-local-map widget-keymap)
(widget-setup)

Below is a slightly modified version of the example in Emacs online docs.





Comments

Popular posts from this blog

Formula Editor in GNU Emacs

Draw and Scribble Notes in GNU Emacs

GNU Emacs: A configurable browser