[Top][All Lists]

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

Re: is Emacs completely written in lisp

From: Joel J. Adamson
Subject: Re: is Emacs completely written in lisp
Date: Tue, 20 Nov 2007 13:42:01 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

arunmib <address@hidden> writes:

> On Nov 20, 5:04 pm, Marc Tfardy <address@hidden> wrote:
>> arunmib schrieb:
>> > Hi all,
>> >     Is Emacs completely written in Lisp or is written in combination
>> > with some other language. What I am trying to ask is the UI and other
>> > OS dependent stuff (if any, I don't know this thing) is also written
>> > in Lisp or some other language, like C is also used....
>> C + ELisp
>> Marc
> Out of curiosity, can you tell me how? just a general overview or some
> place where I can read, how this is done?

Stallman's article is a good place to hear about the why and how:  My understanding is that the
functions that really need to work fast and often, as well as
the Emacs Lisp interpreter are in C.  Basically the backbone is C and
the Lisp interpreter (a full-on REPL) takes care of the rest.  If you
`M-x apropos' and look up a function name, it will tell you if it's in C
or Lisp, along with a link to the file where you can find the function.

For example `self-insert-command', which is invoked every time I press a
key is in C:
DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, 
       doc: /* Insert the character you type.
Whichever character you type to run this command is inserted.  */)
     Lisp_Object n;

  /* Barf if the key that invoked this was not a character.  */
  if (!CHARACTERP (last_command_char))
    bitch_at_user ();
    int character = translate_char (Vtranslation_table_for_input,
                                    XINT (last_command_char));
    if (XINT (n) >= 2 && NILP (current_buffer->overwrite_mode))
        int modified_char = character;
        /* Add the offset to the character, for Finsert_char.
           We pass internal_self_insert the unmodified character
           because it itself does this offsetting.  */
        if (! NILP (current_buffer->enable_multibyte_characters))
          modified_char = unibyte_char_to_multibyte (modified_char);

        XSETFASTINT (n, XFASTINT (n) - 2);
        /* The first one might want to expand an abbrev.  */
        internal_self_insert (character, 1);
        /* The bulk of the copies of this char can be inserted simply.
           We don't have to handle a user-specified face specially
           because it will get inherited from the first char inserted.  */
        Finsert_char (make_number (modified_char), n, Qt);
        /* The last one might want to auto-fill.  */
        internal_self_insert (character, 0);
      while (XINT (n) > 0)
          /* Ok since old and new vals both nonneg */
          XSETFASTINT (n, XFASTINT (n) - 1);
          internal_self_insert (character, XFASTINT (n) != 0);

  return Qnil;
(a function called bitch_at_user() --- that's a good one)
I learn a lot by using apropos.
Joel J. Adamson
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

reply via email to

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