From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "spamfilteraccount@gmail.com" Newsgroups: gmane.emacs.help Subject: Overriding self-insert-command doesn't work Date: 10 Mar 2007 08:56:24 -0800 Organization: http://groups.google.com Message-ID: <1173545783.896059.199250@j27g2000cwj.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1173548412 681 80.91.229.12 (10 Mar 2007 17:40:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 10 Mar 2007 17:40:12 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 10 18:40:10 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HQ5Y9-00049T-FM for geh-help-gnu-emacs@m.gmane.org; Sat, 10 Mar 2007 18:40:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HQ5YX-0004Sf-O5 for geh-help-gnu-emacs@m.gmane.org; Sat, 10 Mar 2007 12:40:33 -0500 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!j27g2000cwj.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: 81.183.146.34 Original-X-Trace: posting.google.com 1173545789 28810 127.0.0.1 (10 Mar 2007 16:56:29 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 10 Mar 2007 16:56:29 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.10 (Windows NT 5.1; U; en),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j27g2000cwj.googlegroups.com; posting-host=81.183.146.34; posting-account=b98TkQ0AAAD7PsllN8gfWGRoPOPWdnv4 Original-Xref: shelby.stanford.edu gnu.emacs.help:146259 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:41863 Archived-At: 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.