Mercurial > hg > xemacs-beta
comparison lisp/emulators/tpu-extras.el @ 4:b82b59fe008d r19-15b3
Import from CVS: tag r19-15b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:56 +0200 |
parents | 376386a54a3c |
children | 131b0175ea99 |
comparison
equal
deleted
inserted
replaced
3:30df88044ec6 | 4:b82b59fe008d |
---|---|
1 ;;; tpu-extras.el --- Scroll margins and free cursor mode for TPU-edt | 1 ;;; tpu-extras.el --- Scroll margins and free cursor mode for TPU-edt |
2 | 2 |
3 ;; Copyright (C) 1993 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Rob Riepel <riepel@networking.stanford.edu> | 5 ;; Author: Rob Riepel <riepel@networking.stanford.edu> |
6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> | 6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu> |
7 ;; Keywords: emulations | 7 ;; Keywords: emulations |
8 | 8 |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 ;; General Public License for more details. | 19 ;; General Public License for more details. |
20 | 20 |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; 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 | 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
23 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
24 ;; 02111-1307, USA. | |
25 | |
26 ;;; Synched up with: FSF 19.34 | |
24 | 27 |
25 ;;; Commentary: | 28 ;;; Commentary: |
29 | |
30 ;; Use the functions defined here to customize TPU-edt to your tastes by | |
31 ;; setting scroll margins and/or turning on free cursor mode. Here's an | |
32 ;; example for your .emacs file. | |
33 | |
34 ;; (tpu-set-cursor-free) ; Set cursor free. | |
35 ;; (tpu-set-scroll-margins "10%" "15%") ; Set scroll margins. | |
36 | |
37 ;; Scroll margins and cursor binding can be changed from within emacs using | |
38 ;; the following commands: | |
39 | |
40 ;; tpu-set-scroll-margins or set scroll margins | |
41 ;; tpu-set-cursor-bound or set cursor bound | |
42 ;; tpu-set-cursor-free or set cursor free | |
43 | |
44 ;; Additionally, Gold-F toggles between bound and free cursor modes. | |
45 | |
46 ;; Note that switching out of free cursor mode or exiting TPU-edt while in | |
47 ;; free cursor mode strips trailing whitespace from every line in the file. | |
48 | |
49 | |
50 ;;; Details: | |
26 | 51 |
27 ;; The functions contained in this file implement scroll margins and free | 52 ;; The functions contained in this file implement scroll margins and free |
28 ;; cursor mode. The following keys and commands are affected. | 53 ;; cursor mode. The following keys and commands are affected. |
29 | 54 |
30 ;; key/command function scroll cursor | 55 ;; key/command function scroll cursor |
65 ;; for their normal operation and part of the display function. There | 90 ;; for their normal operation and part of the display function. There |
66 ;; is a possibility that this display overhead could adversely affect the | 91 ;; is a possibility that this display overhead could adversely affect the |
67 ;; performance of TPU-edt on slower computers. In order to support the | 92 ;; performance of TPU-edt on slower computers. In order to support the |
68 ;; widest range of computers, scroll margin support is optional. | 93 ;; widest range of computers, scroll margin support is optional. |
69 | 94 |
70 ;; I don't know for a fact that the overhead associated with scroll | 95 ;; It's actually not known whether the overhead associated with scroll |
71 ;; margin support is significant. If you find that it is, please send me | 96 ;; margin support is significant. If you find that it is, please send |
72 ;; a note describing the extent of the performance degradation. Be sure | 97 ;; a note describing the extent of the performance degradation. Be sure |
73 ;; to include a description of the platform where you're running TPU-edt. | 98 ;; to include a description of the platform where you're running TPU-edt. |
74 ;; Send your note to the address provided by Gold-V. | 99 ;; Send your note to the address provided by Gold-V. |
75 | 100 |
76 ;; Even with these differences and limitations, these functions implement | 101 ;; Even with these differences and limitations, these functions implement |
77 ;; important aspects of the real TPU/edt. Those who miss free cursor mode | 102 ;; important aspects of the real TPU/edt. Those who miss free cursor mode |
78 ;; and/or scroll margins will appreciate these implementations. | 103 ;; and/or scroll margins will appreciate these implementations. |
79 | 104 |
80 ;;; Usage: | 105 ;; NOTE: There was a very old tpu-edt in XEmacs 19.14 so I deleted it and |
81 | 106 ;; replaced it with the one in Emacs 19.34. -sb |
82 ;; To use this file, simply load it after loading TPU-edt. After that, | |
83 ;; customize TPU-edt to your tastes by setting scroll margins and/or | |
84 ;; turning on free cursor mode. Here's an example for your .emacs file. | |
85 | |
86 ;; (load "tpu-edt") ; Load the base TPU-edt | |
87 ;; (load "tpu-extras") ; and the extras. | |
88 ;; (tpu-set-scroll-margins "10%" "15%") ; Set scroll margins. | |
89 | |
90 ;; Once the extras are loaded, scroll margins and cursor binding can be | |
91 ;; changed with the following commands: | |
92 | |
93 ;; tpu-set-scroll-margins or set scroll margins | |
94 ;; tpu-set-cursor-bound or set cursor bound | |
95 ;; tpu-set-cursor-free or set cursor free | |
96 | |
97 ;; Additionally, Gold-F toggles between bound and free cursor modes. | |
98 | |
99 ;; Note that switching out of free cursor mode or exiting TPU-edt while in | |
100 ;; free cursor mode strips trailing whitespace from every line in the file. | |
101 | 107 |
102 ;;; Code: | 108 ;;; Code: |
103 | 109 |
104 | 110 |
105 ;;; Revision Information | 111 ;;; Gotta have tpu-edt |
106 | 112 |
107 (defconst tpu-extras-revision "!Revision: 1.6 !" | 113 (require 'tpu-edt) |
108 "Revision number of the TPU-edt extras.") | |
109 | 114 |
110 | 115 |
111 ;;; Customization variables | 116 ;;; Customization variables |
112 | 117 |
113 (defconst tpu-top-scroll-margin 0 | 118 (defconst tpu-top-scroll-margin 0 |
130 | 135 |
131 | 136 |
132 ;;; Hooks -- Set cursor free in picture mode. | 137 ;;; Hooks -- Set cursor free in picture mode. |
133 ;;; Clean up when writing a file from cursor free mode. | 138 ;;; Clean up when writing a file from cursor free mode. |
134 | 139 |
135 (if tpu-gnu-emacs18-p | 140 (add-hook 'picture-mode-hook 'tpu-set-cursor-free) |
136 (or (memq 'tpu-set-cursor-free edit-picture-hook) | |
137 (setq edit-picture-hook | |
138 (cons 'tpu-set-cursor-free edit-picture-hook))) | |
139 (add-hook 'picture-mode-hook 'tpu-set-cursor-free)) | |
140 | 141 |
141 (defun tpu-write-file-hook nil | 142 (defun tpu-write-file-hook nil |
142 "Eliminate whitespace at ends of lines, if the cursor is free." | 143 "Eliminate whitespace at ends of lines, if the cursor is free." |
143 (if (and (buffer-modified-p) tpu-cursor-free) (picture-clean))) | 144 (if (and (buffer-modified-p) tpu-cursor-free) (picture-clean))) |
144 | 145 |
262 (defun tpu-backward-line (num) | 263 (defun tpu-backward-line (num) |
263 "Move to beginning of previous line. | 264 "Move to beginning of previous line. |
264 Prefix argument serves as repeat count." | 265 Prefix argument serves as repeat count." |
265 (interactive "p") | 266 (interactive "p") |
266 (let ((beg (tpu-current-line))) | 267 (let ((beg (tpu-current-line))) |
268 (or (bolp) (>= 0 num) (setq num (- num 1))) | |
267 (next-line-internal (- num)) | 269 (next-line-internal (- num)) |
268 (tpu-top-check beg num) | 270 (tpu-top-check beg num) |
269 (beginning-of-line))) | 271 (beginning-of-line))) |
270 | 272 |
271 | 273 |
426 (tpu-bottom-check beg 1))) | 428 (tpu-bottom-check beg 1))) |
427 | 429 |
428 | 430 |
429 ;;; Function to set scroll margins | 431 ;;; Function to set scroll margins |
430 | 432 |
431 ;;;jwz: don't autoload this by default ###autoload | 433 ;;;###autoload |
432 (defun tpu-set-scroll-margins (top bottom) | 434 (defun tpu-set-scroll-margins (top bottom) |
433 "Set scroll margins." | 435 "Set scroll margins." |
434 (interactive | 436 (interactive |
435 "sEnter top scroll margin (N lines or N%% or RETURN for current value): \ | 437 "sEnter top scroll margin (N lines or N%% or RETURN for current value): \ |
436 \nsEnter bottom scroll margin (N lines or N%% or RETURN for current value): ") | 438 \nsEnter bottom scroll margin (N lines or N%% or RETURN for current value): ") |
454 tpu-top-scroll-margin tpu-bottom-scroll-margin))) | 456 tpu-top-scroll-margin tpu-bottom-scroll-margin))) |
455 | 457 |
456 | 458 |
457 ;;; Functions to set cursor bound or free | 459 ;;; Functions to set cursor bound or free |
458 | 460 |
459 ;;;jwz: don't autoload this by default ###autoload | 461 ;;;###autoload |
460 (defun tpu-set-cursor-free nil | 462 (defun tpu-set-cursor-free nil |
461 "Allow the cursor to move freely about the screen." | 463 "Allow the cursor to move freely about the screen." |
462 (interactive) | 464 (interactive) |
463 (setq tpu-cursor-free t) | 465 (setq tpu-cursor-free t) |
464 (substitute-key-definition 'tpu-set-cursor-free | 466 (substitute-key-definition 'tpu-set-cursor-free |
465 'tpu-set-cursor-bound | 467 'tpu-set-cursor-bound |
466 GOLD-map) | 468 GOLD-map) |
467 (message "The cursor will now move freely about the screen.")) | 469 (message "The cursor will now move freely about the screen.")) |
468 | 470 |
469 ;;;jwz: don't autoload this by default ###autoload | 471 ;;;###autoload |
470 (defun tpu-set-cursor-bound nil | 472 (defun tpu-set-cursor-bound nil |
471 "Constrain the cursor to the flow of the text." | 473 "Constrain the cursor to the flow of the text." |
472 (interactive) | 474 (interactive) |
473 (picture-clean) | 475 (picture-clean) |
474 (setq tpu-cursor-free nil) | 476 (setq tpu-cursor-free nil) |