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

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

Re: Emacs internals + lisp guru question


From: Nix
Subject: Re: Emacs internals + lisp guru question
Date: 29 Sep 2002 16:33:19 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Informed Management)

[followups drastically trimmed]

On 28 Sep 2002, gnuist stipulated:
> There are some functions that take a list as argument.
> Text can be read from the buffer as a string.
> There are some functions that take a "symbol" as an argument.
> A string can be converted to a symbol.

Yes, with `intern' or `make-symbol' (which do *very* different things).

> However, when symbol is provided to the function by converting a string
>  it is not working.
> 
> For example:
> 
> (describe-function quoted-SYMBOL) works
> (make-symbol "describe-function") works

The symbols these functions yield are *different*: e.g.

(eq 'describe-function (make-symbol "describe-function"))
  ==> nil

Think of a symbol as a key in a lookup table mapping symbols to triples
of (function, value, property). (Lisp calls these tables `obarrays').

The Lisp reader (the thing that takes 'describe-function and transforms
it to a symbol) looks up its symbols in the obarray named, with great
originality, `obarray'. This is the one where all the Lisp symbols are
defined. There are other obarrays: abbrev puts its abbrevs in an
obarray, and the BBDB uses another one to store its address
book.

Obviously you don't want these entries to collide with Lisp symbols; so
they use different obarrays (which are normally *themselves* stored as
Lisp variables).

`make-symbol' makes a symbol that is in *no obarray at all*; so
regardless of its name no symbol given to the Lisp reader will be equal
to it, have the same value as it, &c, &c.

If you want to look up a symbol with a name given as a string in the
Lisp obarray, you need to use `intern'; this'll create the symbol if
it doesn't exist. If you want to avoid creating the symbol, you can
use `intern-soft', which returns nil if the symbol is nonexistent.

See 
<http://www.gnu.org/manual/elisp-manual-21-2.8/html_chapter/elisp_8.html#SEC106>.

> How can we get the code of describe-function?

(symbol-function 'describe-function), but it's not very useful; the
function is probably byte-compiled, so you'll get code in the bytecode
interpreter's language, not in Lisp.

Alternatively, look in `help.el' (I think it's there in GNU Emacs too;
I'm looking at XEmacs here).

> What is the meaning of the gibberish from
> (insert (format "%s" (symbol-function 'describe-function) ))

I see no gibberish there. Which bit do you find gibberishy?

> What is out there to learn more about emacs/emacs_lisp and become more
> sophisticated?

The Emacs Lisp Intro is very good:
<http://www.gnu.org/manual/emacs-lisp-intro/emacs-lisp-intro.html>.

Once you've read that, read the Lisp Reference for your flavour of
(X)Emacs and read lots of the lisp sources that come with the editor and
you should be enlightened.

-- 
`Let's have a round of applause for those daring young men
 and their flying spellcheckers.' --- Meg Worley


reply via email to

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