From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Character repeation detection
Date: Mon, 10 Mar 2014 09:59:32 +0800 [thread overview]
Message-ID: <87ob1edda3.fsf@ericabrahamsen.net> (raw)
In-Reply-To: loom.20140309T081128-120@post.gmane.org
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
next prev parent reply other threads:[~2014-03-10 1:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-09 5:47 Character repeation detection Tom
2014-03-09 6:08 ` Jambunathan K
2014-03-09 7:08 ` Tom
2014-03-09 7:12 ` Tom
2014-03-09 13:47 ` Marcin Borkowski
2014-03-09 15:29 ` Jambunathan K
2014-03-09 16:46 ` Tom
2014-03-09 17:13 ` Marcin Borkowski
2014-03-09 18:20 ` Andreas Röhler
2014-03-09 18:39 ` Tom
2014-03-09 20:20 ` Tom
2014-03-10 1:20 ` Stefan Monnier
[not found] ` <mailman.16788.1394383649.10748.help-gnu-emacs@gnu.org>
2014-03-09 17:46 ` Dan Espen
2014-03-09 18:42 ` Tom
2014-03-10 1:15 ` Joost Kremers
2014-03-10 1:59 ` Eric Abrahamsen [this message]
2014-03-09 16:29 ` Yuri Khan
[not found] ` <mailman.16786.1394382568.10748.help-gnu-emacs@gnu.org>
2014-03-09 17:39 ` Pascal J. Bourguignon
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ob1edda3.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.