I'm trying to make Workgroups2 more convenient by displaying a list of workgroups in the mini-buffer on pressing the prefix key (C-c z), e.g.:
This makes it convenient to use the index 0-9 to switch workgroups:
(defvar wg-prefixed-map
(wg-fill-keymap
(make-sparse-keymap)
;; workgroup switching
(kbd "C-j") 'wg-switch-to-workgroup-at-index
(kbd "j") 'wg-switch-to-workgroup-at-index
(kbd "0") 'wg-switch-to-workgroup-at-index-0
(kbd "1") 'wg-switch-to-workgroup-at-index-1
(kbd "2") 'wg-switch-to-workgroup-at-index-2
(kbd "3") 'wg-switch-to-workgroup-at-index-3
(kbd "4") 'wg-switch-to-workgroup-at-index-4
(kbd "5") 'wg-switch-to-workgroup-at-index-5
(kbd "6") 'wg-switch-to-workgroup-at-index-6
(kbd "7") 'wg-switch-to-workgroup-at-index-7
(kbd "8") 'wg-switch-to-workgroup-at-index-8
(kbd "9") 'wg-switch-to-workgroup-at-index-9
)
"The keymap that sits on `wg-prefix-key'.")
(defun wg-fill-keymap (keymap &rest binds)
"Return KEYMAP after defining in it all keybindings in BINDS."
(while binds
(define-key keymap (car binds) (cadr binds))
(setq binds (cddr binds)))
keymap)
The list can be generated with:
(wg-fontified-message
(wg-workgroup-list-display))
Question:
Given C-c z as the prefix key for Workgroups2, is it possible to bind it to
(wg-fontified-message
(wg-workgroup-list-display))
so that it displays the list of workgroups in the mini-buffer? C-c z should still be the prefix after the binding.
Note:
This question is similar to Can the prefix of a key-sequence have an effect?. The comments suggest set-transient-map
or keymapp
. If either of these is useful, please kindly show how the above code can be modified to implement the function. Thank you.