From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: recenter-top-bottom Date: Wed, 07 Nov 2007 22:54:06 +0100 Message-ID: <473233FE.6000206@gmail.com> References: <4731F4BE.4000408@gmail.com> <473223B5.7070900@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1194472497 6037 80.91.229.12 (7 Nov 2007 21:54:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Nov 2007 21:54:57 +0000 (UTC) Cc: Drew Adams , emacs-devel@gnu.org To: Alan Mackenzie_JWA Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 07 22:55:00 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IpsrT-0004Rb-IL for ged-emacs-devel@m.gmane.org; Wed, 07 Nov 2007 22:54:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpsrI-0002Gq-C5 for ged-emacs-devel@m.gmane.org; Wed, 07 Nov 2007 16:54:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IpsrD-0002Fz-Q3 for emacs-devel@gnu.org; Wed, 07 Nov 2007 16:54:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IpsrC-0002ES-HK for emacs-devel@gnu.org; Wed, 07 Nov 2007 16:54:43 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpsrB-0002Da-Pp for emacs-devel@gnu.org; Wed, 07 Nov 2007 16:54:41 -0500 Original-Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IpsrA-0002h0-Oo for emacs-devel@gnu.org; Wed, 07 Nov 2007 16:54:41 -0500 Original-Received: from c83-254-148-228.bredband.comhem.se ([83.254.148.228]:59331 helo=[127.0.0.1]) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1Ipsr8-0004SQ-7y; Wed, 07 Nov 2007 22:54:38 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 In-Reply-To: <473223B5.7070900@gmail.com> X-Antivirus: avast! (VPS 071106-0, 2007-11-06), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.148.228 X-Scan-Result: No virus found in message 1Ipsr8-0004SQ-7y. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1Ipsr8-0004SQ-7y b4bd2e2822cb3cb678eb43e65de70ab2 X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:82771 Archived-At: Lennart Borgman (gmail) wrote: > (defun recenter-top-bottom (&optional arg) > "Move current line to window center, top, and bottom, alternately. > With prefix ARG, move current line to window-line ARG. > > Otherwise if the key sequence that invoked this command is > repeated within `cua-prefix-override-inhibit-delay' then current > line is moved to top, or if repeated again, bottom." > (interactive "P") > (if arg > (recenter arg) > (let* ((cmd-keys (this-command-keys)) > (delay 2);cua-prefix-override-inhibit-delay) > (keys (with-timeout (delay nil) (read-key-sequence nil)))) > (if (equal cmd-keys keys) > (let ((keys (with-timeout (delay nil) (read-key-sequence nil)))) > (if (equal cmd-keys keys) > (recenter -1) > (recenter 0) > (put-back-read-key-sequence keys))) > (recenter) > (put-back-read-key-sequence keys))))) > > (defun put-back-read-key-sequence (keys) > (when keys > (when (vectorp keys) > (setq keys (append keys nil))) > (isearch-unread keys))) I do not understand why, but this version works better: (defun put-back-read-key-sequence (keys) (when keys (when (stringp keys) (setq keys (string-to-char keys))) (when (vectorp keys) (setq keys (append keys nil))) (isearch-unread keys)))