help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Overriding self-insert-command doesn't work


From: Robert Thorpe
Subject: Re: Overriding self-insert-command doesn't work
Date: 12 Mar 2007 10:23:25 -0700
User-agent: G2/1.0

On Mar 10, 4:56 pm, "address@hidden"
<address@hidden> wrote:
> 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.

The command "self-insert-command" is inbuilt to Emacs.  It is part of
the static binary executable and is called directly by other parts of
that executable.  Changing it cannot change this version.

> I know about advising, so please don't recommend other ways to
> accomplish this.

OK.




reply via email to

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