From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Newsgroups: gmane.emacs.help Subject: Re: Character repeation detection Date: Sun, 9 Mar 2014 20:20:54 +0000 (UTC) Message-ID: References: <878usjewew.fsf@gmail.com> <87eh2bmlvd.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1394396503 28713 80.91.229.3 (9 Mar 2014 20:21:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Mar 2014 20:21: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 Sun Mar 09 21:21:50 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 1WMkEH-0006ei-N2 for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 21:21:49 +0100 Original-Received: from localhost ([::1]:45430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMkEH-0001MO-9N for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 16:21:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMkDz-0001M5-Pi for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 16:21:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMkDs-0006kJ-FR for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 16:21:31 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:59383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMkDs-0006k9-8Q for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 16:21:24 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WMkDq-0006L6-Sp for help-gnu-emacs@gnu.org; Sun, 09 Mar 2014 21:21:23 +0100 Original-Received: from 84-236-108-177.pool.digikabel.hu ([84.236.108.177]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 09 Mar 2014 21:21:22 +0100 Original-Received: from adatgyujto by 84-236-108-177.pool.digikabel.hu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 09 Mar 2014 21:21:22 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 59 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 84.236.108.177 (Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.16) 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:96359 Archived-At: Tom 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)))