309
|
1 ;; File: ws-mode.el
|
|
2 ;; Description: WordStar emulation mode for GNU Emacs
|
|
3 ;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de>
|
|
4 ;; Created: 13 Feb 1991
|
|
5 ;; Version: 0.7
|
|
6
|
|
7 ;; Copyright (C) 1991 Free Software Foundation, Inc.
|
|
8
|
|
9 ;; This file is distributed in the hope that it will be useful,
|
|
10 ;; but WITHOUT ANY WARRANTY. No author or distributor
|
|
11 ;; accepts responsibility to anyone for the consequences of using it
|
|
12 ;; or for whether it serves any particular purpose or works at all,
|
|
13 ;; unless he says so in writing. Refer to the GNU Emacs General Public
|
|
14 ;; License for full details.
|
|
15
|
|
16 ;; Everyone is granted permission to copy, modify and redistribute
|
|
17 ;; this file, but only under the conditions described in the
|
|
18 ;; GNU Emacs General Public License. A copy of this license is
|
|
19 ;; supposed to have been given to you along with GNU Emacs so you
|
|
20 ;; can know your rights and responsibilities. It should be in a
|
|
21 ;; file named COPYING. Among other things, the copyright notice
|
|
22 ;; and this notice must be preserved on all copies.
|
|
23
|
|
24
|
|
25 ;; How to install ws-mode.el:
|
|
26 ;;
|
|
27 ;; either you
|
|
28 ;; put the following line into your default.el (usually
|
|
29 ;; /usr/local/emacs/lisp/default.el):
|
|
30 ;; (autoload 'wordstar-mode "ws-mode.el" "WordStar emulation mode." t)
|
|
31 ;; put ws-mode.el into a directory in your Emacs load-path (usually
|
|
32 ;; /usr/local/emacs/local/lisp).
|
|
33 ;;
|
|
34 ;; or you
|
|
35 ;; put ws-mode.el into your directory $HOME/lib/emacs (or something
|
|
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))
|
|
167
|
|
168 (defvar wordstar-mode-map nil "")
|
|
169 (defvar wordstar-C-j-map nil "")
|
|
170 (defvar wordstar-C-k-map nil "")
|
|
171 (defvar wordstar-C-o-map nil "")
|
|
172 (defvar wordstar-C-q-map nil "")
|
|
173
|
|
174 (if wordstar-mode-map
|
|
175 ()
|
|
176 (setq wordstar-mode-map (make-keymap))
|
|
177 ;; (setq wordstar-C-j-map (make-keymap)) ; later, perhaps
|
|
178 (setq wordstar-C-k-map (make-keymap))
|
|
179 (setq wordstar-C-o-map (make-keymap))
|
|
180 (setq wordstar-C-q-map (make-keymap))
|
|
181
|
|
182 (define-key wordstar-mode-map "\C-a" 'backward-word)
|
|
183 (define-key wordstar-mode-map "\C-b" 'fill-paragraph)
|
|
184 (define-key wordstar-mode-map "\C-c" 'scroll-up)
|
|
185 (define-key wordstar-mode-map "\C-d" 'forward-char)
|
|
186 (define-key wordstar-mode-map "\C-e" 'previous-line)
|
|
187 (define-key wordstar-mode-map "\C-f" 'forward-word)
|
|
188 (define-key wordstar-mode-map "\C-g" 'delete-char)
|
|
189 (define-key wordstar-mode-map "\C-h" 'backward-char)
|
|
190 (define-key wordstar-mode-map "\C-i" 'indent-for-tab-command)
|
|
191 (define-key wordstar-mode-map "\C-j" 'help-for-help)
|
|
192 (define-key wordstar-mode-map "\C-k" wordstar-C-k-map)
|
|
193 (define-key wordstar-mode-map "\C-l" 'ws-repeat-search)
|
|
194 (define-key wordstar-mode-map "\C-n" 'open-line)
|
|
195 (define-key wordstar-mode-map "\C-o" wordstar-C-o-map)
|
|
196 (define-key wordstar-mode-map "\C-p" 'quoted-insert)
|
|
197 (define-key wordstar-mode-map "\C-q" wordstar-C-q-map)
|
|
198 (define-key wordstar-mode-map "\C-r" 'scroll-down)
|
|
199 (define-key wordstar-mode-map "\C-s" 'backward-char)
|
|
200 (define-key wordstar-mode-map "\C-t" 'kill-word)
|
|
201 (define-key wordstar-mode-map "\C-u" 'keyboard-quit)
|
|
202 (define-key wordstar-mode-map "\C-v" 'overwrite-mode)
|
|
203 (define-key wordstar-mode-map "\C-w" 'scroll-down-line)
|
|
204 (define-key wordstar-mode-map "\C-x" 'next-line)
|
|
205 (define-key wordstar-mode-map "\C-y" 'kill-complete-line)
|
|
206 (define-key wordstar-mode-map "\C-z" 'scroll-up-line)
|
|
207
|
|
208 ;; wordstar-C-k-map
|
|
209
|
|
210 (define-key wordstar-C-k-map " " ())
|
|
211 (define-key wordstar-C-k-map "0" 'ws-set-marker-0)
|
|
212 (define-key wordstar-C-k-map "1" 'ws-set-marker-1)
|
|
213 (define-key wordstar-C-k-map "2" 'ws-set-marker-2)
|
|
214 (define-key wordstar-C-k-map "3" 'ws-set-marker-3)
|
|
215 (define-key wordstar-C-k-map "4" 'ws-set-marker-4)
|
|
216 (define-key wordstar-C-k-map "5" 'ws-set-marker-5)
|
|
217 (define-key wordstar-C-k-map "6" 'ws-set-marker-6)
|
|
218 (define-key wordstar-C-k-map "7" 'ws-set-marker-7)
|
|
219 (define-key wordstar-C-k-map "8" 'ws-set-marker-8)
|
|
220 (define-key wordstar-C-k-map "9" 'ws-set-marker-9)
|
|
221 (define-key wordstar-C-k-map "b" 'ws-begin-block)
|
|
222 (define-key wordstar-C-k-map "\C-b" 'ws-begin-block)
|
|
223 (define-key wordstar-C-k-map "c" 'ws-copy-block)
|
|
224 (define-key wordstar-C-k-map "\C-c" 'ws-copy-block)
|
|
225 (define-key wordstar-C-k-map "d" 'save-buffers-kill-emacs)
|
|
226 (define-key wordstar-C-k-map "\C-d" 'save-buffers-kill-emacs)
|
|
227 (define-key wordstar-C-k-map "f" 'find-file)
|
|
228 (define-key wordstar-C-k-map "\C-f" 'find-file)
|
|
229 (define-key wordstar-C-k-map "h" 'ws-show-markers)
|
|
230 (define-key wordstar-C-k-map "\C-h" 'ws-show-markers)
|
|
231 (define-key wordstar-C-k-map "i" 'ws-indent-block)
|
|
232 (define-key wordstar-C-k-map "\C-i" 'ws-indent-block)
|
|
233 (define-key wordstar-C-k-map "k" 'ws-end-block)
|
|
234 (define-key wordstar-C-k-map "\C-k" 'ws-end-block)
|
|
235 (define-key wordstar-C-k-map "p" 'ws-print-block)
|
|
236 (define-key wordstar-C-k-map "\C-p" 'ws-print-block)
|
|
237 (define-key wordstar-C-k-map "q" 'kill-emacs)
|
|
238 (define-key wordstar-C-k-map "\C-q" 'kill-emacs)
|
|
239 (define-key wordstar-C-k-map "r" 'insert-file)
|
|
240 (define-key wordstar-C-k-map "\C-r" 'insert-file)
|
|
241 (define-key wordstar-C-k-map "s" 'save-some-buffers)
|
|
242 (define-key wordstar-C-k-map "\C-s" 'save-some-buffers)
|
|
243 (define-key wordstar-C-k-map "t" 'ws-mark-word)
|
|
244 (define-key wordstar-C-k-map "\C-t" 'ws-mark-word)
|
|
245 (define-key wordstar-C-k-map "u" 'ws-exdent-block)
|
|
246 (define-key wordstar-C-k-map "\C-u" 'keyboard-quit)
|
|
247 (define-key wordstar-C-k-map "v" 'ws-move-block)
|
|
248 (define-key wordstar-C-k-map "\C-v" 'ws-move-block)
|
|
249 (define-key wordstar-C-k-map "w" 'ws-write-block)
|
|
250 (define-key wordstar-C-k-map "\C-w" 'ws-write-block)
|
|
251 (define-key wordstar-C-k-map "x" 'save-buffers-kill-emacs)
|
|
252 (define-key wordstar-C-k-map "\C-x" 'save-buffers-kill-emacs)
|
|
253 (define-key wordstar-C-k-map "y" 'ws-delete-block)
|
|
254 (define-key wordstar-C-k-map "\C-y" 'ws-delete-block)
|
|
255
|
|
256 ;; wordstar-C-j-map not yet implemented
|
|
257
|
|
258 ;; wordstar-C-o-map
|
|
259
|
|
260 (define-key wordstar-C-o-map " " ())
|
|
261 (define-key wordstar-C-o-map "c" 'center-line)
|
|
262 (define-key wordstar-C-o-map "\C-c" 'center-line)
|
|
263 (define-key wordstar-C-o-map "b" 'switch-to-buffer)
|
|
264 (define-key wordstar-C-o-map "\C-b" 'switch-to-buffer)
|
|
265 (define-key wordstar-C-o-map "j" 'justify-current-line)
|
|
266 (define-key wordstar-C-o-map "\C-j" 'justify-current-line)
|
|
267 (define-key wordstar-C-o-map "k" 'kill-buffer)
|
|
268 (define-key wordstar-C-o-map "\C-k" 'kill-buffer)
|
|
269 (define-key wordstar-C-o-map "l" 'list-buffers)
|
|
270 (define-key wordstar-C-o-map "\C-l" 'list-buffers)
|
|
271 (define-key wordstar-C-o-map "m" 'auto-fill-mode)
|
|
272 (define-key wordstar-C-o-map "\C-m" 'auto-fill-mode)
|
|
273 (define-key wordstar-C-o-map "r" 'set-fill-column)
|
|
274 (define-key wordstar-C-o-map "\C-r" 'set-fill-column)
|
|
275 (define-key wordstar-C-o-map "\C-u" 'keyboard-quit)
|
|
276 (define-key wordstar-C-o-map "wd" 'delete-other-windows)
|
|
277 (define-key wordstar-C-o-map "wh" 'split-window-horizontally)
|
|
278 (define-key wordstar-C-o-map "wo" 'other-window)
|
|
279 (define-key wordstar-C-o-map "wv" 'split-window-vertically)
|
|
280
|
|
281 ;; wordstar-C-q-map
|
|
282 (define-key wordstar-C-q-map " " ())
|
|
283 (define-key wordstar-C-q-map "0" 'ws-find-marker-0)
|
|
284 (define-key wordstar-C-q-map "1" 'ws-find-marker-1)
|
|
285 (define-key wordstar-C-q-map "2" 'ws-find-marker-2)
|
|
286 (define-key wordstar-C-q-map "3" 'ws-find-marker-3)
|
|
287 (define-key wordstar-C-q-map "4" 'ws-find-marker-4)
|
|
288 (define-key wordstar-C-q-map "5" 'ws-find-marker-5)
|
|
289 (define-key wordstar-C-q-map "6" 'ws-find-marker-6)
|
|
290 (define-key wordstar-C-q-map "7" 'ws-find-marker-7)
|
|
291 (define-key wordstar-C-q-map "8" 'ws-find-marker-8)
|
|
292 (define-key wordstar-C-q-map "9" 'ws-find-marker-9)
|
|
293 (define-key wordstar-C-q-map "a" 'ws-query-replace)
|
|
294 (define-key wordstar-C-q-map "\C-a" 'ws-query-replace)
|
|
295 (define-key wordstar-C-q-map "b" 'ws-goto-block-begin)
|
|
296 (define-key wordstar-C-q-map "\C-b" 'ws-goto-block-begin)
|
|
297 (define-key wordstar-C-q-map "c" 'end-of-buffer)
|
|
298 (define-key wordstar-C-q-map "\C-c" 'end-of-buffer)
|
|
299 (define-key wordstar-C-q-map "d" 'end-of-line)
|
|
300 (define-key wordstar-C-q-map "\C-d" 'end-of-line)
|
|
301 (define-key wordstar-C-q-map "f" 'ws-search)
|
|
302 (define-key wordstar-C-q-map "\C-f" 'ws-search)
|
|
303 (define-key wordstar-C-q-map "k" 'ws-goto-block-end)
|
|
304 (define-key wordstar-C-q-map "\C-k" 'ws-goto-block-end)
|
|
305 (define-key wordstar-C-q-map "l" 'ws-undo)
|
|
306 (define-key wordstar-C-q-map "\C-l" 'ws-undo)
|
|
307 (define-key wordstar-C-q-map "p" 'ws-last-cursorp)
|
|
308 (define-key wordstar-C-q-map "\C-p" 'ws-last-cursorp)
|
|
309 (define-key wordstar-C-q-map "r" 'beginning-of-buffer)
|
|
310 (define-key wordstar-C-q-map "\C-r" 'beginning-of-buffer)
|
|
311 (define-key wordstar-C-q-map "s" 'beginning-of-line)
|
|
312 (define-key wordstar-C-q-map "\C-s" 'beginning-of-line)
|
|
313 (define-key wordstar-C-q-map "\C-u" 'keyboard-quit)
|
|
314 (define-key wordstar-C-q-map "w" 'ws-last-error)
|
|
315 (define-key wordstar-C-q-map "\C-w" 'ws-last-error)
|
|
316 (define-key wordstar-C-q-map "y" 'ws-kill-eol)
|
|
317 (define-key wordstar-C-q-map "\C-y" 'ws-kill-eol)
|
|
318 (define-key wordstar-C-q-map "\177" 'ws-kill-bol))
|
|
319
|
|
320
|
|
321 (defun center-paragraph ()
|
|
322 "Center each line in the paragraph at or after point.
|
|
323 See center-line for more info."
|
|
324 (interactive)
|
|
325 (save-excursion
|
|
326 (forward-paragraph)
|
|
327 (or (bolp) (newline 1))
|
|
328 (let ((end (point)))
|
|
329 (backward-paragraph)
|
|
330 (center-region (point) end))))
|
|
331
|
|
332 (defun center-region (from to)
|
|
333 "Center each line starting in the region.
|
|
334 See center-line for more info."
|
|
335 (interactive "r")
|
|
336 (if (> from to)
|
|
337 (let ((tem to))
|
|
338 (setq to from from tem)))
|
|
339 (save-excursion
|
|
340 (save-restriction
|
|
341 (narrow-to-region from to)
|
|
342 (goto-char from)
|
|
343 (while (not (eobp))
|
|
344 (center-line)
|
|
345 (forward-line 1)))))
|
|
346
|
|
347 (defun center-line ()
|
|
348 "Center the line point is on, within the width specified by `fill-column'.
|
|
349 This means adjusting the indentation to match
|
|
350 the distance between the end of the text and `fill-column'."
|
|
351 (interactive)
|
|
352 (save-excursion
|
|
353 (let (line-length)
|
|
354 (beginning-of-line)
|
|
355 (delete-horizontal-space)
|
|
356 (end-of-line)
|
|
357 (delete-horizontal-space)
|
|
358 (setq line-length (current-column))
|
|
359 (beginning-of-line)
|
|
360 (indent-to
|
|
361 (+ left-margin
|
|
362 (/ (- fill-column left-margin line-length) 2))))))
|
|
363
|
|
364 (defun scroll-down-line ()
|
|
365 "Scroll one line down."
|
|
366 (interactive)
|
|
367 (scroll-down 1))
|
|
368
|
|
369 (defun scroll-up-line ()
|
|
370 "Scroll one line up."
|
|
371 (interactive)
|
|
372 (scroll-up 1))
|
|
373
|
|
374 ;;;;;;;;;;;
|
|
375 ;; wordstar special variables:
|
|
376
|
|
377 (defvar ws-marker-0 nil "Position marker 0 in WordStar mode.")
|
|
378 (defvar ws-marker-1 nil "Position marker 1 in WordStar mode.")
|
|
379 (defvar ws-marker-2 nil "Position marker 2 in WordStar mode.")
|
|
380 (defvar ws-marker-3 nil "Position marker 3 in WordStar mode.")
|
|
381 (defvar ws-marker-4 nil "Position marker 4 in WordStar mode.")
|
|
382 (defvar ws-marker-5 nil "Position marker 5 in WordStar mode.")
|
|
383 (defvar ws-marker-6 nil "Position marker 6 in WordStar mode.")
|
|
384 (defvar ws-marker-7 nil "Position marker 7 in WordStar mode.")
|
|
385 (defvar ws-marker-8 nil "Position marker 8 in WordStar mode.")
|
|
386 (defvar ws-marker-9 nil "Position marker 9 in WordStar mode.")
|
|
387
|
|
388 (defvar ws-block-begin-marker nil "Beginning of \"Block\" in WordStar mode.")
|
|
389 (defvar ws-block-end-marker nil "End of \"Block\" in WordStar mode.")
|
|
390
|
|
391 (defvar ws-search-string nil "String of last search in WordStar mode.")
|
|
392 (defvar ws-search-direction t
|
|
393 "Direction of last search in WordStar mode. T if forward, NIL if backward.")
|
|
394
|
|
395 (defvar ws-last-cursorposition nil
|
|
396 "Position before last search etc. in WordStar mode.")
|
|
397
|
|
398 (defvar ws-last-errormessage nil
|
|
399 "Last error message issued by a WordStar mode function.")
|
|
400
|
|
401 ;;;;;;;;;;;
|
|
402 ;; wordstar special functions:
|
|
403
|
|
404 (defun ws-error (string)
|
|
405 "Report error of a WordStar special function. Error message is saved
|
|
406 in ws-last-errormessage for recovery with C-q w."
|
|
407 (setq ws-last-errormessage string)
|
|
408 (error string))
|
|
409
|
|
410 (defun ws-set-marker-0 ()
|
|
411 "In WordStar mode: Set marker 0 to current cursor position."
|
|
412 (interactive)
|
|
413 (setq ws-marker-0 (point-marker))
|
|
414 (message "Marker 0 set"))
|
|
415
|
|
416 (defun ws-set-marker-1 ()
|
|
417 "In WordStar mode: Set marker 1 to current cursor position."
|
|
418 (interactive)
|
|
419 (setq ws-marker-1 (point-marker))
|
|
420 (message "Marker 1 set"))
|
|
421
|
|
422 (defun ws-set-marker-2 ()
|
|
423 "In WordStar mode: Set marker 2 to current cursor position."
|
|
424 (interactive)
|
|
425 (setq ws-marker-2 (point-marker))
|
|
426 (message "Marker 2 set"))
|
|
427
|
|
428 (defun ws-set-marker-3 ()
|
|
429 "In WordStar mode: Set marker 3 to current cursor position."
|
|
430 (interactive)
|
|
431 (setq ws-marker-3 (point-marker))
|
|
432 (message "Marker 3 set"))
|
|
433
|
|
434 (defun ws-set-marker-4 ()
|
|
435 "In WordStar mode: Set marker 4 to current cursor position."
|
|
436 (interactive)
|
|
437 (setq ws-marker-4 (point-marker))
|
|
438 (message "Marker 4 set"))
|
|
439
|
|
440 (defun ws-set-marker-5 ()
|
|
441 "In WordStar mode: Set marker 5 to current cursor position."
|
|
442 (interactive)
|
|
443 (setq ws-marker-5 (point-marker))
|
|
444 (message "Marker 5 set"))
|
|
445
|
|
446 (defun ws-set-marker-6 ()
|
|
447 "In WordStar mode: Set marker 6 to current cursor position."
|
|
448 (interactive)
|
|
449 (setq ws-marker-6 (point-marker))
|
|
450 (message "Marker 6 set"))
|
|
451
|
|
452 (defun ws-set-marker-7 ()
|
|
453 "In WordStar mode: Set marker 7 to current cursor position."
|
|
454 (interactive)
|
|
455 (setq ws-marker-7 (point-marker))
|
|
456 (message "Marker 7 set"))
|
|
457
|
|
458 (defun ws-set-marker-8 ()
|
|
459 "In WordStar mode: Set marker 8 to current cursor position."
|
|
460 (interactive)
|
|
461 (setq ws-marker-8 (point-marker))
|
|
462 (message "Marker 8 set"))
|
|
463
|
|
464 (defun ws-set-marker-9 ()
|
|
465 "In WordStar mode: Set marker 9 to current cursor position."
|
|
466 (interactive)
|
|
467 (setq ws-marker-9 (point-marker))
|
|
468 (message "Marker 9 set"))
|
|
469
|
|
470 (defun ws-begin-block ()
|
|
471 "In WordStar mode: Set block begin marker to current cursor position."
|
|
472 (interactive)
|
|
473 (setq ws-block-begin-marker (point-marker))
|
|
474 (message "Block begin marker set"))
|
|
475
|
|
476 (defun ws-show-markers ()
|
|
477 "In WordStar mode: Show block markers."
|
|
478 (interactive)
|
|
479 (if (or ws-block-begin-marker ws-block-end-marker)
|
|
480 (save-excursion
|
|
481 (if ws-block-begin-marker
|
|
482 (let ()
|
|
483 (goto-char ws-block-begin-marker)
|
|
484 (message "Block begin marker")
|
|
485 (sit-for 2))
|
|
486 (message "Block begin marker not set")
|
|
487 (sit-for 2))
|
|
488 (if ws-block-end-marker
|
|
489 (let ()
|
|
490 (goto-char ws-block-end-marker)
|
|
491 (message "Block end marker")
|
|
492 (sit-for 2))
|
|
493 (message "Block end marker not set"))
|
|
494 (message ""))
|
|
495 (message "Block markers not set")))
|
|
496
|
|
497
|
|
498 (defun ws-indent-block ()
|
|
499 "In WordStar mode: Indent block (not yet implemeted)."
|
|
500 (interactive)
|
|
501 (ws-error "Indent block not yet implemented"))
|
|
502
|
|
503 (defun ws-end-block ()
|
|
504 "In WordStar mode: Set block end marker to current cursor position."
|
|
505 (interactive)
|
|
506 (setq ws-block-end-marker (point-marker))
|
|
507 (message "Block end marker set"))
|
|
508
|
|
509 (defun ws-print-block ()
|
|
510 "In WordStar mode: Print block."
|
|
511 (interactive)
|
|
512 (message "Don't do this. Write block to a file (C-k w) and print this file."))
|
|
513
|
|
514 (defun ws-mark-word ()
|
|
515 "In WordStar mode: Mark current word as block."
|
|
516 (interactive)
|
|
517 (save-excursion
|
|
518 (forward-word)
|
|
519 (sit-for 1)
|
|
520 (ws-end-block)
|
|
521 (backward-word)
|
|
522 (sit-for 1)
|
|
523 (ws-begin-block)))
|
|
524
|
|
525 (defun ws-exdent-block ()
|
|
526 "I don't know what this (C-k u) should do."
|
|
527 (interactive)
|
|
528 (ws-error "This won't be done -- not yet implemented."))
|
|
529
|
|
530 (defun ws-move-block ()
|
|
531 "In WordStar mode: Move block to current cursor position."
|
|
532 (interactive)
|
|
533 (if (and ws-block-begin-marker ws-block-end-marker)
|
|
534 (let ()
|
|
535 (kill-region ws-block-begin-marker ws-block-end-marker 'silent)
|
|
536 (yank)
|
|
537 (save-excursion
|
|
538 (goto-char (region-beginning))
|
|
539 (setq ws-block-begin-marker (point-marker))
|
|
540 (goto-char (region-end))
|
|
541 (setq ws-block-end-marker (point-marker))))
|
|
542 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
543 (ws-block-end-marker "Block begin marker not set")
|
|
544 (t "Block markers not set")))))
|
|
545
|
|
546 (defun ws-write-block ()
|
|
547 "In WordStar mode: Write block to file."
|
|
548 (interactive)
|
|
549 (if (and ws-block-begin-marker ws-block-end-marker)
|
|
550 (let ((filename (read-file-name "Write block to file: ")))
|
|
551 (write-region ws-block-begin-marker ws-block-end-marker filename))
|
|
552 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
553 (ws-block-end-marker "Block begin marker not set")
|
|
554 (t "Block markers not set")))))
|
|
555
|
|
556
|
|
557 (defun ws-delete-block ()
|
|
558 "In WordStar mode: Delete block."
|
|
559 (interactive)
|
|
560 (if (and ws-block-begin-marker ws-block-end-marker)
|
|
561 (let ()
|
|
562 (kill-region ws-block-begin-marker ws-block-end-marker)
|
|
563 (setq ws-block-end-marker nil)
|
|
564 (setq ws-block-begin-marker nil))
|
|
565 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
566 (ws-block-end-marker "Block begin marker not set")
|
|
567 (t "Block markers not set")))))
|
|
568
|
|
569 (defun ws-find-marker-0 ()
|
|
570 "In WordStar mode: Go to marker 0."
|
|
571 (interactive)
|
|
572 (if ws-marker-0
|
|
573 (let ()
|
|
574 (setq ws-last-cursorposition (point-marker))
|
|
575 (goto-char ws-marker-0))
|
|
576 (ws-error "Marker 0 not set")))
|
|
577
|
|
578 (defun ws-find-marker-1 ()
|
|
579 "In WordStar mode: Go to marker 1."
|
|
580 (interactive)
|
|
581 (if ws-marker-1
|
|
582 (let ()
|
|
583 (setq ws-last-cursorposition (point-marker))
|
|
584 (goto-char ws-marker-1))
|
|
585 (ws-error "Marker 1 not set")))
|
|
586
|
|
587 (defun ws-find-marker-2 ()
|
|
588 "In WordStar mode: Go to marker 2."
|
|
589 (interactive)
|
|
590 (if ws-marker-2
|
|
591 (let ()
|
|
592 (setq ws-last-cursorposition (point-marker))
|
|
593 (goto-char ws-marker-2))
|
|
594 (ws-error "Marker 2 not set")))
|
|
595
|
|
596 (defun ws-find-marker-3 ()
|
|
597 "In WordStar mode: Go to marker 3."
|
|
598 (interactive)
|
|
599 (if ws-marker-3
|
|
600 (let ()
|
|
601 (setq ws-last-cursorposition (point-marker))
|
|
602 (goto-char ws-marker-3))
|
|
603 (ws-error "Marker 3 not set")))
|
|
604
|
|
605 (defun ws-find-marker-4 ()
|
|
606 "In WordStar mode: Go to marker 4."
|
|
607 (interactive)
|
|
608 (if ws-marker-4
|
|
609 (let ()
|
|
610 (setq ws-last-cursorposition (point-marker))
|
|
611 (goto-char ws-marker-4))
|
|
612 (ws-error "Marker 4 not set")))
|
|
613
|
|
614 (defun ws-find-marker-5 ()
|
|
615 "In WordStar mode: Go to marker 5."
|
|
616 (interactive)
|
|
617 (if ws-marker-5
|
|
618 (let ()
|
|
619 (setq ws-last-cursorposition (point-marker))
|
|
620 (goto-char ws-marker-5))
|
|
621 (ws-error "Marker 5 not set")))
|
|
622
|
|
623 (defun ws-find-marker-6 ()
|
|
624 "In WordStar mode: Go to marker 6."
|
|
625 (interactive)
|
|
626 (if ws-marker-6
|
|
627 (let ()
|
|
628 (setq ws-last-cursorposition (point-marker))
|
|
629 (goto-char ws-marker-6))
|
|
630 (ws-error "Marker 6 not set")))
|
|
631
|
|
632 (defun ws-find-marker-7 ()
|
|
633 "In WordStar mode: Go to marker 7."
|
|
634 (interactive)
|
|
635 (if ws-marker-7
|
|
636 (let ()
|
|
637 (setq ws-last-cursorposition (point-marker))
|
|
638 (goto-char ws-marker-7))
|
|
639 (ws-error "Marker 7 not set")))
|
|
640
|
|
641 (defun ws-find-marker-8 ()
|
|
642 "In WordStar mode: Go to marker 8."
|
|
643 (interactive)
|
|
644 (if ws-marker-8
|
|
645 (let ()
|
|
646 (setq ws-last-cursorposition (point-marker))
|
|
647 (goto-char ws-marker-8))
|
|
648 (ws-error "Marker 8 not set")))
|
|
649
|
|
650 (defun ws-find-marker-9 ()
|
|
651 "In WordStar mode: Go to marker 9."
|
|
652 (interactive)
|
|
653 (if ws-marker-9
|
|
654 (let ()
|
|
655 (setq ws-last-cursorposition (point-marker))
|
|
656 (goto-char ws-marker-9))
|
|
657 (ws-error "Marker 9 not set")))
|
|
658
|
|
659 (defun ws-goto-block-begin ()
|
|
660 "In WordStar mode: Go to block begin marker."
|
|
661 (interactive)
|
|
662 (if ws-block-begin-marker
|
|
663 (let ()
|
|
664 (setq ws-last-cursorposition (point-marker))
|
|
665 (goto-char ws-block-begin-marker))
|
|
666 (ws-error "Block begin marker not set")))
|
|
667
|
|
668 (defun ws-search (string)
|
|
669 "In WordStar mode: Search string, remember string for repetition."
|
|
670 (interactive "sSearch for: ")
|
|
671 (message "Forward (f) or backward (b)")
|
|
672 (let ((direction
|
|
673 (read-char)))
|
|
674 (cond ((equal (upcase direction) \070)
|
|
675 (setq ws-search-string string)
|
|
676 (setq ws-search-direction t)
|
|
677 (setq ws-last-cursorposition (point-marker))
|
|
678 (search-forward string))
|
|
679 ((equal (upcase direction) \066)
|
|
680 (setq ws-search-string string)
|
|
681 (setq ws-search-direction nil)
|
|
682 (setq ws-last-cursorposition (point-marker))
|
|
683 (search-backward string))
|
|
684 (t (keyboard-quit)))))
|
|
685
|
|
686 (defun ws-goto-block-end ()
|
|
687 "In WordStar mode: Go to block end marker."
|
|
688 (interactive)
|
|
689 (if ws-block-end-marker
|
|
690 (let ()
|
|
691 (setq ws-last-cursorposition (point-marker))
|
|
692 (goto-char ws-block-end-marker))
|
|
693 (ws-error "Block end marker not set")))
|
|
694
|
|
695 (defun ws-undo ()
|
|
696 "In WordStar mode: Undo and give message about undoing more changes."
|
|
697 (interactive)
|
|
698 (undo)
|
|
699 (message "Repeat C-q l to undo more changes."))
|
|
700
|
|
701 (defun ws-goto-last-cursorposition ()
|
|
702 "In WordStar mode: "
|
|
703 (interactive)
|
|
704 (if ws-last-cursorposition
|
|
705 (let ()
|
|
706 (setq ws-last-cursorposition (point-marker))
|
|
707 (goto-char ws-last-cursorposition))
|
|
708 (ws-error "No last cursor position available.")))
|
|
709
|
|
710 (defun ws-last-error ()
|
|
711 "In WordStar mode: repeat last error message.
|
|
712 This will only work for errors raised by WordStar mode functions."
|
|
713 (interactive)
|
|
714 (if ws-last-errormessage
|
|
715 (message ws-last-errormessage)
|
|
716 (message "No WordStar error yet.")))
|
|
717
|
|
718 (defun ws-kill-eol ()
|
|
719 "In WordStar mode: Kill to end of line (like WordStar, not like Emacs)."
|
|
720 (interactive)
|
|
721 (let ((p (point)))
|
|
722 (end-of-line)
|
|
723 (kill-region p (point))))
|
|
724
|
|
725 (defun ws-kill-bol ()
|
|
726 "In WordStar mode: Kill to beginning of line
|
|
727 (like WordStar, not like Emacs)."
|
|
728 (interactive)
|
|
729 (let ((p (point)))
|
|
730 (beginning-of-line)
|
|
731 (kill-region (point) p)))
|
|
732
|
|
733 (defun kill-complete-line ()
|
|
734 "Kill the complete line."
|
|
735 (interactive)
|
|
736 (beginning-of-line)
|
|
737 (if (eobp) (error "End of buffer"))
|
|
738 (let ((beg (point)))
|
|
739 (forward-line 1)
|
|
740 (kill-region beg (point))))
|
|
741
|
|
742 (defun ws-repeat-search ()
|
|
743 "In WordStar mode: Repeat last search."
|
|
744 (interactive)
|
|
745 (setq ws-last-cursorposition (point-marker))
|
|
746 (if ws-search-string
|
|
747 (if ws-search-direction
|
|
748 (search-forward ws-search-string)
|
|
749 (search-backward ws-search-string))
|
|
750 (ws-error "No search to repeat")))
|
|
751
|
|
752 (defun ws-query-replace (from to)
|
|
753 "In WordStar mode: Search string, remember string for repetition."
|
|
754 (interactive "sReplace:
|
|
755 sWith: " )
|
|
756 (setq ws-search-string from)
|
|
757 (setq ws-search-direction t)
|
|
758 (setq ws-last-cursorposition (point-marker))
|
|
759 (query-replace from to))
|
|
760
|
|
761 (defun ws-copy-block ()
|
|
762 "In WordStar mode: Copy block to current cursor position."
|
|
763 (interactive)
|
|
764 (if (and ws-block-begin-marker ws-block-end-marker)
|
|
765 (let ()
|
|
766 (copy-region-as-kill ws-block-begin-marker ws-block-end-marker)
|
|
767 (yank)
|
|
768 (save-excursion
|
|
769 (goto-char (region-beginning))
|
|
770 (setq ws-block-begin-marker (point-marker))
|
|
771 (goto-char (region-end))
|
|
772 (setq ws-block-end-marker (point-marker))))
|
|
773 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
774 (ws-block-end-marker "Block begin marker not set")
|
|
775 (t "Block markers not set")))))
|