From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Character repeation detection Date: Sun, 09 Mar 2014 18:39:51 +0100 Organization: Informatimago Message-ID: <87wqg3s23c.fsf@kuiper.lan.informatimago.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1394387108 28019 80.91.229.3 (9 Mar 2014 17:45:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Mar 2014 17:45:08 +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 18:45:18 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 1WMhmo-0005sB-79 for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 18:45:18 +0100 Original-Received: from localhost ([::1]:44961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMhmn-0007ZK-TM for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2014 13:45:17 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 74 Original-X-Trace: individual.net 6+5bM4JTelhLhWpM6oloPQz5vtTO6AkJD/OB5judQZY6x/2iIY Cancel-Lock: sha1:M2U5NjU1M2MxOWM3ODQ2OGE1ZTk5OWYyYTRlMmNiMjlmYmU0ODAzZA== sha1:+HV2as6I9w+WwlTAtsA4rEjQ1Bw= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:204072 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:96342 Archived-At: Yuri Khan writes: > On Sun, Mar 9, 2014 at 12:47 PM, Tom wrote: > >> Is there a function or package to detect if a character is typed >> repeatedly? E.g. if a is typed 3 or more times in a row (aaa...) >> then call a function. >> >> Is there an existing solution for this? >> >> It would even be better if it had repetition suppression, that is >> if I leave my finger on a key so I type a string of a certain character >> (aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) then after the first 3 repetition >> the function is called and the rest of the repeated characters are >> removed from the keyboard buffer. ;; To correct some rebound problem I had with a keyboard, disable ;; two spaces in a row, unless it's preceded by a punctuation, or ;; explicitely requested. (defun pjb-electric-space-rebound (p) (interactive "P") ;; (message "p=%S" p) (cond ((null p) (let ((recent (recent-keys))) ;; (message "recent=%S"(equal (subseq recent (1- (length recent))) [32])) (if (equal (subseq recent (- (length recent) 2)) [32 32]) (when (let ((pt (point))) (when (< (+ (point-min) 2) pt) (unwind-protect (progn (forward-char -2) (looking-at "[.;!?] ")) (goto-char pt)))) (insert " ")) (insert " ")))) ((eq p '-)) ((integerp p) (insert (make-string p 32))) ((and (listp p) (integerp (car p))) (insert (make-string (car p) 32))) (t (error "Unknown raw prefix argument %S" p)))) ;; (global-set-key (kbd "SPC") 'pjb-electric-space-rebound) (defun pjb-electric-ellipsis (p) "... --> …" (interactive "P") (cond ((null p) (let ((recent (recent-keys))) (if (and (equal (subseq recent (- (length recent) 2)) [?. ?.]) (equal (buffer-substring (- (point) 2) (point)) "..")) (progn (delete-region (- (point) 2) (point)) (insert "…")) (insert ".")))) ((eq p '-)) ((integerp p) (insert (make-string p ?.))) ((and (listp p) (integerp (car p))) (insert (make-string (car p) ?.))) (t (error "Unknown raw prefix argument %S" p)))) (global-set-key (kbd ".") 'pjb-electric-ellipsis) -- __Pascal Bourguignon__ http://www.informatimago.com/ "Le mercure monte ? C'est le moment d'acheter !"