unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "spamfilteraccount@gmail.com" <spamfilteraccount@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Overriding self-insert-command doesn't work
Date: 10 Mar 2007 08:56:24 -0800	[thread overview]
Message-ID: <1173545783.896059.199250@j27g2000cwj.googlegroups.com> (raw)

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.

             reply	other threads:[~2007-03-10 16:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-10 16:56 spamfilteraccount [this message]
2007-03-12 17:23 ` Overriding self-insert-command doesn't work 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1173545783.896059.199250@j27g2000cwj.googlegroups.com \
    --to=spamfilteraccount@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).