Mercurial > hg > xemacs-beta
comparison lisp/modes/auto-show.el @ 155:43dd3413c7c7 r20-3b4
Import from CVS: tag r20-3b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:39:39 +0200 |
parents | ac2d302a0011 |
children | 85ec50267440 |
comparison
equal
deleted
inserted
replaced
154:94141801dd7e | 155:43dd3413c7c7 |
---|---|
1 ;;; auto-show.el --- perform automatic horizontal scrolling as point moves | 1 ;;; auto-show.el --- perform automatic horizontal scrolling as point moves |
2 ;;; This file is in the public domain. | |
3 | 2 |
4 ;;; Keywords: scroll display minor-mode | 3 ;; This file is in the public domain. |
5 ;;; Author: Pete Ware <ware@cis.ohio-state.edu> | 4 |
6 ;;; Modified by: Ben Wing <wing@666.com> | 5 ;; Author: Pete Ware <ware@cis.ohio-state.edu> |
7 ;;; Maintainer: FSF | 6 ;; Modified by: Ben Wing <wing@666.com> |
7 ;; Maintainer: XEmacs Development Team | |
8 ;; Keywords: extensions, internal | |
8 | 9 |
9 ;; This file is part of XEmacs. | 10 ;; This file is part of XEmacs. |
10 | 11 |
11 ;; XEmacs is free software; you can redistribute it and/or modify it | 12 ;; XEmacs is free software; you can redistribute it and/or modify it |
12 ;; under the terms of the GNU General Public License as published by | 13 ;; under the terms of the GNU General Public License as published by |
21 ;; You should have received a copy of the GNU General Public License | 22 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 23 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
24 ;; 02111-1307, USA. | 25 ;; 02111-1307, USA. |
25 | 26 |
26 ;;; Synched up with: FSF 19.34 (But starting to deviate). | 27 ;;; Synched up with: Emacs/Mule zeta. |
27 | 28 |
28 ;;; Commentary: | 29 ;;; Commentary: |
29 | 30 |
30 ;;; This file provides functions that | 31 ;; This file provides functions that |
31 ;;; automatically scroll the window horizontally when the point moves | 32 ;; automatically scroll the window horizontally when the point moves |
32 ;;; off the left or right side of the window. | 33 ;; off the left or right side of the window. |
33 | 34 |
34 ;;; Once this library is loaded, automatic horizontal scrolling | 35 ;; Once this library is loaded, automatic horizontal scrolling |
35 ;;; occurs whenever long lines are being truncated. | 36 ;; occurs whenever long lines are being truncated. |
36 ;;; To request truncation of long lines, set the variable | 37 ;; To request truncation of long lines, set the variable |
37 ;;; Setting the variable `truncate-lines' to non-nil. | 38 ;; Setting the variable `truncate-lines' to non-nil. |
38 ;;; You can do this for all buffers as follows: | 39 ;; You can do this for all buffers as follows: |
39 ;;; | 40 ;; |
40 ;;; (set-default 'truncate-lines t) | 41 ;; (set-default 'truncate-lines t) |
41 | 42 |
42 ;;; Here is how to do it for C mode only: | 43 ;; Here is how to do it for C mode only: |
43 ;;; | 44 ;; |
44 ;;; (set-default 'truncate-lines nil) ; this is the original value | 45 ;; (set-default 'truncate-lines nil) ; this is the original value |
45 ;;; (defun my-c-mode-hook () | 46 ;; (defun my-c-mode-hook () |
46 ;;; "Run when C-mode starts up. Changes ..." | 47 ;; "Run when C-mode starts up. Changes ..." |
47 ;;; ... set various personal preferences ... | 48 ;; ... set various personal preferences ... |
48 ;;; (setq truncate-lines t)) | 49 ;; (setq truncate-lines t)) |
49 ;;; (add-hook 'c-mode-hook 'my-c-mode-hook) | 50 ;; (add-hook 'c-mode-hook 'my-c-mode-hook) |
50 ;;; | 51 ;; |
51 ;;; | 52 ;; |
52 ;;; As a finer level of control, you can still have truncated lines but | 53 ;; As a finer level of control, you can still have truncated lines but |
53 ;;; without the automatic horizontal scrolling by setting the buffer | 54 ;; without the automatic horizontal scrolling by setting the buffer |
54 ;;; local variable `auto-show-mode' to nil. The default value is t. | 55 ;; local variable `auto-show-mode' to nil. The default value is t. |
55 ;;; The command `auto-show-mode' toggles the value of the variable | 56 ;; The command `auto-show-mode' toggles the value of the variable |
56 ;;; `auto-show-mode'. | 57 ;; `auto-show-mode'. |
57 | 58 |
58 ;;; Code: | 59 ;;; Code: |
59 | 60 |
60 (defvar auto-show-mode t | 61 (defvar auto-show-mode t |
61 "*Non-nil enables automatic horizontal scrolling, when lines are truncated. | 62 "*Non-nil enables automatic horizontal scrolling, when lines are truncated. |
62 The default value is t. To change the default, do this: | 63 The default value is t. To change the default, do this: |
63 (set-default 'auto-show-mode nil) | 64 (set-default 'auto-show-mode nil) |
64 See also command `auto-show-mode'. | 65 See also command `auto-show-mode'. |
65 This variable has no effect when lines are not being truncated.") | 66 This variable has no effect when lines are not being truncated. |
67 This variable is automatically local in each buffer where it is set.") | |
66 | 68 |
67 (make-variable-buffer-local 'auto-show-mode) | 69 (make-variable-buffer-local 'auto-show-mode) |
68 | 70 |
69 (defvar auto-show-shift-amount 8 | 71 (defvar auto-show-shift-amount 8 |
70 "*Extra columns to scroll. for automatic horizontal scrolling.") | 72 "*Extra columns to scroll. for automatic horizontal scrolling.") |
85 (specifier-instance right-margin-width)) | 87 (specifier-instance right-margin-width)) |
86 (frame-width))))) | 88 (frame-width))))) |
87 | 89 |
88 (defun auto-show-mode (arg) | 90 (defun auto-show-mode (arg) |
89 "Turn automatic horizontal scroll mode on or off. | 91 "Turn automatic horizontal scroll mode on or off. |
90 With arg, turn auto scrolling on if arg is positive, off otherwise." | 92 With arg, turn auto scrolling on if arg is positive, off otherwise. |
93 This mode is enabled or disabled for each buffer individually. | |
94 It takes effect only when `truncate-lines' is non-nil." | |
91 (interactive "P") | 95 (interactive "P") |
92 (setq auto-show-mode | 96 (setq auto-show-mode |
93 (if (null arg) | 97 (if (null arg) |
94 (not auto-show-mode) | 98 (not auto-show-mode) |
95 (> (prefix-numeric-value arg) 0)))) | 99 (> (prefix-numeric-value arg) 0)))) |
139 | 143 |
140 (defun auto-show-make-point-visible (&optional ignore-arg) | 144 (defun auto-show-make-point-visible (&optional ignore-arg) |
141 "Scroll horizontally to make point visible, if that is enabled. | 145 "Scroll horizontally to make point visible, if that is enabled. |
142 This function only does something if `auto-show-mode' is non-nil | 146 This function only does something if `auto-show-mode' is non-nil |
143 and longlines are being truncated in the selected window. | 147 and longlines are being truncated in the selected window. |
144 See also the command `auto-show-toggle'." | 148 See also the command `auto-show-mode'." |
145 (interactive) | 149 (interactive) |
146 ;; XEmacs change | 150 ;; XEmacs change |
147 (if (auto-show-should-take-action-p) | 151 (if (auto-show-should-take-action-p) |
148 (let* ((col (current-column)) ;column on line point is at | 152 (let* ((col (current-column)) ;column on line point is at |
149 (scroll (window-hscroll)) ;how far window is scrolled | 153 (scroll (window-hscroll)) ;how far window is scrolled |
175 ;; move point). | 179 ;; move point). |
176 ;; Do auto-scrolling after commands. | 180 ;; Do auto-scrolling after commands. |
177 ;;(add-hook 'post-command-hook 'auto-show-make-point-visible) | 181 ;;(add-hook 'post-command-hook 'auto-show-make-point-visible) |
178 | 182 |
179 ;; If being dumped, turn it on right away. | 183 ;; If being dumped, turn it on right away. |
180 (and (noninteractive) (auto-show-mode 1)) | 184 (when (boundp 'load-gc) |
185 (auto-show-mode 1)) | |
181 | 186 |
182 ;; Do auto-scrolling in comint buffers after process output also. | 187 ;; Do auto-scrolling in comint buffers after process output also. |
183 ; XEmacs -- don't do this now, it messes up comint. | 188 ; XEmacs -- don't do this now, it messes up comint. |
184 ;(add-hook 'comint-output-filter-functions 'auto-show-make-point-visible t) | 189 ;(add-hook 'comint-output-filter-functions 'auto-show-make-point-visible t) |
185 | 190 |
186 (provide 'auto-show) | 191 (provide 'auto-show) |
187 | 192 |
188 ;; auto-show.el ends here | 193 ;; auto-show.el ends here |
189 |