emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/frog-menu 1bcc95f 01/12: Add menubar example


From: Clemens Radermacher
Subject: [elpa] externals/frog-menu 1bcc95f 01/12: Add menubar example
Date: Thu, 21 May 2020 11:15:11 -0400 (EDT)

branch: externals/frog-menu
commit 1bcc95fbeb5a7bba498ec3d0689656a1e5483d0b
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>

    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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]