emacs-devel
[Top][All Lists]
Advanced

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

Re: invoke a keyboard menu map from lisp?


From: Stefan Reichör
Subject: Re: invoke a keyboard menu map from lisp?
Date: Thu, 27 Aug 2015 08:22:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

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.




reply via email to

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