all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Johnson <tim@akwebsoft.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Execute a string as a command
Date: Sat, 7 Nov 2015 10:36:18 -0900	[thread overview]
Message-ID: <20151107193618.GM3301@mail.akwebsoft.com> (raw)
In-Reply-To: <barmar-0B8F90.13321207112015@88-209-239-213.giganet.hu>

* Barry Margolin <barmar@alum.mit.edu> [151107 09:44]:
> In article <mailman.1860.1446859974.7904.help-gnu-emacs@gnu.org>,
>  Tim Johnson <tim@akwebsoft.com> wrote:
> 
> > * Emanuel Berg <embe8573@student.uu.se> [151106 12:47]:
> > > Tim Johnson <tim@akwebsoft.com> writes:
> > > 
> > > > I can't get to that phase for another day or two..
> > > > thanks, Emanuel.
> > > 
> > > No, there are much better things for you to do than to
> > > digest that code. For example, ask yourself why you
> > > want to execute strings as commands, and if there is
> > > a better way still.
> > > 
> > > That code of mine is more like a demo to show of
> > > skills and attract ohs and ahs. It is not really
> > > helpful (tho sometimes I use it so it *does* work).
> > 
> >   By this time, you've probably read from the continuation of this
> >   thread that I had problems with setting up the menu structure so
> >   that command objects could be read from it. Thus I used a string
> >   representation to see if that could be evaluated. 
> 
> The usual way to implement things like this is with an association list.
> The key is the string that's displayed in the menu, and the value is a 
> symbol that names a function or a lambda expression.

  Absolutely. This is what I was finally able to make work:
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (defun tj-toggle-funcs ()
  "Toggle functions"
  (interactive)
  (let ((menu
	 '("" ("" ("1)Transient Mark Mode" . (transient-mark-mode))
	       ("2)Truncate Lines" . (toggle-truncate-lines))
	       ("3)Show Tabs" .  (toggle-show-tabs-show-ws)))
	(choice))
    (setq choice (tmm-prompt menu))
    (if choice
	  (eval choice))))
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Any creative or instructive comments are more than welcome.

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



  reply	other threads:[~2015-11-07 19:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-06  3:23 Execute a string as a command Tim Johnson
2015-11-06  3:53 ` Emanuel Berg
2015-11-06  4:06   ` Tim Johnson
2015-11-06 21:47     ` Emanuel Berg
2015-11-07  1:32       ` Tim Johnson
2015-11-07  3:57         ` Emanuel Berg
     [not found]       ` <mailman.1860.1446859974.7904.help-gnu-emacs@gnu.org>
2015-11-07 18:32         ` Barry Margolin
2015-11-07 19:36           ` Tim Johnson [this message]
2015-11-06  4:40 ` Random832
2015-11-06  5:52   ` Tim Johnson
     [not found]   ` <mailman.1818.1446789151.7904.help-gnu-emacs@gnu.org>
2015-11-06  9:43     ` Joost Kremers
2015-11-06 16:17       ` Tim Johnson
2015-11-06 16:49         ` Tim Johnson
     [not found] <mailman.1811.1446780244.7904.help-gnu-emacs@gnu.org>
2015-11-06  3:36 ` Barry Margolin
2015-11-06  3:59   ` Tim Johnson
2015-11-06  3:59   ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151107193618.GM3301@mail.akwebsoft.com \
    --to=tim@akwebsoft.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.