From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: Character repeation detection Date: Sun, 9 Mar 2014 14:47:35 +0100 Organization: WMI UAM Message-ID: <20140309144735.70a7100d@aga-netbook> References: <878usjewew.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1394372872 12423 80.91.229.3 (9 Mar 2014 13:47:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Mar 2014 13:47:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 09 14:48:02 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WMe5B-0003q7-HF for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 14:48:01 +0100 Original-Received: from localhost ([::1]:44086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMe5A-0001bD-Mk for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 09:48:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMe4v-0001b4-AC for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 09:47:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMe4p-0007qh-N6 for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 09:47:45 -0400 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:59697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMe4p-0007qY-GC for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 09:47:39 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 88C2C4206D for ; Sun, 9 Mar 2014 14:47:37 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YAAtlyb-05Wf for ; Sun, 9 Mar 2014 14:47:37 +0100 (CET) Original-Received: from aga-netbook (99-234.echostar.pl [213.156.99.234]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id 600B742066 for ; Sun, 9 Mar 2014 14:47:37 +0100 (CET) In-Reply-To: X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.20; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:808:114:2::50 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96337 Archived-At: Dnia 2014-03-09, o godz. 07:12:55 Tom napisa=C5=82(a): > Tom gmail.com> writes: >=20 > >=20 > > Jambunathan K gmail.com> writes: > >=20 > > > > Is there an existing solution for this? > > >=20 > > > M-s h r \(.\)\1 RET > > >=20 > > > (highlight-regexp "\\(.\\)\\1" (quote highlight)) > > >=20 > >=20 > > I'm not talking about highlighting. I'd like an actual function > > call when this happens. > >=20 >=20 > 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=E2=84=A2 (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, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University