help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing a variable with a keystroke


From: Juanma Barranquero
Subject: Re: changing a variable with a keystroke
Date: Wed, 14 Jan 2009 13:14:20 +0100

On Wed, Jan 14, 2009 at 12:32, Joff <jack.joff@gmail.com> wrote:

> (defun set_recursive_dired () "Set dired mode to recursive view"
>   (interactive "p")
>   (setq dired-listing-switches "-lR"))
>
> (global-set-key (kbd "C-l") nil)
> (global-set-key (kbd "C-l C-r") 'set_recursive_dired)
>
> because I thought setq might not be a command (?)

`setq' is an elisp function (more properly, a "special form"; see the
Emacs Lisp Intro), but it is not an interactive command.  Functions
bound to keys must be interactive commands.

> which got me:
>
> call-interactively: Wrong number of arguments: (lambda nil "Set dired mode
> to recursive view" (interactive "p") (setq dired-listing-switches "-lR")), 1

You are using (interactive "p"), which says that the function has an
argument, but it has none. If you use just (interactive) it will work.
See the documentation for function `interactive'.

However, it's a bit weird that you need a keybinding just to set
switches for dired. Doesn't it work if you just add

  (setq dired-listing-switches "-lR")

to your .emacs file? Unless you don't always want these switches, of course.

    Juanma




reply via email to

[Prev in Thread] Current Thread [Next in Thread]