From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: Execute a string as a command Date: 6 Nov 2015 09:43:03 GMT Message-ID: References: <20151106032357.GF3301@mail.akwebsoft.com> <87611fg2q0.fsf@fastmail.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1446803127 19788 80.91.229.3 (6 Nov 2015 09:45:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Nov 2015 09:45:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 06 10:45:25 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZudaD-0001CE-J1 for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2015 10:45:21 +0100 Original-Received: from localhost ([::1]:37632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZudaC-0005K6-MA for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2015 04:45:20 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 56 Original-X-Trace: individual.net LafJEc6IVqAbNv+t4LM3wglTLs2KyAJAQm6NvYLyxYwTB/un2F Cancel-Lock: sha1:U4ApewZEsI69Rtc6CkVtuL0Km/A= Mail-Copies-To: nobody X-Editor: Emacs of course! User-Agent: slrn/1.0.1 (Linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:215682 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107968 Archived-At: Tim Johnson wrote: > Here is an example of what could be a working function 'interning' > a string : > (defun tj-toggle-funcs () > "Toggle functions" > (interactive) > (let ((menu > '("" ("" ("Transient Mark Mode" . "transient-mark-mode")) > ("Truncate Lines" . "toggle-truncate-lines") > ("Show Tabs" . "toggle-tabs-font-lock")))) > (choice )) > (setq choice (tmm-prompt menu)) > (if choice > (call-interactively (intern choice))))) > > My preference *would* be that a command object be read from the > 'menu structure, but wasn't able to make it work. > So my next step is to figure out how to place a command object as a > value instead of a string... and then evaluate it properly. Check out the Elisp manual on pop-up menus, which use the function x-popup-menu, which takes the same kind of menu structure as tmm-prompt. C-h i Elisp RET Pop-up menus RET An alternative to what you're trying to do would be to use the hydra package: https://github.com/abo-abo/hydra Here is my toggle hydra, for example: ``` (defhydra jk-hydra-toggle (:color blue) "Change" ("d" toggle-debug-on-error "Debug") ("w" writeroom-mode "Writeroom") ("i" ispell-change-dictionary "Change Ispell Dictionary") ("f" toggle-fill-unfill "Fill") ("F" follow-mode "Follow mode") ("t" orgtbl-mode "OrgTbl mode") ("y" typo-mode "Typo mode") ("q" nil "Cancel")) (bind-key "s-r" #'jk-hydra-toggle/body) ``` Yeah, ok, so `ispell-change-dictionary` is not a toggle... But you get the idea. ;-) HTH -- Joost Kremers joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9)