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: Fri, 6 Nov 2015 07:17:54 -0900	[thread overview]
Message-ID: <20151106161754.GJ3301@mail.akwebsoft.com> (raw)
In-Reply-To: <da3b17FjcbrU1@mid.individual.net>

* Joost Kremers <joost.m.kremers@gmail.com> [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



  reply	other threads:[~2015-11-06 16:17 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
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 [this message]
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=20151106161754.GJ3301@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.