[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Question about quotes on emacs lisp
From: |
Drew Adams |
Subject: |
RE: Question about quotes on emacs lisp |
Date: |
Sat, 16 Sep 2006 17:06:11 -0700 |
Why can't I do something like this:
(global-set-key "\C-x\n" "other-window")
Aren't I still using quotes when calling the function other-window?
Neither "other-window" nor 'other-window calls the function other-window.
The former evaluates to a string; the latter evaluates to the symbol whose
name is other-window. You want the latter here, because you are binding a
key sequence to the command represented by the symbol other-window.
Double quotes (") delimit strings. A single quote (') in front of a Lisp
S-expression (sexp) tells the interpreter to treat the sexp literally, that
is, to return the sexp. The sexp 'other-window is syntactic sugar for (quote
other-window), and quote returns its argument unevaluated. So, the sexp
'other-window returns the sexpr other-window, which is a symbol - it is not
a string.
For this to become more clear and familiar, read up on evaluation, quote,
symbols, and perhaps strings in the Emacs-Lisp manual, and practice
evaluating sexps that include ' and "...".