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