From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: Character repeation detection Date: Mon, 10 Mar 2014 09:59:32 +0800 Message-ID: <87ob1edda3.fsf@ericabrahamsen.net> References: <878usjewew.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1394416663 26441 80.91.229.3 (10 Mar 2014 01:57:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Mar 2014 01:57:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 10 02:57:48 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 1WMpTL-0002nO-4N for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Mar 2014 02:57:43 +0100 Original-Received: from localhost ([::1]:46369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMpTK-0006jl-Pv for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 21:57:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMpT3-0006jW-UV for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 21:57:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMpSw-0006uz-LR for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 21:57:25 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:42338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMpSw-0006us-F4 for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 21:57:18 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WMpSt-0002Qj-So for help-gnu-emacs@gnu.org; Mon, 10 Mar 2014 02:57:15 +0100 Original-Received: from 114.248.1.149 ([114.248.1.149]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Mar 2014 02:57:15 +0100 Original-Received: from eric by 114.248.1.149 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Mar 2014 02:57:15 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 40 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 114.248.1.149 User-Agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:XMWjNhRaXW7fF41PsXiKLpNXOXs= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:96371 Archived-At: Tom writes: > Tom gmail.com> writes: > >> >> Jambunathan K 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