unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Overriding self-insert-command doesn't work
@ 2007-03-10 16:56 spamfilteraccount
  2007-03-12 17:23 ` Robert Thorpe
  0 siblings, 1 reply; 7+ messages in thread
From: spamfilteraccount @ 2007-03-10 16:56 UTC (permalink / raw)
  To: help-gnu-emacs

I'd like to override self-insert-command in a way that I replace the
actual function belonging to the symbol `self-insert-command'.

In the code below I do that. I store the old function definition,
replace it with my own definition and call the original definition
from my own function:


(defvar oldfunc (symbol-function 'self-insert-command))

(defun my-self-insert (n)
  "doc"
  (interactive "p")
  (funcall oldfunc n)
  (message "hello"))

(fset 'self-insert-command 'my-self-insert)


This solution doesn't work because it seems to affect only self-insert-
command function calls (hello is printed when I press enter which
presumably calls self-insert-command), but it's not printed when I
press any other self insert key (like "a"). Curiously, if I press "C-h
k a" then it says that "a" invokes my function, but it doesn't. Why is
that?

I tested it with Gnu Emacs 21.

I know about advising, so please don't recommend other ways to
accomplish this. I'd like to know why this specific solution doesn't
work.

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-03-14 14:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-10 16:56 Overriding self-insert-command doesn't work spamfilteraccount
2007-03-12 17:23 ` Robert Thorpe
2007-03-12 18:30   ` spamfilteraccount
2007-03-12 19:30     ` David Hansen
2007-03-13  2:04       ` Drew Adams
2007-03-13  1:25     ` Barry Margolin
2007-03-14 14:17     ` Robert Thorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).