From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Deniz Dogan Newsgroups: gmane.emacs.devel Subject: Suggestion to change the behavior of M-r Date: Sun, 19 Apr 2009 18:40:31 +0200 Message-ID: <7b501d5c0904190940x24e9412fvb26dc531b096a62d@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1240159292 21253 80.91.229.12 (19 Apr 2009 16:41:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Apr 2009 16:41:32 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 19 18:42:52 2009 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 1Lva6R-0002Sj-5u for ged-emacs-devel@m.gmane.org; Sun, 19 Apr 2009 18:42:47 +0200 Original-Received: from localhost ([127.0.0.1]:48487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lva52-00085d-De for ged-emacs-devel@m.gmane.org; Sun, 19 Apr 2009 12:41:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lva4M-0007pi-Va for emacs-devel@gnu.org; Sun, 19 Apr 2009 12:40:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lva4M-0007ou-1w for emacs-devel@gnu.org; Sun, 19 Apr 2009 12:40:38 -0400 Original-Received: from [199.232.76.173] (port=44061 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lva4L-0007oj-Qx for emacs-devel@gnu.org; Sun, 19 Apr 2009 12:40:37 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:34360) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lva4L-00055Y-Dk for emacs-devel@gnu.org; Sun, 19 Apr 2009 12:40:37 -0400 Original-Received: from fg-out-1718.google.com ([72.14.220.159]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lva4J-0007EP-IL for emacs-devel@gnu.org; Sun, 19 Apr 2009 12:40:35 -0400 Original-Received: by fg-out-1718.google.com with SMTP id l27so322818fgb.7 for ; Sun, 19 Apr 2009 09:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=9fViIpr2mwXqsKNKuRLVwK6Rz0v0gslD7a/VV+3C33k=; b=cre0GM9T4wxtORtBBZ8HDWmYxkXkVDQpUlNo7TLB/b39HEe52UPiKI+qSIWYI+Uw6w LzrDwFb0wzPy2WdHALslG9jK8LpTpiobFw5qfMTPqUi+o4RNw4roBXrz1DQhK1iRpAIy Zc4l2zGchedIqXQ+krag3Bx706lxs2QER+g4E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=VF87CrmvWLzhmXYAUqcxal+hkxBjATLlvV8F+sA8EhyJ9KGGncI6afhQY7vTvQXmLZ cD5ujkj8jg+sgGKRbP5FwFk+ImMlqCVLcMTVbxWvCaqaJ/Lw0qoWx3t41rmjl5r1+UD0 Wkt5VjcEZb630XUdo/CVvjzoYfHpCru5u5A7U= Original-Received: by 10.86.94.11 with SMTP id r11mr3400852fgb.11.1240159231274; Sun, 19 Apr 2009 09:40:31 -0700 (PDT) X-detected-kernel: by mx20.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:110349 Archived-At: Hi I recently found out about the M-r keybinding, which by default is bound to move-to-window-line. Already knowing about the C-l keybinding (recenter-top-bottom) I was a bit thrown off when I found out that M-r doesn't behave in the same way. This got me thinking that the behavior of M-r should be changed to behave somewhat like C-l. So I basically stole the code for recenter-top-bottom and modified it to work with move-to-window-line instead. This is the result: (defvar move-to-window-line-last-op nil "Indicates the last move-to-window-line operation performed. Possible values: `top', `middle', `bottom'.") (defun move-to-window-line-top-bottom (&optional arg) (interactive "P") (cond (arg (move-to-window-line arg)) ; Always respect ARG. ((or (not (eq this-command last-command)) ; If this is not a repetition (eq move-to-window-line-last-op 'bottom)) ; or if the last one put us at the bottom (setq move-to-window-line-last-op 'middle) ; then move it to the middle (call-interactively 'move-to-window-line)) (t (let ((this-scroll-margin (min (max 0 scroll-margin) (truncate (/ (window-body-height) 4.0))))) (cond ((eq move-to-window-line-last-op 'middle) ; If we're at the middle (setq move-to-window-line-last-op 'top) ; then move to the top (move-to-window-line this-scroll-margin)) ((eq move-to-window-line-last-op 'top) ; If we're at the top (setq move-to-window-line-last-op 'bottom) ; then move to the bottom (move-to-window-line (- -1 this-scroll-margin)))))))) Please, do consider changing the behavior of M-r, of course not necessarily using the code above. If the code became a bit obfuscated on its way to the mailing list, I pasted it on lisp.org as well: http://paste.lisp.org/display/78841 Thanks, Deniz Dogan