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: Thu, 5 Nov 2015 20:52:26 -0900 Organization: AkWebsoft Message-ID: <20151106055226.GI3301@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 1446789170 1572 80.91.229.3 (6 Nov 2015 05:52:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Nov 2015 05:52:50 +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 06:52:42 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 1ZuZx3-0005Td-Eq for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2015 06:52:41 +0100 Original-Received: from localhost ([::1]:36758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuZx2-0004If-Ql for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2015 00:52:40 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuZwr-0004IN-Mx for help-gnu-emacs@gnu.org; Fri, 06 Nov 2015 00:52:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuZwo-00029Q-G7 for help-gnu-emacs@gnu.org; Fri, 06 Nov 2015 00:52:29 -0500 Original-Received: from tjohnson.mtaonline.net ([64.4.232.191]:34993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuZwo-00029K-7o for help-gnu-emacs@gnu.org; Fri, 06 Nov 2015 00:52:26 -0500 Original-Received: by tj49.com (Postfix, from userid 1000) id 9B55F200122; Thu, 5 Nov 2015 20:52:26 -0900 (AKST) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <87611fg2q0.fsf@fastmail.com> 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:107967 Archived-At: * Random832 [151105 19:52]: > Tim Johnson writes: > > > Example : A string has the value of : > > "toggle-truncate-lines" > > > > (setq string-wants-to-be-a-command "toggle-truncate-lines") > > > > How may I convert 'string-wants-to-be-a-command to a command: > > I.E. => (toggle-truncate-lines) to be used programmatically? > > > > thanks <...> > But why are you storing a string instead of the command object > (symbol/function/lambda) anyway? Because I'm a total noob when I comes to using menu objects as per tmm-prompt (my preference) and x-popup-menu, and I have had problems finding instructions for my needs as illustrated below. > And then you can call it with funcall or call-interactively. > > funcall requires you to specify the arguments, so only commands > that don't require an argument will work. To read the arguments > from the keyboard instead, use call-interactively. 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, late here, my response would be in 9-10 hours.. -- Tim http://www.akwebsoft.com, http://www.tj49.com