[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: changing a variable with a keystroke
From: |
Tassilo Horn |
Subject: |
Re: changing a variable with a keystroke |
Date: |
Thu, 15 Jan 2009 19:51:13 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Joff <jack.joff@gmail.com> writes:
Hi!
>> To fix, you can define your function, then put the function name as
>> the second arg to setkey. But since elisp has a function construct
>> (aka lambda), so you don't need to define it separately.
>> Here's the code:
>> (global-set-key (kbd "C-l C-r")
>> (lambda () (setq dired-listing-switches "-lR"))
>> ) ;; code not tested
>
> This doesn't seem to work: it gives me:
> Wrong type argument: commandp, (lambda nil (setq dired-listing-switches
> "-lR"))
Only commands (functions with `interactive' spec) can be bound to keys,
so simply putting (interactive) afted "lambda ()" should do the trick.
>> Note that what you are doing is strange. Depending what you want to
>> achieve, there are probably better ways.
>>
> What I want to be able to acheive is being able to switch to and from
> dired recursive list 'mode' with a single key combination (rather than
> going through M-x set-variable... etc or C-u s switch. Is there a
> better way to do this?
Dired can do that automatically. See
(info "(emacs)Subdirectories in Dired") <== C-x C-e here!
in the emacs manual.
Bye,
Tassilo
--
It is better to give than to receive. This is especially true of a Chuck
Norris roundhouse kick.