From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim Johnson Newsgroups: gmane.emacs.help Subject: Re: Execute a string as a command Date: Fri, 6 Nov 2015 07:17:54 -0900 Organization: AkWebsoft Message-ID: <20151106161754.GJ3301@mail.akwebsoft.com> References: <20151106032357.GF3301@mail.akwebsoft.com> <87611fg2q0.fsf@fastmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1446826701 23620 80.91.229.3 (6 Nov 2015 16:18:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Nov 2015 16:18:21 +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 17:18:12 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 1ZujiM-00066r-MJ for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2015 17:18:10 +0100 Original-Received: from localhost ([::1]:39752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZujiM-0002ZR-9s for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2015 11:18:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZujiA-0002ZI-G1 for help-gnu-emacs@gnu.org; Fri, 06 Nov 2015 11:17:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zuji7-0005xC-2q for help-gnu-emacs@gnu.org; Fri, 06 Nov 2015 11:17:58 -0500 Original-Received: from tjohnson.mtaonline.net ([64.4.232.191]:35598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zuji6-0005wB-MT for help-gnu-emacs@gnu.org; Fri, 06 Nov 2015 11:17:55 -0500 Original-Received: by tj49.com (Postfix, from userid 1000) id E529E20010C; Fri, 6 Nov 2015 07:17:54 -0900 (AKST) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.4.232.191 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:107975 Archived-At: * Joost Kremers [151106 00:57]: > 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. Thanks for the reply : > 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. 1)I'm a bit "mouse averse" - I.E. I prefer tmm-prompt for numerous reasons. 2)The Elisp manual (as far as I have found it) does not give any working examples which have edified me. What has eluded me so far is how to use commands as values in the alist - this is why I introduced the topic of evaluating a string as a command. > 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) > ``` The formatting of this structure above makes total sense, but can it be used for tmm-prompt. > Yeah, ok, so `ispell-change-dictionary` is not a toggle... But you get the > idea. ;-) > > HTH Thanks very much. -- Tim http://www.akwebsoft.com, http://www.tj49.com