branch: externals/frog-menu commit 1bcc95fbeb5a7bba498ec3d0689656a1e5483d0b Author: Clemens Radermacher <clem...@posteo.net> Commit: Clemens Radermacher <clem...@posteo.net>
Add menubar example --- README.org | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.org b/README.org index e8fc72f..a406b13 100644 --- a/README.org +++ b/README.org @@ -74,3 +74,32 @@ of (command . word) to be used by `flyspell-do-correct'." Afterwards calling =M-x flyspell-correct-wrapper= will prompt you with a =frog-menu=. +And here is yet another example I use to navigate the menubar: + +#+begin_src elisp +(defun frog-tmm () + "Adapted from `counsel-tmm'." + (interactive) + (require 'tmm) + (run-hooks 'menu-bar-update-hook) + (setq tmm-table-undef nil) + (frog-tmm-prompt (tmm-get-keybind [menu-bar]))) + +(defun frog-tmm-prompt (menu) + "Adapted from `counsel-tmm-prompt'." + (let (out + choice + chosen-string) + (setq tmm-km-list nil) + (map-keymap (lambda (k v) (tmm-get-keymap (cons k v))) menu) + (setq tmm-km-list (nreverse tmm-km-list)) + (setq out (frog-menu-read "Menu: " (mapcar #'car tmm-km-list))) + (setq choice (cdr (assoc out tmm-km-list))) + (setq chosen-string (car choice)) + (setq choice (cdr choice)) + (cond ((keymapp choice) + (frog-tmm-prompt choice)) + ((and choice chosen-string) + (setq last-command-event chosen-string) + (call-interactively choice))))) +#+end_src