[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Execute a string as a command
From: |
Tim Johnson |
Subject: |
Re: Execute a string as a command |
Date: |
Thu, 5 Nov 2015 20:52:26 -0900 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
* Random832 <random832@fastmail.com> [151105 19:52]:
> Tim Johnson <tim@akwebsoft.com> 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
Re: Execute a string as a command, Random832, 2015/11/05
- Re: Execute a string as a command,
Tim Johnson <=
- Message not available