unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Marcin Borkowski <mbork@wmi.amu.edu.pl>
To: help-gnu-emacs@gnu.org
Subject: Re: Character repeation detection
Date: Sun, 9 Mar 2014 14:47:35 +0100	[thread overview]
Message-ID: <20140309144735.70a7100d@aga-netbook> (raw)
In-Reply-To: <loom.20140309T081128-120@post.gmane.org>

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



  reply	other threads:[~2014-03-09 13:47 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 [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140309144735.70a7100d@aga-netbook \
    --to=mbork@wmi.amu.edu.pl \
    --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.
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).