From: "Stefan Reichör" <stefan@xsteve.at>
To: emacs-devel@gnu.org
Subject: Re: invoke a keyboard menu map from lisp?
Date: Thu, 27 Aug 2015 08:22:18 +0200 [thread overview]
Message-ID: <87twrlp7xh.fsf@xsteve.at> (raw)
In-Reply-To: 86egipk9tu.fsf@stephe-leake.org
Hello Stephen,
> I'm trying to build a keyboard menu keymap on the fly, and then invoke
> it. I've gotten this far:
>
> (defun dvc-offer-choices (comment choices)
> "Present user with a choice of actions, labeled by COMMENT. CHOICES is a list of pairs
> containing (function description)."
> ;; Build a keyboard menu keymap
> (let ((i 0)
> (map (make-sparse-keymap "actions"))
> choice)
> (unless (< (length choices) 10)
> (error "‘dvc-offer-choices’ only supports up to 10 choices"))
>
> (while choices
> (setq choice (pop choices))
> (define-key map (int-to-string i)
> (list menu-item
> (format "%d) %s" i (cadr choice))
> (car choice))))
> ;; FIXME: invoke the map
> ))
>
> But I can't find the function that executes the keymap.
>
> Can anyone help?
It sounds similar to my quick-task.el library:
http://xsteve.at/prg/emacs/quick-task.el
Using it you can define actions that are shown in a menu like this:
;; (quick-task-define-menu my-quick-task-menu
;; '(("Build"
;; ["software" my-quick-task-build1]
;; ["1: scons proj1" my-quick-task-scons-proj1]
;; )
;; ("other"
;; ["fun" my-quick-task-fun]
;; )
;; ["ediff proj1" my-quick-task-ediff-proj1]
;; ["9: another fun" my-quick-task-fun]
;; [view "*s:*/dev/ttyS0"] ;; switch to an already open serial terminal buffer
;; ("find-file"
;; [open "*e:*~/.emacs"]
;; [open "*q:*.quick-task.el*/home/stefan/site-lisp/xsteve/.quick-task.el"]
;; )
;; ))
Internally I use tmm-prompt to display the candidates.
Maybe this is useful for you.
Stefan.
next prev parent reply other threads:[~2015-08-27 6:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-26 21:40 invoke a keyboard menu map from lisp? Stephen Leake
2015-08-27 2:21 ` Alexis
2015-08-27 3:18 ` Stephen Leake
2015-08-27 2:30 ` Stephen Leake
2015-08-27 2:46 ` Eli Zaretskii
2015-08-27 3:16 ` Stephen Leake
2015-08-27 6:22 ` Stefan Reichör [this message]
2015-08-27 17:00 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87twrlp7xh.fsf@xsteve.at \
--to=stefan@xsteve.at \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.