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

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

Re: key interception in major mode


From: Ian Zimmerman
Subject: Re: key interception in major mode
Date: Sat, 14 Jan 2006 18:14:52 -0800 (PST)
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

Anton> I am writing my own major mode. How can I make my own function
Anton> called on every key press?  I tried to create a copy of global
Anton> map, replacing self-insert-command function with my own, but
Anton> failed. Maybe there is another way to achieve key interception in
Anton> major mode?

First of all, it is not clear what you mean by "called on every key
press".  `self-insert-command' certainly isn't called on every key press
from my POV; for example, it isn't called when you press the TAB key.
(unless a major mode overrides its binding in the global map, of
course).

That said, here is one way (though probably not the cleanest way) of
doing something along the lines you did: define an advice (see the
online help for `defadvice') for `self-insert-command'; the adviced
function should first check the major mode (variable `major-mode')
and either do your thing or else the usual thing (`ad-do-it').

-- 
A true pessimist won't be discouraged by a little success.




reply via email to

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