Multi-select Tree widget in GNU Emacs

Here's an example of multi-select tree widget in GNU Emacs. It is cobbled up from visibility and option widgets. If you want different icons, see.


(widget-create 'tree
           :name "Tree" :checkbox t
           '(item "One") '(item "Two"))
 
;; Uncomment if you don't need images
;; (setq widget-image-enable nil)
 
;; Following two lines are necessary to interact with the widget
(use-local-map widget-keymap)
(widget-setup)
 
;; This is a list of values of effectively selected leaf nodes.
(widget-tree-flat-value widget)

;; Create tree widget from a list of values
(widget-create (widget-tree-from-list '("One" "Two") "Tree"))

 

For placement, you can use :indent property on parent. For indentation of children, either use :offset on parent or :extra-offset on child.

Code: https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/wid-edit.el


 

 


 

 

 

Comments

Popular posts from this blog

GNU Emacs as a Comic Book Reader

Data Visualization with GNU Emacs

Tinylisp and Multi-threaded Emacs