[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Overriding self-insert-command doesn't work

From: address@hidden
Subject: Overriding self-insert-command doesn't work
Date: 10 Mar 2007 08:56:24 -0800
User-agent: G2/1.0

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)
  (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

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]