Ah! I didn't think to check the git manual instead of the online one. Good
to know about.

Doing it like you suggested works.


On Sun, Apr 20, 2014 at 8:41 PM, Eric Abrahamsen <e...@ericabrahamsen.net>wrote:

> "J. David Smith" <emall...@archlinux.us> writes:
>
> > Hullo,
> >
> > I'm sure most of you are aware of the fact that (define-key ...)
> > cannot directly take a function as its third parameter. Instead, it
> > is given a string containing the command name. For example, this:
> >
> > (define-key *root-map* (kbd "f") "firefox")
> >
> > versus this:
> >
> > (define-key *root-map* (kbd "f") #'firefox)
> >
> > This is doubly confusing because (defcommand ...) wraps (defun ...),
> > so (defcommand firefox (&optional (new-window nil)) () ....) produces
> > a function (firefox ...). In order to make two keys (f and C-f), I
> > can't simply do:
> >
> > (define-key *root-map* (kbd "f") #'firefox)
> > (define-key *root-map* (kbd "C-f") (lambda () (firefox t)))
> >
> > I have to define two commands:
> >
> > (defcommand firefox ...) and (defcommand new-firefox ...).
> >
> > as well as two keys.
> >
> > So I suppose my question can be summed up like this:
> >
> > What is the reasoning for using strings to reference functions like
> > this?
> >
> >   -- J David Smith
>
> I can't really explain the reasoning, not having been in on it, but I do
> know the system was put in place as a kind of echo of Emacs' distinction
> between functions and interactive commands.
>
> Luckily, your problem is fairly easy to solve -- you can pass command
> arguments along with the command name as part of the same string. So
> try:
>
> (defcommand ff (&optional (new-window nil)) (:y-or-n)
>             (if new-window
>               (message "new window!")
>               (message "no new window!")))
>
> (define-key *root-map* (kbd "z") "ff")
> (define-key *root-map* (kbd "Z") "ff t")
>
> There's no "boolean" type, but any string will do.
>
> If you're using StumpWM from git, update to something recent and check
> out the manual -- there's a new section on this.
>
> Hope that helps,
> Eric
>
>
> _______________________________________________
> Stumpwm-devel mailing list
> Stumpwm-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
>
_______________________________________________
Stumpwm-devel mailing list
Stumpwm-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel

Reply via email to