diff options
| author | Juri Linkov | 2010-04-06 02:38:53 +0300 |
|---|---|---|
| committer | Juri Linkov | 2010-04-06 02:38:53 +0300 |
| commit | 79ce172a464f2d5cced69f97fd86c4e03a0876a9 (patch) | |
| tree | f7347b58dd13fcc423f8b006bb39fe2219892393 /lisp | |
| parent | 6460e5342cb08578eb2fd22b086373bbc12a11d0 (diff) | |
| download | emacs-79ce172a464f2d5cced69f97fd86c4e03a0876a9.tar.gz emacs-79ce172a464f2d5cced69f97fd86c4e03a0876a9.zip | |
Scrolling commands which does not signal errors at top/bottom.
http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01452.html
* simple.el (scroll-up-command, scroll-down-command): New commands.
Put property isearch-scroll=t on them.
* bindings.el (global-map): Rebind [prior] from `scroll-down' to
`scroll-down-command' and [next] from `scroll-up' to
`scroll-up-command'.
* emulation/cua-base.el: Put property CUA=move on
`scroll-up-command' and `scroll-down-command'.
(cua--init-keymaps): Remap `scroll-up-command' to `cua-scroll-up'
and `scroll-down-command' to `cua-scroll-down'.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 17 | ||||
| -rw-r--r-- | lisp/bindings.el | 4 | ||||
| -rw-r--r-- | lisp/emulation/cua-base.el | 3 | ||||
| -rw-r--r-- | lisp/simple.el | 63 |
4 files changed, 85 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 69e20017750..f343754e3d2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2010-04-05 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | Scrolling commands which does not signal errors at top/bottom. | ||
| 4 | http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01452.html | ||
| 5 | |||
| 6 | * simple.el (scroll-up-command, scroll-down-command): New commands. | ||
| 7 | Put property isearch-scroll=t on them. | ||
| 8 | |||
| 9 | * bindings.el (global-map): Rebind [prior] from `scroll-down' to | ||
| 10 | `scroll-down-command' and [next] from `scroll-up' to | ||
| 11 | `scroll-up-command'. | ||
| 12 | |||
| 13 | * emulation/cua-base.el: Put property CUA=move on | ||
| 14 | `scroll-up-command' and `scroll-down-command'. | ||
| 15 | (cua--init-keymaps): Remap `scroll-up-command' to `cua-scroll-up' | ||
| 16 | and `scroll-down-command' to `cua-scroll-down'. | ||
| 17 | |||
| 1 | 2010-04-05 Juanma Barranquero <lekktu@gmail.com> | 18 | 2010-04-05 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 19 | ||
| 3 | * help.el (describe-mode): Return nil. | 20 | * help.el (describe-mode): Return nil. |
diff --git a/lisp/bindings.el b/lisp/bindings.el index 37ca3b86055..a7f6643b2db 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -873,8 +873,8 @@ or \\[semantic-mode]"))))) | |||
| 873 | (define-key global-map [up] 'previous-line) | 873 | (define-key global-map [up] 'previous-line) |
| 874 | (define-key global-map [right] 'forward-char) | 874 | (define-key global-map [right] 'forward-char) |
| 875 | (define-key global-map [down] 'next-line) | 875 | (define-key global-map [down] 'next-line) |
| 876 | (define-key global-map [prior] 'scroll-down) | 876 | (define-key global-map [prior] 'scroll-down-command) |
| 877 | (define-key global-map [next] 'scroll-up) | 877 | (define-key global-map [next] 'scroll-up-command) |
| 878 | (define-key global-map [C-up] 'backward-paragraph) | 878 | (define-key global-map [C-up] 'backward-paragraph) |
| 879 | (define-key global-map [C-down] 'forward-paragraph) | 879 | (define-key global-map [C-down] 'forward-paragraph) |
| 880 | (define-key global-map [C-prior] 'scroll-right) | 880 | (define-key global-map [C-prior] 'scroll-right) |
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 57ea683a1ff..39d3ff785ce 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el | |||
| @@ -1440,6 +1440,8 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1440 | ;; scrolling | 1440 | ;; scrolling |
| 1441 | (define-key cua-global-keymap [remap scroll-up] 'cua-scroll-up) | 1441 | (define-key cua-global-keymap [remap scroll-up] 'cua-scroll-up) |
| 1442 | (define-key cua-global-keymap [remap scroll-down] 'cua-scroll-down) | 1442 | (define-key cua-global-keymap [remap scroll-down] 'cua-scroll-down) |
| 1443 | (define-key cua-global-keymap [remap scroll-up-command] 'cua-scroll-up) | ||
| 1444 | (define-key cua-global-keymap [remap scroll-down-command] 'cua-scroll-down) | ||
| 1443 | 1445 | ||
| 1444 | (define-key cua--cua-keys-keymap [(control x) timeout] 'kill-region) | 1446 | (define-key cua--cua-keys-keymap [(control x) timeout] 'kill-region) |
| 1445 | (define-key cua--cua-keys-keymap [(control c) timeout] 'copy-region-as-kill) | 1447 | (define-key cua--cua-keys-keymap [(control c) timeout] 'copy-region-as-kill) |
| @@ -1499,6 +1501,7 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1499 | move-end-of-line move-beginning-of-line | 1501 | move-end-of-line move-beginning-of-line |
| 1500 | end-of-buffer beginning-of-buffer | 1502 | end-of-buffer beginning-of-buffer |
| 1501 | scroll-up scroll-down | 1503 | scroll-up scroll-down |
| 1504 | scroll-up-command scroll-down-command | ||
| 1502 | up-list down-list backward-up-list | 1505 | up-list down-list backward-up-list |
| 1503 | end-of-defun beginning-of-defun | 1506 | end-of-defun beginning-of-defun |
| 1504 | forward-sexp backward-sexp | 1507 | forward-sexp backward-sexp |
diff --git a/lisp/simple.el b/lisp/simple.el index 73138111cfe..7616d19057a 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -4738,6 +4738,69 @@ This also turns on `word-wrap' in the buffer." | |||
| 4738 | visual-line-mode turn-on-visual-line-mode | 4738 | visual-line-mode turn-on-visual-line-mode |
| 4739 | :lighter " vl") | 4739 | :lighter " vl") |
| 4740 | 4740 | ||
| 4741 | ;;; Scrolling commands. | ||
| 4742 | |||
| 4743 | ;;; Scrolling commands which does not signal errors at top/bottom | ||
| 4744 | ;;; of buffer at first key-press (instead moves to top/bottom | ||
| 4745 | ;;; of buffer). | ||
| 4746 | |||
| 4747 | (defun scroll-up-command (&optional arg) | ||
| 4748 | "Scroll text of selected window upward ARG lines; or near full screen if no ARG. | ||
| 4749 | If `scroll-up' cannot scroll window further, move cursor to the bottom line. | ||
| 4750 | When point is already on that position, then signal an error. | ||
| 4751 | A near full screen is `next-screen-context-lines' less than a full screen. | ||
| 4752 | Negative ARG means scroll downward. | ||
| 4753 | If ARG is the atom `-', scroll downward by nearly full screen." | ||
| 4754 | (interactive "^P") | ||
| 4755 | (cond | ||
| 4756 | ((eq arg '-) (scroll-down-command nil)) | ||
| 4757 | ((< (prefix-numeric-value arg) 0) | ||
| 4758 | (scroll-down-command (- (prefix-numeric-value arg)))) | ||
| 4759 | ((eobp) | ||
| 4760 | (scroll-up arg)) ; signal error | ||
| 4761 | (t | ||
| 4762 | (condition-case nil | ||
| 4763 | (scroll-up arg) | ||
| 4764 | (end-of-buffer | ||
| 4765 | (if arg | ||
| 4766 | ;; When scrolling by ARG lines can't be done, | ||
| 4767 | ;; move by ARG lines instead. | ||
| 4768 | (forward-line arg) | ||
| 4769 | ;; When ARG is nil for full-screen scrolling, | ||
| 4770 | ;; move to the bottom of the buffer. | ||
| 4771 | (goto-char (point-max)))))))) | ||
| 4772 | |||
| 4773 | (put 'scroll-up-command 'isearch-scroll t) | ||
| 4774 | |||
| 4775 | (defun scroll-down-command (&optional arg) | ||
| 4776 | "Scroll text of selected window down ARG lines; or near full screen if no ARG. | ||
| 4777 | If `scroll-down' cannot scroll window further, move cursor to the top line. | ||
| 4778 | When point is already on that position, then signal an error. | ||
| 4779 | A near full screen is `next-screen-context-lines' less than a full screen. | ||
| 4780 | Negative ARG means scroll upward. | ||
| 4781 | If ARG is the atom `-', scroll upward by nearly full screen." | ||
| 4782 | (interactive "^P") | ||
| 4783 | (cond | ||
| 4784 | ((eq arg '-) (scroll-up-command nil)) | ||
| 4785 | ((< (prefix-numeric-value arg) 0) | ||
| 4786 | (scroll-up-command (- (prefix-numeric-value arg)))) | ||
| 4787 | ((bobp) | ||
| 4788 | (scroll-down arg)) ; signal error | ||
| 4789 | (t | ||
| 4790 | (condition-case nil | ||
| 4791 | (scroll-down arg) | ||
| 4792 | (beginning-of-buffer | ||
| 4793 | (if arg | ||
| 4794 | ;; When scrolling by ARG lines can't be done, | ||
| 4795 | ;; move by ARG lines instead. | ||
| 4796 | (forward-line (- arg)) | ||
| 4797 | ;; When ARG is nil for full-screen scrolling, | ||
| 4798 | ;; move to the top of the buffer. | ||
| 4799 | (goto-char (point-min)))))))) | ||
| 4800 | |||
| 4801 | (put 'scroll-down-command 'isearch-scroll t) | ||
| 4802 | |||
| 4803 | |||
| 4741 | (defun scroll-other-window-down (lines) | 4804 | (defun scroll-other-window-down (lines) |
| 4742 | "Scroll the \"other window\" down. | 4805 | "Scroll the \"other window\" down. |
| 4743 | For more details, see the documentation for `scroll-other-window'." | 4806 | For more details, see the documentation for `scroll-other-window'." |