Mercurial > emacs
comparison lisp/simple.el @ 107875:b22d92cb789e
Move scrolling commands from simple.el to window.el
because their primitives are implemented in window.c.
* simple.el (scroll-error-top-bottom)
(scroll-up-command, scroll-down-command, scroll-up-line)
(scroll-down-line, scroll-other-window-down)
(beginning-of-buffer-other-window, end-of-buffer-other-window):
* window.el (scroll-error-top-bottom)
(scroll-up-command, scroll-down-command, scroll-up-line)
(scroll-down-line, scroll-other-window-down)
(beginning-of-buffer-other-window, end-of-buffer-other-window):
Move from simple.el to window.el because their primitives are
implemented in window.c.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Fri, 16 Apr 2010 04:41:58 +0300 |
parents | b97c55098dcc |
children | cede0252a395 |
comparison
equal
deleted
inserted
replaced
107874:b97c55098dcc | 107875:b22d92cb789e |
---|---|
4743 (visual-line-mode 1)) | 4743 (visual-line-mode 1)) |
4744 | 4744 |
4745 (define-globalized-minor-mode global-visual-line-mode | 4745 (define-globalized-minor-mode global-visual-line-mode |
4746 visual-line-mode turn-on-visual-line-mode | 4746 visual-line-mode turn-on-visual-line-mode |
4747 :lighter " vl") | 4747 :lighter " vl") |
4748 | 4748 |
4749 ;;; Scrolling commands. | |
4750 | |
4751 ;;; Scrolling commands which does not signal errors at top/bottom | |
4752 ;;; of buffer at first key-press (instead moves to top/bottom | |
4753 ;;; of buffer). | |
4754 | |
4755 (defcustom scroll-error-top-bottom nil | |
4756 "Move point to top/bottom of buffer before signalling a scrolling error. | |
4757 A value of nil means just signal an error if no more scrolling possible. | |
4758 A value of t means point moves to the beginning or the end of the buffer | |
4759 \(depending on scrolling direction) when no more scrolling possible. | |
4760 When point is already on that position, then signal an error." | |
4761 :type 'boolean | |
4762 :group 'scrolling | |
4763 :version "24.1") | |
4764 | |
4765 (defun scroll-up-command (&optional arg) | |
4766 "Scroll text of selected window upward ARG lines; or near full screen if no ARG. | |
4767 If `scroll-error-top-bottom' is non-nil and `scroll-up' cannot | |
4768 scroll window further, move cursor to the bottom line. | |
4769 When point is already on that position, then signal an error. | |
4770 A near full screen is `next-screen-context-lines' less than a full screen. | |
4771 Negative ARG means scroll downward. | |
4772 If ARG is the atom `-', scroll downward by nearly full screen." | |
4773 (interactive "^P") | |
4774 (cond | |
4775 ((null scroll-error-top-bottom) | |
4776 (scroll-up arg)) | |
4777 ((eq arg '-) | |
4778 (scroll-down-command nil)) | |
4779 ((< (prefix-numeric-value arg) 0) | |
4780 (scroll-down-command (- (prefix-numeric-value arg)))) | |
4781 ((eobp) | |
4782 (scroll-up arg)) ; signal error | |
4783 (t | |
4784 (condition-case nil | |
4785 (scroll-up arg) | |
4786 (end-of-buffer | |
4787 (if arg | |
4788 ;; When scrolling by ARG lines can't be done, | |
4789 ;; move by ARG lines instead. | |
4790 (forward-line arg) | |
4791 ;; When ARG is nil for full-screen scrolling, | |
4792 ;; move to the bottom of the buffer. | |
4793 (goto-char (point-max)))))))) | |
4794 | |
4795 (put 'scroll-up-command 'scroll-command t) | |
4796 | |
4797 (defun scroll-down-command (&optional arg) | |
4798 "Scroll text of selected window down ARG lines; or near full screen if no ARG. | |
4799 If `scroll-error-top-bottom' is non-nil and `scroll-down' cannot | |
4800 scroll window further, move cursor to the top line. | |
4801 When point is already on that position, then signal an error. | |
4802 A near full screen is `next-screen-context-lines' less than a full screen. | |
4803 Negative ARG means scroll upward. | |
4804 If ARG is the atom `-', scroll upward by nearly full screen." | |
4805 (interactive "^P") | |
4806 (cond | |
4807 ((null scroll-error-top-bottom) | |
4808 (scroll-down arg)) | |
4809 ((eq arg '-) | |
4810 (scroll-up-command nil)) | |
4811 ((< (prefix-numeric-value arg) 0) | |
4812 (scroll-up-command (- (prefix-numeric-value arg)))) | |
4813 ((bobp) | |
4814 (scroll-down arg)) ; signal error | |
4815 (t | |
4816 (condition-case nil | |
4817 (scroll-down arg) | |
4818 (beginning-of-buffer | |
4819 (if arg | |
4820 ;; When scrolling by ARG lines can't be done, | |
4821 ;; move by ARG lines instead. | |
4822 (forward-line (- arg)) | |
4823 ;; When ARG is nil for full-screen scrolling, | |
4824 ;; move to the top of the buffer. | |
4825 (goto-char (point-min)))))))) | |
4826 | |
4827 (put 'scroll-down-command 'scroll-command t) | |
4828 | |
4829 ;;; Scrolling commands which scroll a line instead of full screen. | |
4830 | |
4831 (defun scroll-up-line (&optional arg) | |
4832 "Scroll text of selected window upward ARG lines; or one line if no ARG. | |
4833 If ARG is omitted or nil, scroll upward by one line. | |
4834 This is different from `scroll-up-command' that scrolls a full screen." | |
4835 (interactive "p") | |
4836 (scroll-up (or arg 1))) | |
4837 | |
4838 (put 'scroll-up-line 'scroll-command t) | |
4839 | |
4840 (defun scroll-down-line (&optional arg) | |
4841 "Scroll text of selected window down ARG lines; or one line if no ARG. | |
4842 If ARG is omitted or nil, scroll down by one line. | |
4843 This is different from `scroll-down-command' that scrolls a full screen." | |
4844 (interactive "p") | |
4845 (scroll-down (or arg 1))) | |
4846 | |
4847 (put 'scroll-down-line 'scroll-command t) | |
4848 | |
4849 | |
4850 (defun scroll-other-window-down (lines) | |
4851 "Scroll the \"other window\" down. | |
4852 For more details, see the documentation for `scroll-other-window'." | |
4853 (interactive "P") | |
4854 (scroll-other-window | |
4855 ;; Just invert the argument's meaning. | |
4856 ;; We can do that without knowing which window it will be. | |
4857 (if (eq lines '-) nil | |
4858 (if (null lines) '- | |
4859 (- (prefix-numeric-value lines)))))) | |
4860 | |
4861 (defun beginning-of-buffer-other-window (arg) | |
4862 "Move point to the beginning of the buffer in the other window. | |
4863 Leave mark at previous position. | |
4864 With arg N, put point N/10 of the way from the true beginning." | |
4865 (interactive "P") | |
4866 (let ((orig-window (selected-window)) | |
4867 (window (other-window-for-scrolling))) | |
4868 ;; We use unwind-protect rather than save-window-excursion | |
4869 ;; because the latter would preserve the things we want to change. | |
4870 (unwind-protect | |
4871 (progn | |
4872 (select-window window) | |
4873 ;; Set point and mark in that window's buffer. | |
4874 (with-no-warnings | |
4875 (beginning-of-buffer arg)) | |
4876 ;; Set point accordingly. | |
4877 (recenter '(t))) | |
4878 (select-window orig-window)))) | |
4879 | |
4880 (defun end-of-buffer-other-window (arg) | |
4881 "Move point to the end of the buffer in the other window. | |
4882 Leave mark at previous position. | |
4883 With arg N, put point N/10 of the way from the true end." | |
4884 (interactive "P") | |
4885 ;; See beginning-of-buffer-other-window for comments. | |
4886 (let ((orig-window (selected-window)) | |
4887 (window (other-window-for-scrolling))) | |
4888 (unwind-protect | |
4889 (progn | |
4890 (select-window window) | |
4891 (with-no-warnings | |
4892 (end-of-buffer arg)) | |
4893 (recenter '(t))) | |
4894 (select-window orig-window)))) | |
4895 | 4749 |
4896 (defun transpose-chars (arg) | 4750 (defun transpose-chars (arg) |
4897 "Interchange characters around point, moving forward one character. | 4751 "Interchange characters around point, moving forward one character. |
4898 With prefix arg ARG, effect is to take character before point | 4752 With prefix arg ARG, effect is to take character before point |
4899 and drag it forward past ARG other characters (backward if ARG negative). | 4753 and drag it forward past ARG other characters (backward if ARG negative). |