aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-11-16 18:50:35 +0000
committerStefan Monnier2007-11-16 18:50:35 +0000
commitde8ebf6226a1948e9df250abd9a42b4ccff2a5c7 (patch)
tree889864bd5f2773be368b8efa07fad1ac9f37dfcb
parentd548715ceb4a2dcbc7d82100a490b9aa2913d4e4 (diff)
downloademacs-de8ebf6226a1948e9df250abd9a42b4ccff2a5c7.tar.gz
emacs-de8ebf6226a1948e9df250abd9a42b4ccff2a5c7.zip
(recenter-last-op): New var.
(recenter-top-bottom): New command. (global-map): Bind it to C-l.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/window.el38
2 files changed, 42 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ccd62fa9e36..c17f848c0f4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12007-11-16 Stefan Monnier <monnier@iro.umontreal.ca> 12007-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * window.el (recenter-last-op): New var.
4 (recenter-top-bottom): New command.
5 (global-map): Bind it to C-l.
6
3 * abbrev.el (abbrev--write): Fix error in transcription from C. 7 * abbrev.el (abbrev--write): Fix error in transcription from C.
4 8
5 * emulation/pc-select.el (pc-select-shifted-mark): Remove. 9 * emulation/pc-select.el (pc-select-shifted-mark): Remove.
diff --git a/lisp/window.el b/lisp/window.el
index 0f6ae8ab763..94e4b48a3a7 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -879,6 +879,44 @@ and the buffer that is killed or buried is the one in that window."
879 ;; Maybe get rid of the window. 879 ;; Maybe get rid of the window.
880 (and window (not window-handled) (not window-solitary) 880 (and window (not window-handled) (not window-solitary)
881 (delete-window window)))) 881 (delete-window window))))
882
883(defvar recenter-last-op nil
884 "Indicates the last recenter operation performed.
885Possible values: `top', `middle', `bottom'.")
886
887(defun recenter-top-bottom (&optional arg)
888 "Move current line to window center, top, and bottom, successively.
889With a prefix argument, this is the same as `recenter':
890 With numeric prefix ARG, move current line to window-line ARG.
891 With plain `C-u', move current line to window center.
892
893Otherwise move current line to window center on first call, and to
894top, middle, or bottom on successive calls.
895
896The starting position of the window determines the cycling order:
897 If initially in the top or middle third: top -> middle -> bottom.
898 If initially in the bottom third: bottom -> middle -> top.
899
900Top and bottom destinations are actually `scroll-conservatively' lines
901from true window top and bottom."
902 (interactive "P")
903 (cond
904 (arg (recenter arg)) ; Always respect ARG.
905 ((not (eq this-command last-command))
906 ;; First time - save mode and recenter.
907 (let ((bottom (1+ (count-lines 1 (window-end))))
908 (current (1+ (count-lines 1 (point))))
909 (total (window-height)))
910 (setq recenter-last-op 'middle)
911 (recenter)))
912 (t ;; repeat: loop through various options.
913 (setq recenter-last-op
914 (ecase recenter-last-op
915 (middle (recenter scroll-conservatively) 'top)
916 (top (recenter (1- (- scroll-conservatively))) 'bottom)
917 (bottom (recenter) 'middle))))))
918
919(define-key global-map [?\C-l] 'recenter-top-bottom)
882 920
883(defvar mouse-autoselect-window-timer nil 921(defvar mouse-autoselect-window-timer nil
884 "Timer used by delayed window autoselection.") 922 "Timer used by delayed window autoselection.")