* Character repeation detection
@ 2014-03-09 5:47 Tom
2014-03-09 6:08 ` Jambunathan K
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Tom @ 2014-03-09 5:47 UTC (permalink / raw)
To: help-gnu-emacs
Is there a function or package to detect if a character is typed
repeatedly? E.g. if a is typed 3 or more times in a row (aaa...)
then call a function.
Is there an existing solution for this?
It would even be better if it had repetition suppression, that is
if I leave my finger on a key so I type a string of a certain character
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) then after the first 3 repetition
the function is called and the rest of the repeated characters are
removed from the keyboard buffer.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
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 16:29 ` Yuri Khan
[not found] ` <mailman.16786.1394382568.10748.help-gnu-emacs@gnu.org>
2 siblings, 1 reply; 18+ messages in thread
From: Jambunathan K @ 2014-03-09 6:08 UTC (permalink / raw)
To: help-gnu-emacs
Tom <adatgyujto@gmail.com> writes:
> Is there a function or package to detect if a character is typed
> repeatedly? E.g. if a is typed 3 or more times in a row (aaa...)
> then call a function.
>
> Is there an existing solution for this?
M-s h r \(.\)\1 RET
(highlight-regexp "\\(.\\)\\1" (quote highlight))
>
> It would even be better if it had repetition suppression, that is
> if I leave my finger on a key so I type a string of a certain character
> (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) then after the first 3 repetition
> the function is called and the rest of the repeated characters are
> removed from the keyboard buffer.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 6:08 ` Jambunathan K
@ 2014-03-09 7:08 ` Tom
2014-03-09 7:12 ` Tom
0 siblings, 1 reply; 18+ messages in thread
From: Tom @ 2014-03-09 7:08 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 7:08 ` Tom
@ 2014-03-09 7:12 ` Tom
2014-03-09 13:47 ` Marcin Borkowski
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Tom @ 2014-03-09 7:12 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 7:12 ` Tom
@ 2014-03-09 13:47 ` Marcin Borkowski
2014-03-09 15:29 ` Jambunathan K
2014-03-10 1:59 ` Eric Abrahamsen
2 siblings, 0 replies; 18+ messages in thread
From: Marcin Borkowski @ 2014-03-09 13:47 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-03-09, o godz. 07:12:55
Tom <adatgyujto@gmail.com> napisał(a):
> 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.
An obvious idea that comes to mind is to advise the
`self-insert-command' function. Can functions written in C be
advised? (I don't know, I never actually *used* advice.)
If this is not possible, one could remap all self-inserting commands
to e.g. `self-insert-if-not-repeated-too-many-times', which could be
trivially defined to Do The Right Thing™ (possibly using something
like (looking-back "\\(.\\)\\1")).
Note: do you mean "when the user types 3 or more of the same character
in a row", or rather "when a user types a character such that two
characters before point are this very character, too?" My suggestion
deals with the latter variant, of course, which encompasses more cases
than the former, but seems reasonable to me.
Hth,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
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
[not found] ` <mailman.16788.1394383649.10748.help-gnu-emacs@gnu.org>
2014-03-10 1:59 ` Eric Abrahamsen
2 siblings, 2 replies; 18+ messages in thread
From: Jambunathan K @ 2014-03-09 15:29 UTC (permalink / raw)
To: Tom; +Cc: help-gnu-emacs
Tom <adatgyujto@gmail.com> writes:
> 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.
Here is a quick one that checks for 2 characters in a row.
Are you sure you don't want flyspell-mode and only this. What is your
usecase. Why would you want this?
(defvar-local my-last-command-event nil)
(defun my-self-insert-command (N)
(interactive "p")
(if (eq my-last-command-event last-command-event)
(minibuffer-message "Refusing to insert %c" last-command-event)
(setq my-last-command-event last-command-event)
(self-insert-command N)))
(defun my-post-command-hook ()
(unless (eq this-command 'my-self-insert-command)
(setq my-last-command-event nil)))
(add-hook 'post-command-hook 'my-post-command-hook)
(substitute-key-definition 'self-insert-command
'my-self-insert-command
(current-global-map))
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 5:47 Character repeation detection Tom
2014-03-09 6:08 ` Jambunathan K
@ 2014-03-09 16:29 ` Yuri Khan
[not found] ` <mailman.16786.1394382568.10748.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 18+ messages in thread
From: Yuri Khan @ 2014-03-09 16:29 UTC (permalink / raw)
To: Tom; +Cc: help-gnu-emacs@gnu.org
On Sun, Mar 9, 2014 at 12:47 PM, Tom <adatgyujto@gmail.com> wrote:
> Is there a function or package to detect if a character is typed
> repeatedly? E.g. if a is typed 3 or more times in a row (aaa...)
> then call a function.
>
> Is there an existing solution for this?
>
> It would even be better if it had repetition suppression, that is
> if I leave my finger on a key so I type a string of a certain character
> (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) then after the first 3 repetition
> the function is called and the rest of the repeated characters are
> removed from the keyboard buffer.
What kind of function do you have in mind to call in such cases?
Is it about preventing key autorepeat? Then just disable autorepeat in
your system, or set a very high autorepeat delay and/or low rate.
What about repeated key presses and releases, do you want to suppress
that too? You might want to enable a key filtering accessibility
feature.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 15:29 ` Jambunathan K
@ 2014-03-09 16:46 ` Tom
2014-03-09 17:13 ` Marcin Borkowski
` (2 more replies)
[not found] ` <mailman.16788.1394383649.10748.help-gnu-emacs@gnu.org>
1 sibling, 3 replies; 18+ messages in thread
From: Tom @ 2014-03-09 16:46 UTC (permalink / raw)
To: help-gnu-emacs
Jambunathan K <kjambunathan <at> gmail.com> writes:
>
> Here is a quick one that checks for 2 characters in a row.
>
> Are you sure you don't want flyspell-mode and only this. What is your
> usecase. Why would you want this?
I want to use it as a hotkey.
It occured to me it's very unusual to type the same character 3
times in a row. Two can occur in words, but 3 practically never.
Therefore it could be used as a single key hotkey in text buffers
where otherwise you use the characters to type.
For example, I want to invoke occur. I press o and keep it pressed.
After auto repeat types 3 o characters this function kicks in, removes
the 3 typed Os from the buffer, removes the additional Os from the
keyboard buffer (if I kept it pressed for two long) and calls occur.
It seems to me it would be more convenient than typing multikey
hotkeys and it would give lots of new free bindings in addition to
the existing ones.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
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
2 siblings, 2 replies; 18+ messages in thread
From: Marcin Borkowski @ 2014-03-09 17:13 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-03-09, o godz. 16:46:47
Tom <adatgyujto@gmail.com> napisał(a):
> It occured to me it's very unusual to type the same character 3
> times in a row. Two can occur in words, but 3 practically never.
Balletttänzer.
(The "new" German spelling is really, really strange... Basically - as
I see it - there was an alternative. Either Microsoft fixes
the hyphenation algorithm in MS Word, or the Germans change their
spelling. Guess who won...)
Regards,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
[not found] ` <mailman.16786.1394382568.10748.help-gnu-emacs@gnu.org>
@ 2014-03-09 17:39 ` Pascal J. Bourguignon
0 siblings, 0 replies; 18+ messages in thread
From: Pascal J. Bourguignon @ 2014-03-09 17:39 UTC (permalink / raw)
To: help-gnu-emacs
Yuri Khan <yuri.v.khan@gmail.com> writes:
> On Sun, Mar 9, 2014 at 12:47 PM, Tom <adatgyujto@gmail.com> wrote:
>
>> Is there a function or package to detect if a character is typed
>> repeatedly? E.g. if a is typed 3 or more times in a row (aaa...)
>> then call a function.
>>
>> Is there an existing solution for this?
>>
>> It would even be better if it had repetition suppression, that is
>> if I leave my finger on a key so I type a string of a certain character
>> (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) then after the first 3 repetition
>> the function is called and the rest of the repeated characters are
>> removed from the keyboard buffer.
;; To correct some rebound problem I had with a keyboard, disable
;; two spaces in a row, unless it's preceded by a punctuation, or
;; explicitely requested.
(defun pjb-electric-space-rebound (p)
(interactive "P")
;; (message "p=%S" p)
(cond
((null p)
(let ((recent (recent-keys)))
;; (message "recent=%S"(equal (subseq recent (1- (length recent))) [32]))
(if (equal (subseq recent (- (length recent) 2)) [32 32])
(when (let ((pt (point)))
(when (< (+ (point-min) 2) pt)
(unwind-protect
(progn
(forward-char -2)
(looking-at "[.;!?] "))
(goto-char pt))))
(insert " "))
(insert " "))))
((eq p '-))
((integerp p) (insert (make-string p 32)))
((and (listp p) (integerp (car p))) (insert (make-string (car p) 32)))
(t (error "Unknown raw prefix argument %S" p))))
;; (global-set-key (kbd "SPC") 'pjb-electric-space-rebound)
(defun pjb-electric-ellipsis (p)
"... --> …"
(interactive "P")
(cond
((null p)
(let ((recent (recent-keys)))
(if (and (equal (subseq recent (- (length recent) 2)) [?. ?.])
(equal (buffer-substring (- (point) 2) (point)) ".."))
(progn
(delete-region (- (point) 2) (point))
(insert "…"))
(insert "."))))
((eq p '-))
((integerp p) (insert (make-string p ?.)))
((and (listp p) (integerp (car p))) (insert (make-string (car p) ?.)))
(t (error "Unknown raw prefix argument %S" p))))
(global-set-key (kbd ".") 'pjb-electric-ellipsis)
--
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ? C'est le moment d'acheter !"
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
[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
1 sibling, 1 reply; 18+ messages in thread
From: Dan Espen @ 2014-03-09 17:46 UTC (permalink / raw)
To: help-gnu-emacs
Tom <adatgyujto@gmail.com> writes:
> Jambunathan K <kjambunathan <at> gmail.com> writes:
>
>>
>> Here is a quick one that checks for 2 characters in a row.
>>
>> Are you sure you don't want flyspell-mode and only this. What is your
>> usecase. Why would you want this?
>
> I want to use it as a hotkey.
>
> It occured to me it's very unusual to type the same character 3
> times in a row. Two can occur in words, but 3 practically never.
>
> Therefore it could be used as a single key hotkey in text buffers
> where otherwise you use the characters to type.
I have a KVM that uses 3 presses of Ctrl as a way of sending commands
to the KVM. 3 presses followed by a key that represents the command.
I do sometimes accidentally hit Ctrl 3 times but the KVM
starts flashing the keyboard LED lights so it's easy to know I've hit
the key by accident.
> For example, I want to invoke occur. I press o and keep it pressed.
> After auto repeat types 3 o characters this function kicks in, removes
> the 3 typed Os from the buffer, removes the additional Os from the
> keyboard buffer (if I kept it pressed for two long) and calls occur.
>
> It seems to me it would be more convenient than typing multikey
> hotkeys and it would give lots of new free bindings in addition to
> the existing ones.
It would, but I suspect the modes that have a lot of key bindings
using typing keys (like Dired and buffer list) might present a problem.
--
Dan Espen
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 17:13 ` Marcin Borkowski
@ 2014-03-09 18:20 ` Andreas Röhler
2014-03-09 18:39 ` Tom
1 sibling, 0 replies; 18+ messages in thread
From: Andreas Röhler @ 2014-03-09 18:20 UTC (permalink / raw)
To: help-gnu-emacs
Am 09.03.2014 18:13, schrieb Marcin Borkowski:
> Dnia 2014-03-09, o godz. 16:46:47
> Tom <adatgyujto@gmail.com> napisał(a):
>
>> It occured to me it's very unusual to type the same character 3
>> times in a row. Two can occur in words, but 3 practically never.
>
> Balletttänzer.
>
> (The "new" German spelling is really, really strange...
Indeed. But write
The new "German" spelling.
The imposed disorder was rejected by a majority of writers and the people alike.
Imposing it nonetheless tells something of the condition we have to live in.
Basically - as
> I see it - there was an alternative. Either Microsoft fixes
> the hyphenation algorithm in MS Word, or the Germans change their
rather not "the Germans"
> spelling. Guess who won...)
>
> Regards,
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 17:13 ` Marcin Borkowski
2014-03-09 18:20 ` Andreas Röhler
@ 2014-03-09 18:39 ` Tom
1 sibling, 0 replies; 18+ messages in thread
From: Tom @ 2014-03-09 18:39 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork <at> wmi.amu.edu.pl> writes:
>
> Dnia 2014-03-09, o godz. 16:46:47
> Tom <adatgyujto <at> gmail.com> napisał(a):
>
> > It occured to me it's very unusual to type the same character 3
> > times in a row. Two can occur in words, but 3 practically never.
>
> Balletttänzer.
>
Ok, you wouldn't bind k then, but what about uuu, ooo, aaa, etc.?
Surely you can find a character which triplets do not occur in
the languages you use.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 17:46 ` Dan Espen
@ 2014-03-09 18:42 ` Tom
0 siblings, 0 replies; 18+ messages in thread
From: Tom @ 2014-03-09 18:42 UTC (permalink / raw)
To: help-gnu-emacs
Dan Espen <despen <at> verizon.net> writes:
> >
> > It seems to me it would be more convenient than typing multikey
> > hotkeys and it would give lots of new free bindings in addition to
> > the existing ones.
>
> It would, but I suspect the modes that have a lot of key bindings
> using typing keys (like Dired and buffer list) might present a problem.
>
It is for the buffers in which you usually type, so you can't bind
single key hotkeys.
In Dired and other modes you can already bind new single hotkeys
if you want.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 16:46 ` Tom
2014-03-09 17:13 ` Marcin Borkowski
@ 2014-03-09 20:20 ` Tom
2014-03-10 1:20 ` Stefan Monnier
2 siblings, 0 replies; 18+ messages in thread
From: Tom @ 2014-03-09 20:20 UTC (permalink / raw)
To: help-gnu-emacs
Tom <adatgyujto <at> gmail.com> writes:
>
> It seems to me it would be more convenient than typing multikey
> hotkeys and it would give lots of new free bindings in addition to
> the existing ones.
>
I created a crude implementation to test the concept.
It invokes occur if you press o 3 times or press o and
keep it pressed. It is active only in buffers with emacs-lisp-mode
major mode for now.
It works, but looks a bit unconventional as the o characters are
deleted automatically.
The only thing missing is restoring the unmodified status
of the buffer if it was unmodified before.
(setq my-char-to-check ?o)
(setq my-char-count 0)
(setq my-start-pos nil)
(defun my-post-command-hook ()
(when (and (eq major-mode 'emacs-lisp-mode)
(eq this-command 'self-insert-command))
(if (not (eq last-command-char my-char-to-check))
(setq my-char-count 0)
(if (eq my-char-count 0)
(setq my-start-pos (1- (point))))
(incf my-char-count)
(when (eq my-char-count 3)
(setq my-char-count 0)
;; should restore buffer modified status here
(delete-region my-start-pos (point))
(run-with-idle-timer
0 nil
(lambda ()
(add-hook 'post-command-hook 'my-remove-excess-chars)
(call-interactively 'occur)))))))
(add-hook 'post-command-hook 'my-post-command-hook)
(defun my-remove-excess-chars ()
(when (sit-for 0.1)
(delete-region (point) (line-beginning-position))
(remove-hook 'post-command-hook 'my-remove-excess-chars)))
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
[not found] ` <mailman.16788.1394383649.10748.help-gnu-emacs@gnu.org>
2014-03-09 17:46 ` Dan Espen
@ 2014-03-10 1:15 ` Joost Kremers
1 sibling, 0 replies; 18+ messages in thread
From: Joost Kremers @ 2014-03-10 1:15 UTC (permalink / raw)
To: help-gnu-emacs
Tom wrote:
> Jambunathan K <kjambunathan <at> gmail.com> writes:
>
>>
>> Here is a quick one that checks for 2 characters in a row.
>>
>> Are you sure you don't want flyspell-mode and only this. What is your
>> usecase. Why would you want this?
>
> I want to use it as a hotkey.
>
> It occured to me it's very unusual to type the same character 3
> times in a row. Two can occur in words, but 3 practically never.
>
> Therefore it could be used as a single key hotkey in text buffers
> where otherwise you use the characters to type.
Perhaps check out key-chord-mode:
http://www.emacswiki.org/KeyChord
Similar idea, might contain some ideas you can use.
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 16:46 ` Tom
2014-03-09 17:13 ` Marcin Borkowski
2014-03-09 20:20 ` Tom
@ 2014-03-10 1:20 ` Stefan Monnier
2 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2014-03-10 1:20 UTC (permalink / raw)
To: help-gnu-emacs
> For example, I want to invoke occur. I press o and keep it pressed.
> After auto repeat types 3 o characters this function kicks in, removes
> the 3 typed Os from the buffer, removes the additional Os from the
> keyboard buffer (if I kept it pressed for two long) and calls occur.
I think that dealing with auto-repeat would be ugly: you have to
wait "1 / auto-repeat-rate" before you know if you've seen the last
repetition and in general you don't know auto-repeat-rate so it's
a bit hackish. And if you additionally want to check if the event is
really an auto-repeat and not some other event that also came quickly,
then you need to "peek" at the events, which is somewhere between hard
and impossible to do reliably.
OTOH if you only want to handle the "3 presses" case, you can probably
do it as follows:
(defvar my-multi-self-insert-trick-map '((?o . occur)))
(defun my-multi-self-insert-trick ()
(and (eq this-command last-command)
(not current-prefix-arg)
(looking-back "\\(.\\)\\1\\{2\\}" (- (point) 3)) ;; 3rd in a row.
(let ((cmd (cdr (assq (char-before)
my-multi-self-insert-trick-map))))
(when cmd
(delete-region (match-beginning 0) (match-end 0))
(call-interactively cmd)))))
(add-hook 'post-self-insert-hook 'my-multi-self-insert-trick)
To handle auto-repeat, you'd have to add a loop along the lines of
(let ((evt last-command-event))
(while (and (not (sit-for (/ 1.0 my-auto-repeat-rate) 'nodisp))
(let ((k (read-key "")))
(if (and (eq (length k) 1) (eq (aref k 0) evt))
;; It's a repetition; just drop it.
t
;; It's not a repetition; put it back.
;; FIXME: we basically can't do it 100% right because
;; read-key already had to decide whether the incoming
;; events are bytes or characters.
(setq unread-command-events
(nconc (append (this-single-command-raw-keys) nil)
unread-command-events))
nil)))))
after the `when cmd'.
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Character repeation detection
2014-03-09 7:12 ` Tom
2014-03-09 13:47 ` Marcin Borkowski
2014-03-09 15:29 ` Jambunathan K
@ 2014-03-10 1:59 ` Eric Abrahamsen
2 siblings, 0 replies; 18+ messages in thread
From: Eric Abrahamsen @ 2014-03-10 1:59 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2014-03-10 1:59 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).