From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.help Subject: Re: Character repeation detection Date: Sun, 09 Mar 2014 20:59:10 +0530 Message-ID: <87eh2bmlvd.fsf@gmail.com> References: <878usjewew.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1394378929 9746 80.91.229.3 (9 Mar 2014 15:28:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Mar 2014 15:28:49 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Tom Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 09 16:28:58 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 1WMfeq-00033F-TL for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 16:28:57 +0100 Original-Received: from localhost ([::1]:44446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMfeq-0002Og-C4 for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 11:28:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMfeX-0002LK-2j for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 11:28:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMfeO-0001Ax-F9 for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 11:28:36 -0400 Original-Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]:33746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMfeO-00019u-8I for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 11:28:28 -0400 Original-Received: by mail-pd0-f176.google.com with SMTP id r10so6011761pdi.21 for ; Sun, 09 Mar 2014 08:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=j8bBqjGOU6RFmnvDdJNgQ2Q24GdJ2JkqgElSKpAhH0E=; b=LRFgnH6BUhnNMdcQ35rSVNujAkZrQFFqNPvtWB2J/k12t704FQvUFvoKfzQ8+8M86A 0bbuaRNM975HdwT7QFmLa9nVFxVGc1zwD1gMI7YrxAVGAV8TaI1RhIXbQ+cT+1TwQn6S ymJUCBK+PBaxdgfoEV+cbnvWpbVwjJ5YVN2tGe1qeeWUxPa9W+7zGT6D10LVEAfz3DbP u/7TamctzqyV0BVVGWWHCXGzx9uzyUzrgrkiePj3EkSe9rPUcuZ3kgBKgAXz0g8dGiNd G+S2Ubgm+Q0LPYpnXZkJqABv+w6hShvYGKxwxbPDvC1qz9hqW8OttDAr1CNF0cgc0FAY a9ng== X-Received: by 10.68.229.164 with SMTP id sr4mr34442951pbc.82.1394378907222; Sun, 09 Mar 2014 08:28:27 -0700 (PDT) Original-Received: from debian-6.05 ([115.241.91.251]) by mx.google.com with ESMTPSA id y9sm58872757pas.10.2014.03.09.08.28.24 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Sun, 09 Mar 2014 08:28:26 -0700 (PDT) In-Reply-To: (Tom's message of "Sun, 9 Mar 2014 07:12:55 +0000 (UTC)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::230 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:96338 Archived-At: Tom 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))