From: Deniz Dogan <deniz.a.m.dogan@gmail.com>
To: emacs-devel@gnu.org
Subject: Suggestion to change the behavior of M-r
Date: Sun, 19 Apr 2009 18:40:31 +0200 [thread overview]
Message-ID: <7b501d5c0904190940x24e9412fvb26dc531b096a62d@mail.gmail.com> (raw)
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
next reply other threads:[~2009-04-19 16:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-19 16:40 Deniz Dogan [this message]
2009-08-12 18:51 ` Suggestion to change the behavior of M-r Deniz Dogan
2009-08-12 20:52 ` Juri Linkov
2009-08-12 23:20 ` Deniz Dogan
2009-08-12 23:26 ` Deniz Dogan
2009-08-13 23:17 ` Juri Linkov
2009-10-04 16:51 ` Deniz Dogan
2009-10-05 21:33 ` Juri Linkov
2009-11-23 3:57 ` Stefan Monnier
2009-11-23 5:38 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b501d5c0904190940x24e9412fvb26dc531b096a62d@mail.gmail.com \
--to=deniz.a.m.dogan@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.