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

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

Re: Character repeation detection


From: Eric Abrahamsen
Subject: Re: Character repeation detection
Date: Mon, 10 Mar 2014 09:59:32 +0800
User-agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.3 (gnu/linux)

Tom <adatgyujto@gmail.com> writes:

> Tom <adatgyujto <at> gmail.com> writes:
>
>> 
>> Jambunathan K <kjambunathan <at> gmail.com> writes:
>> 
>> > > Is there an existing solution for this?
>> > 
>> >     M-s h r \(.\)\1 RET
>> > 
>> >     (highlight-regexp "\\(.\\)\\1" (quote highlight))
>> > 
>> 
>> I'm not talking about highlighting. I'd like an actual function
>> call when this happens.
>> 
>
> And I don't mean 3 or more of the same character in the buffer
> somewhere. I'm interested in detecting  when the user types
> 3 or more of the same character in a row.

I was going to suggest that you make a vector where you store the values
of `last-input-event' in the `post-self-insert-hook' and then check the
value of that vector, but then it occurred to me that emacs already does
this with lossage. And from there to:

recent-keys is a built-in function in `C source code'.

(recent-keys)

Return vector of last 300 events, not counting those from keyboard macros.

Pretty much just what you want. It should be fairly easy to (again using
the `post-self-insert-hook') write a function that takes
`last-input-event' and compares it to the newest values returned by
`recent-keys', and then go from there.

HTH,
Eric




reply via email to

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