unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Question about quotes on emacs lisp
@ 2006-09-16 23:04 grocery_stocker
  2006-09-17  0:06 ` Drew Adams
  2006-09-17  1:38 ` Pascal Bourguignon
  0 siblings, 2 replies; 3+ messages in thread
From: grocery_stocker @ 2006-09-16 23:04 UTC (permalink / raw)


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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Question about quotes on emacs lisp
  2006-09-16 23:04 Question about quotes on emacs lisp grocery_stocker
@ 2006-09-17  0:06 ` Drew Adams
  2006-09-17  1:38 ` Pascal Bourguignon
  1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2006-09-17  0:06 UTC (permalink / raw)


    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 "...".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about quotes on emacs lisp
  2006-09-16 23:04 Question about quotes on emacs lisp grocery_stocker
  2006-09-17  0:06 ` Drew Adams
@ 2006-09-17  1:38 ` Pascal Bourguignon
  1 sibling, 0 replies; 3+ messages in thread
From: Pascal Bourguignon @ 2006-09-17  1:38 UTC (permalink / raw)


"grocery_stocker" <cdalten@gmail.com> writes:

> 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?

LISP = List & Intelligent Symbolic Programming language.

There are lists and symbols in lisp.

Symbols are not strings.  (But the name of a symbol is a string).


Quoting of symbols becomes necessary when you want to consider the
symbol as data from code.  In code, symbols are normally interpreted
as function or variable identifiers.  If you want to have a symbol
interpreted as literal data, you must quote it with the special
operator quote:

         (quote example)   --> example


(global-set-key "\C-x\n" (quote other-window))


Now, some consider that writting (quote ...) is fastidiuous, and
prefer to use some shorter syntax.  You can use a single prefix quote
instead:

          'example  == (quote example)

(global-set-key "\C-x\n" 'other-window)



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"I have challenged the entire quality assurance team to a Bat-Leth
contest.  They will not concern us again."

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-17  1:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-16 23:04 Question about quotes on emacs lisp grocery_stocker
2006-09-17  0:06 ` Drew Adams
2006-09-17  1:38 ` Pascal Bourguignon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).