home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!ucbvax!bloom-beacon!bloom-picayune.mit.edu!mit.edu!acevedo
- From: acevedo@mit.edu (Raul Acevedo)
- Newsgroups: gnu.emacs.help
- Subject: elisp: interactive calling of C subroutines
- Message-ID: <ACEVEDO.92Jul28095546@hippocrene.mit.edu>
- Date: 28 Jul 92 13:54:30 GMT
- Sender: news@athena.mit.edu (News system)
- Distribution: gnu
- Organization: Massachusetts Institute of Technology
- Lines: 44
- Nntp-Posting-Host: hippocrene.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
-