home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / emacs / help / 3528 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.8 KB  |  63 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!cis.ohio-state.edu!lucid.com!jla
  3. From: jla@lucid.com (Joseph Arceneaux)
  4. Subject: elisp: interactive calling of C subroutines
  5. Message-ID: <9207281746.AA01987@hugo.lucid>
  6. Sender: daemon@cis.ohio-state.edu
  7. Reply-To: jla@ai.mit.edu
  8. Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu
  9. References: <ACEVEDO.92Jul28095546@hippocrene.mit.edu>
  10. Date: Tue, 28 Jul 1992 17:46:44 GMT
  11. Lines: 50
  12.  
  13.    Date: 28 Jul 92 13:54:30 GMT
  14.    Organization: Massachusetts Institute of Technology
  15.    From: acevedo@mit.edu (Raul Acevedo)
  16.    Sender: help-gnu-emacs-request@prep.ai.mit.edu
  17.  
  18.  
  19.      Does elisp treat `subrp' functions differently than "regular", elisp
  20.    defined functions in terms of how they are invoked interactively?
  21.  
  22.      What I mean is this: when you say (foo 1 2 3), elisp sees that it's a
  23.    non-empty list; it thus examines the function cell of the first symbol
  24.    for a function to execute.  If that is a function or lambda or some such
  25.    object, it calls it; if it's another symbol, it examines that symbol's
  26.    function cell; and so on.
  27.  
  28.      So, if I do (fset 'foo 'bar), and then do (foo 1 2 3), what will
  29.    really happen is (bar 1 2 3).
  30.  
  31.      However, this doesn't quite work for C-written subroutines, when they
  32.    are bound to a key and you invoke them interactively by typing that key.
  33.    E.g.:
  34.  
  35.        (setq foo (symbol-function 'forward-char))  ; so you can recover it
  36.        (fset 'forward-char 'backward-char)
  37.  
  38.    This will not work.  Sort of.  See what happens to C-f; it doesn't
  39.    change.  However, see how it behaves at the end of the buffer.  Only
  40.    then does it actually do `backward-char'.  But if you evaluate
  41.    (forward-char) or type M-x forward-char, you *will* actually call
  42.    `backward-char'. 
  43.  
  44.      Anyone know what's going on?  I know that this sort of redefining is
  45.    confusing because if another C subroutine calls `forward-char', chances
  46.    are it will use the original C subroutine, not what you've put in the
  47.    function cell.  But if I just type C-f, according to the elisp manual
  48.    the command loop *should* simply use `command-execute' to call
  49.    `forward-char'; this does the right thing.  My guess is that the command
  50.    loop does some sort of optimization, like perhaps when it looks up the
  51.    symbol it automagically knows `forward-char' is a C subroutine, and thus
  52.    doesn't bother looking in the function cell.  Or, the fact that all the
  53.    key lookup and command execution is done in C code nevertheless affects
  54.    things, even if it does use `command-execute'.  Any ideas?
  55.    --
  56.    Raul J. Acevedo
  57.    acevedo@MIT.EDU
  58.  
  59.    Life is a mystery and it's an unsolvable one.  You simply live it through, and,
  60.    as you draw your last breath you say "What was that all about?"
  61.            --- Marlon Brando
  62.  
  63.