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

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