Mercurial > hg > xemacs-beta
comparison lisp/emulators/ws-mode.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | b82b59fe008d |
children | b9518feda344 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
1 ;;; ws-mode.el --- WordStar emulation mode for GNU Emacs | 1 ;;; ws-mode.el --- WordStar emulation mode for GNU Emacs |
2 | 2 |
3 ;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de> | |
4 ;; Created: 13 Feb 1991 | |
5 ;; Version: 0.7 | |
6 | |
3 ;; Copyright (C) 1991 Free Software Foundation, Inc. | 7 ;; Copyright (C) 1991 Free Software Foundation, Inc. |
4 | 8 |
5 ;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de> | 9 ;; This file is distributed in the hope that it will be useful, |
6 ;; Version: 0.7 | 10 ;; but WITHOUT ANY WARRANTY. No author or distributor |
7 ;; Keywords: emulations | 11 ;; accepts responsibility to anyone for the consequences of using it |
8 | 12 ;; or for whether it serves any particular purpose or works at all, |
9 ;; This file is part of XEmacs. | 13 ;; unless he says so in writing. Refer to the GNU Emacs General Public |
10 | 14 ;; License for full details. |
11 ;; XEmacs is free software; you can redistribute it and/or modify it | 15 |
12 ;; under the terms of the GNU General Public License as published by | 16 ;; Everyone is granted permission to copy, modify and redistribute |
13 ;; the Free Software Foundation; either version 2, or (at your option) | 17 ;; this file, but only under the conditions described in the |
14 ;; any later version. | 18 ;; GNU Emacs General Public License. A copy of this license is |
15 | 19 ;; supposed to have been given to you along with GNU Emacs so you |
16 ;; XEmacs is distributed in the hope that it will be useful, but | 20 ;; can know your rights and responsibilities. It should be in a |
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | 21 ;; file named COPYING. Among other things, the copyright notice |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 22 ;; and this notice must be preserved on all copies. |
19 ;; General Public License for more details. | 23 |
20 | 24 |
21 ;; You should have received a copy of the GNU General Public License | 25 ;; How to install ws-mode.el: |
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 26 ;; |
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 27 ;; either you |
24 ;; 02111-1307, USA. | 28 ;; put the following line into your default.el (usually |
25 | 29 ;; /usr/local/emacs/lisp/default.el): |
26 ;;; Synched up with: FSF 19.34 | 30 ;; (autoload 'wordstar-mode "ws-mode.el" "WordStar emulation mode." t) |
27 | 31 ;; put ws-mode.el into a directory in your Emacs load-path (usually |
28 ;;; Commentary: | 32 ;; /usr/local/emacs/local/lisp). |
29 | 33 ;; |
30 ;; This emulates WordStar, with a major mode. | 34 ;; or you |
31 | 35 ;; put ws-mode.el into your directory $HOME/lib/emacs (or something |
32 ;;; Code: | 36 ;; like that) |
37 ;; put the following two lines into your file $HOME/.emacs | |
38 ;; (autoload 'wordstar-mode (expand-file-name "~/lib/emacs/ws-mode.el") | |
39 ;; "WordStar emulation mode." t) | |
40 ;; | |
41 ;; You can then invoke wordstar-mode for a buffer by typing | |
42 ;; M-x wordstar-mode | |
43 ;; | |
44 ;; If you want to use Emacs in wordstar-mode by default, put the | |
45 ;; following line in addition into your file $HOME/.emacs : | |
46 ;; (setq default-major-mode 'wordstar-mode) | |
47 ;; | |
48 ;; If you want to use Emacs *always* in wordstar-mode, even when the | |
49 ;; file type would indicate another mode, put the follwoing line in | |
50 ;; addition into your file $HOME/.emacs : | |
51 ;; (setq auto-mode-alist nil) | |
52 ;; | |
53 ;; Enjoy! | |
54 | |
55 | |
56 | |
57 (defun wordstar-mode () | |
58 "Major mode with WordStar-like key bindings. | |
59 | |
60 BUGS: | |
61 - Help menus with WordStar commands (C-j just calls help-for-help) | |
62 are not implemented | |
63 - Options for search and replace | |
64 - Show markers (C-k h) is somewhat strange | |
65 - Search and replace (C-q a) is only available in forward direction | |
66 | |
67 No key bindings beginning with ESC are installed, they will work | |
68 Emacs-like. | |
69 | |
70 The key bindings are: | |
71 | |
72 C-a backward-word | |
73 C-b fill-paragraph | |
74 C-c scroll-up-line | |
75 C-d forward-char | |
76 C-e previous-line | |
77 C-f forward-word | |
78 C-g delete-char | |
79 C-h backward-char | |
80 C-i indent-for-tab-command | |
81 C-j help-for-help | |
82 C-k ordstar-C-k-map | |
83 C-l ws-repeat-search | |
84 C-n open-line | |
85 C-p quoted-insert | |
86 C-r scroll-down-line | |
87 C-s backward-char | |
88 C-t kill-word | |
89 C-u keyboard-quit | |
90 C-v overwrite-mode | |
91 C-w scroll-down | |
92 C-x next-line | |
93 C-y kill-complete-line | |
94 C-z scroll-up | |
95 | |
96 C-k 0 ws-set-marker-0 | |
97 C-k 1 ws-set-marker-1 | |
98 C-k 2 ws-set-marker-2 | |
99 C-k 3 ws-set-marker-3 | |
100 C-k 4 ws-set-marker-4 | |
101 C-k 5 ws-set-marker-5 | |
102 C-k 6 ws-set-marker-6 | |
103 C-k 7 ws-set-marker-7 | |
104 C-k 8 ws-set-marker-8 | |
105 C-k 9 ws-set-marker-9 | |
106 C-k b ws-begin-block | |
107 C-k c ws-copy-block | |
108 C-k d save-buffers-kill-emacs | |
109 C-k f find-file | |
110 C-k h ws-show-markers | |
111 C-k i ws-indent-block | |
112 C-k k ws-end-block | |
113 C-k p ws-print-block | |
114 C-k q kill-emacs | |
115 C-k r insert-file | |
116 C-k s save-some-buffers | |
117 C-k t ws-mark-word | |
118 C-k u ws-exdent-block | |
119 C-k C-u keyboard-quit | |
120 C-k v ws-move-block | |
121 C-k w ws-write-block | |
122 C-k x kill-emacs | |
123 C-k y ws-delete-block | |
124 | |
125 C-o c center-line | |
126 C-o b switch-to-buffer | |
127 C-o j justify-current-line | |
128 C-o k kill-buffer | |
129 C-o l list-buffers | |
130 C-o m auto-fill-mode | |
131 C-o r set-fill-column | |
132 C-o C-u keyboard-quit | |
133 C-o wd delete-other-windows | |
134 C-o wh split-window-horizontally | |
135 C-o wo other-window | |
136 C-o wv split-window-vertically | |
137 | |
138 C-q 0 ws-find-marker-0 | |
139 C-q 1 ws-find-marker-1 | |
140 C-q 2 ws-find-marker-2 | |
141 C-q 3 ws-find-marker-3 | |
142 C-q 4 ws-find-marker-4 | |
143 C-q 5 ws-find-marker-5 | |
144 C-q 6 ws-find-marker-6 | |
145 C-q 7 ws-find-marker-7 | |
146 C-q 8 ws-find-marker-8 | |
147 C-q 9 ws-find-marker-9 | |
148 C-q a ws-query-replace | |
149 C-q b ws-to-block-begin | |
150 C-q c end-of-buffer | |
151 C-q d end-of-line | |
152 C-q f ws-search | |
153 C-q k ws-to-block-end | |
154 C-q l ws-undo | |
155 C-q p ws-last-cursorp | |
156 C-q r beginning-of-buffer | |
157 C-q C-u keyboard-quit | |
158 C-q w ws-last-error | |
159 C-q y ws-kill-eol | |
160 C-q DEL ws-kill-bol | |
161 " | |
162 (interactive) | |
163 (kill-all-local-variables) | |
164 (use-local-map wordstar-mode-map) | |
165 (setq mode-name "WordStar") | |
166 (setq major-mode 'wordstar-mode)) | |
33 | 167 |
34 (defvar wordstar-mode-map nil "") | 168 (defvar wordstar-mode-map nil "") |
35 (defvar wordstar-C-j-map nil "") | 169 (defvar wordstar-C-j-map nil "") |
36 (defvar wordstar-C-k-map nil "") | 170 (defvar wordstar-C-k-map nil "") |
37 (defvar wordstar-C-o-map nil "") | 171 (defvar wordstar-C-o-map nil "") |
122 ;; wordstar-C-j-map not yet implemented | 256 ;; wordstar-C-j-map not yet implemented |
123 | 257 |
124 ;; wordstar-C-o-map | 258 ;; wordstar-C-o-map |
125 | 259 |
126 (define-key wordstar-C-o-map " " ()) | 260 (define-key wordstar-C-o-map " " ()) |
127 (define-key wordstar-C-o-map "c" 'wordstar-center-line) | 261 (define-key wordstar-C-o-map "c" 'center-line) |
128 (define-key wordstar-C-o-map "\C-c" 'wordstar-center-line) | 262 (define-key wordstar-C-o-map "\C-c" 'center-line) |
129 (define-key wordstar-C-o-map "b" 'switch-to-buffer) | 263 (define-key wordstar-C-o-map "b" 'switch-to-buffer) |
130 (define-key wordstar-C-o-map "\C-b" 'switch-to-buffer) | 264 (define-key wordstar-C-o-map "\C-b" 'switch-to-buffer) |
131 (define-key wordstar-C-o-map "j" 'justify-current-line) | 265 (define-key wordstar-C-o-map "j" 'justify-current-line) |
132 (define-key wordstar-C-o-map "\C-j" 'justify-current-line) | 266 (define-key wordstar-C-o-map "\C-j" 'justify-current-line) |
133 (define-key wordstar-C-o-map "k" 'kill-buffer) | 267 (define-key wordstar-C-o-map "k" 'kill-buffer) |
181 (define-key wordstar-C-q-map "\C-w" 'ws-last-error) | 315 (define-key wordstar-C-q-map "\C-w" 'ws-last-error) |
182 (define-key wordstar-C-q-map "y" 'ws-kill-eol) | 316 (define-key wordstar-C-q-map "y" 'ws-kill-eol) |
183 (define-key wordstar-C-q-map "\C-y" 'ws-kill-eol) | 317 (define-key wordstar-C-q-map "\C-y" 'ws-kill-eol) |
184 (define-key wordstar-C-q-map "\177" 'ws-kill-bol)) | 318 (define-key wordstar-C-q-map "\177" 'ws-kill-bol)) |
185 | 319 |
186 ;;;###autoload | 320 |
187 (defun wordstar-mode () | 321 (defun center-paragraph () |
188 "Major mode with WordStar-like key bindings. | |
189 | |
190 BUGS: | |
191 - Help menus with WordStar commands (C-j just calls help-for-help) | |
192 are not implemented | |
193 - Options for search and replace | |
194 - Show markers (C-k h) is somewhat strange | |
195 - Search and replace (C-q a) is only available in forward direction | |
196 | |
197 No key bindings beginning with ESC are installed, they will work | |
198 Emacs-like. | |
199 | |
200 The key bindings are: | |
201 | |
202 C-a backward-word | |
203 C-b fill-paragraph | |
204 C-c scroll-up-line | |
205 C-d forward-char | |
206 C-e previous-line | |
207 C-f forward-word | |
208 C-g delete-char | |
209 C-h backward-char | |
210 C-i indent-for-tab-command | |
211 C-j help-for-help | |
212 C-k ordstar-C-k-map | |
213 C-l ws-repeat-search | |
214 C-n open-line | |
215 C-p quoted-insert | |
216 C-r scroll-down-line | |
217 C-s backward-char | |
218 C-t kill-word | |
219 C-u keyboard-quit | |
220 C-v overwrite-mode | |
221 C-w scroll-down | |
222 C-x next-line | |
223 C-y kill-complete-line | |
224 C-z scroll-up | |
225 | |
226 C-k 0 ws-set-marker-0 | |
227 C-k 1 ws-set-marker-1 | |
228 C-k 2 ws-set-marker-2 | |
229 C-k 3 ws-set-marker-3 | |
230 C-k 4 ws-set-marker-4 | |
231 C-k 5 ws-set-marker-5 | |
232 C-k 6 ws-set-marker-6 | |
233 C-k 7 ws-set-marker-7 | |
234 C-k 8 ws-set-marker-8 | |
235 C-k 9 ws-set-marker-9 | |
236 C-k b ws-begin-block | |
237 C-k c ws-copy-block | |
238 C-k d save-buffers-kill-emacs | |
239 C-k f find-file | |
240 C-k h ws-show-markers | |
241 C-k i ws-indent-block | |
242 C-k k ws-end-block | |
243 C-k p ws-print-block | |
244 C-k q kill-emacs | |
245 C-k r insert-file | |
246 C-k s save-some-buffers | |
247 C-k t ws-mark-word | |
248 C-k u ws-exdent-block | |
249 C-k C-u keyboard-quit | |
250 C-k v ws-move-block | |
251 C-k w ws-write-block | |
252 C-k x kill-emacs | |
253 C-k y ws-delete-block | |
254 | |
255 C-o c wordstar-center-line | |
256 C-o b switch-to-buffer | |
257 C-o j justify-current-line | |
258 C-o k kill-buffer | |
259 C-o l list-buffers | |
260 C-o m auto-fill-mode | |
261 C-o r set-fill-column | |
262 C-o C-u keyboard-quit | |
263 C-o wd delete-other-windows | |
264 C-o wh split-window-horizontally | |
265 C-o wo other-window | |
266 C-o wv split-window-vertically | |
267 | |
268 C-q 0 ws-find-marker-0 | |
269 C-q 1 ws-find-marker-1 | |
270 C-q 2 ws-find-marker-2 | |
271 C-q 3 ws-find-marker-3 | |
272 C-q 4 ws-find-marker-4 | |
273 C-q 5 ws-find-marker-5 | |
274 C-q 6 ws-find-marker-6 | |
275 C-q 7 ws-find-marker-7 | |
276 C-q 8 ws-find-marker-8 | |
277 C-q 9 ws-find-marker-9 | |
278 C-q a ws-query-replace | |
279 C-q b ws-to-block-begin | |
280 C-q c end-of-buffer | |
281 C-q d end-of-line | |
282 C-q f ws-search | |
283 C-q k ws-to-block-end | |
284 C-q l ws-undo | |
285 C-q p ws-last-cursorp | |
286 C-q r beginning-of-buffer | |
287 C-q C-u keyboard-quit | |
288 C-q w ws-last-error | |
289 C-q y ws-kill-eol | |
290 C-q DEL ws-kill-bol | |
291 " | |
292 (interactive) | |
293 (kill-all-local-variables) | |
294 (use-local-map wordstar-mode-map) | |
295 (setq mode-name "WordStar") | |
296 (setq major-mode 'wordstar-mode)) | |
297 | |
298 | |
299 (defun wordstar-center-paragraph () | |
300 "Center each line in the paragraph at or after point. | 322 "Center each line in the paragraph at or after point. |
301 See `wordstar-center-line' for more info." | 323 See center-line for more info." |
302 (interactive) | 324 (interactive) |
303 (save-excursion | 325 (save-excursion |
304 (forward-paragraph) | 326 (forward-paragraph) |
305 (or (bolp) (newline 1)) | 327 (or (bolp) (newline 1)) |
306 (let ((end (point))) | 328 (let ((end (point))) |
307 (backward-paragraph) | 329 (backward-paragraph) |
308 (wordstar-center-region (point) end)))) | 330 (center-region (point) end)))) |
309 | 331 |
310 (defun wordstar-center-region (from to) | 332 (defun center-region (from to) |
311 "Center each line starting in the region. | 333 "Center each line starting in the region. |
312 See `wordstar-center-line' for more info." | 334 See center-line for more info." |
313 (interactive "r") | 335 (interactive "r") |
314 (if (> from to) | 336 (if (> from to) |
315 (let ((tem to)) | 337 (let ((tem to)) |
316 (setq to from from tem))) | 338 (setq to from from tem))) |
317 (save-excursion | 339 (save-excursion |
318 (save-restriction | 340 (save-restriction |
319 (narrow-to-region from to) | 341 (narrow-to-region from to) |
320 (goto-char from) | 342 (goto-char from) |
321 (while (not (eobp)) | 343 (while (not (eobp)) |
322 (wordstar-center-line) | 344 (center-line) |
323 (forward-line 1))))) | 345 (forward-line 1))))) |
324 | 346 |
325 (defun wordstar-center-line () | 347 (defun center-line () |
326 "Center the line point is on, within the width specified by `fill-column'. | 348 "Center the line point is on, within the width specified by `fill-column'. |
327 This means adjusting the indentation to match | 349 This means adjusting the indentation to match |
328 the distance between the end of the text and `fill-column'." | 350 the distance between the end of the text and `fill-column'." |
329 (interactive) | 351 (interactive) |
330 (save-excursion | 352 (save-excursion |
472 (message "")) | 494 (message "")) |
473 (message "Block markers not set"))) | 495 (message "Block markers not set"))) |
474 | 496 |
475 | 497 |
476 (defun ws-indent-block () | 498 (defun ws-indent-block () |
477 "In WordStar mode: Indent block (not yet implemented)." | 499 "In WordStar mode: Indent block (not yet implemeted)." |
478 (interactive) | 500 (interactive) |
479 (ws-error "Indent block not yet implemented")) | 501 (ws-error "Indent block not yet implemented")) |
480 | 502 |
481 (defun ws-end-block () | 503 (defun ws-end-block () |
482 "In WordStar mode: Set block end marker to current cursor position." | 504 "In WordStar mode: Set block end marker to current cursor position." |
491 | 513 |
492 (defun ws-mark-word () | 514 (defun ws-mark-word () |
493 "In WordStar mode: Mark current word as block." | 515 "In WordStar mode: Mark current word as block." |
494 (interactive) | 516 (interactive) |
495 (save-excursion | 517 (save-excursion |
496 (forward-word 1) | 518 (forward-word) |
497 (sit-for 1) | 519 (sit-for 1) |
498 (ws-end-block) | 520 (ws-end-block) |
499 (forward-word -1) | 521 (backward-word) |
500 (sit-for 1) | 522 (sit-for 1) |
501 (ws-begin-block))) | 523 (ws-begin-block))) |
502 | 524 |
503 (defun ws-exdent-block () | 525 (defun ws-exdent-block () |
504 "I don't know what this (C-k u) should do." | 526 "I don't know what this (C-k u) should do." |
507 | 529 |
508 (defun ws-move-block () | 530 (defun ws-move-block () |
509 "In WordStar mode: Move block to current cursor position." | 531 "In WordStar mode: Move block to current cursor position." |
510 (interactive) | 532 (interactive) |
511 (if (and ws-block-begin-marker ws-block-end-marker) | 533 (if (and ws-block-begin-marker ws-block-end-marker) |
512 (let () | 534 (let () |
513 ;; XEmacs | |
514 (kill-region ws-block-begin-marker ws-block-end-marker 'silent) | 535 (kill-region ws-block-begin-marker ws-block-end-marker 'silent) |
515 (yank) | 536 (yank) |
516 (save-excursion | 537 (save-excursion |
517 (goto-char (region-beginning)) | 538 (goto-char (region-beginning)) |
518 (setq ws-block-begin-marker (point-marker)) | 539 (setq ws-block-begin-marker (point-marker)) |
701 (end-of-line) | 722 (end-of-line) |
702 (kill-region p (point)))) | 723 (kill-region p (point)))) |
703 | 724 |
704 (defun ws-kill-bol () | 725 (defun ws-kill-bol () |
705 "In WordStar mode: Kill to beginning of line | 726 "In WordStar mode: Kill to beginning of line |
706 \(like WordStar, not like Emacs)." | 727 (like WordStar, not like Emacs)." |
707 (interactive) | 728 (interactive) |
708 (let ((p (point))) | 729 (let ((p (point))) |
709 (beginning-of-line) | 730 (beginning-of-line) |
710 (kill-region (point) p))) | 731 (kill-region (point) p))) |
711 | 732 |