0
|
1 ;;; ws-mode.el --- WordStar emulation mode for GNU Emacs
|
|
2
|
|
3 ;; Copyright (C) 1991 Free Software Foundation, Inc.
|
|
4
|
72
|
5 ;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de>
|
|
6 ;; Version: 0.7
|
|
7 ;; Keywords: emulations
|
0
|
8
|
72
|
9 ;; This file is part of XEmacs.
|
0
|
10
|
72
|
11 ;; 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 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
14 ;; any later version.
|
0
|
15
|
72
|
16 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
0
|
20
|
72
|
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
|
|
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
24 ;; 02111-1307, USA.
|
0
|
25
|
72
|
26 ;;; Synched up with: FSF 19.34
|
|
27
|
|
28 ;;; Commentary:
|
0
|
29
|
72
|
30 ;; This emulates WordStar, with a major mode.
|
|
31
|
|
32 ;;; Code:
|
0
|
33
|
|
34 (defvar wordstar-mode-map nil "")
|
|
35 (defvar wordstar-C-j-map nil "")
|
|
36 (defvar wordstar-C-k-map nil "")
|
|
37 (defvar wordstar-C-o-map nil "")
|
|
38 (defvar wordstar-C-q-map nil "")
|
|
39
|
|
40 (if wordstar-mode-map
|
|
41 ()
|
|
42 (setq wordstar-mode-map (make-keymap))
|
|
43 ;; (setq wordstar-C-j-map (make-keymap)) ; later, perhaps
|
|
44 (setq wordstar-C-k-map (make-keymap))
|
|
45 (setq wordstar-C-o-map (make-keymap))
|
|
46 (setq wordstar-C-q-map (make-keymap))
|
|
47
|
|
48 (define-key wordstar-mode-map "\C-a" 'backward-word)
|
|
49 (define-key wordstar-mode-map "\C-b" 'fill-paragraph)
|
|
50 (define-key wordstar-mode-map "\C-c" 'scroll-up)
|
|
51 (define-key wordstar-mode-map "\C-d" 'forward-char)
|
|
52 (define-key wordstar-mode-map "\C-e" 'previous-line)
|
|
53 (define-key wordstar-mode-map "\C-f" 'forward-word)
|
|
54 (define-key wordstar-mode-map "\C-g" 'delete-char)
|
|
55 (define-key wordstar-mode-map "\C-h" 'backward-char)
|
|
56 (define-key wordstar-mode-map "\C-i" 'indent-for-tab-command)
|
|
57 (define-key wordstar-mode-map "\C-j" 'help-for-help)
|
|
58 (define-key wordstar-mode-map "\C-k" wordstar-C-k-map)
|
|
59 (define-key wordstar-mode-map "\C-l" 'ws-repeat-search)
|
|
60 (define-key wordstar-mode-map "\C-n" 'open-line)
|
|
61 (define-key wordstar-mode-map "\C-o" wordstar-C-o-map)
|
|
62 (define-key wordstar-mode-map "\C-p" 'quoted-insert)
|
|
63 (define-key wordstar-mode-map "\C-q" wordstar-C-q-map)
|
|
64 (define-key wordstar-mode-map "\C-r" 'scroll-down)
|
|
65 (define-key wordstar-mode-map "\C-s" 'backward-char)
|
|
66 (define-key wordstar-mode-map "\C-t" 'kill-word)
|
|
67 (define-key wordstar-mode-map "\C-u" 'keyboard-quit)
|
|
68 (define-key wordstar-mode-map "\C-v" 'overwrite-mode)
|
|
69 (define-key wordstar-mode-map "\C-w" 'scroll-down-line)
|
|
70 (define-key wordstar-mode-map "\C-x" 'next-line)
|
|
71 (define-key wordstar-mode-map "\C-y" 'kill-complete-line)
|
|
72 (define-key wordstar-mode-map "\C-z" 'scroll-up-line)
|
|
73
|
|
74 ;; wordstar-C-k-map
|
|
75
|
|
76 (define-key wordstar-C-k-map " " ())
|
|
77 (define-key wordstar-C-k-map "0" 'ws-set-marker-0)
|
|
78 (define-key wordstar-C-k-map "1" 'ws-set-marker-1)
|
|
79 (define-key wordstar-C-k-map "2" 'ws-set-marker-2)
|
|
80 (define-key wordstar-C-k-map "3" 'ws-set-marker-3)
|
|
81 (define-key wordstar-C-k-map "4" 'ws-set-marker-4)
|
|
82 (define-key wordstar-C-k-map "5" 'ws-set-marker-5)
|
|
83 (define-key wordstar-C-k-map "6" 'ws-set-marker-6)
|
|
84 (define-key wordstar-C-k-map "7" 'ws-set-marker-7)
|
|
85 (define-key wordstar-C-k-map "8" 'ws-set-marker-8)
|
|
86 (define-key wordstar-C-k-map "9" 'ws-set-marker-9)
|
|
87 (define-key wordstar-C-k-map "b" 'ws-begin-block)
|
|
88 (define-key wordstar-C-k-map "\C-b" 'ws-begin-block)
|
|
89 (define-key wordstar-C-k-map "c" 'ws-copy-block)
|
|
90 (define-key wordstar-C-k-map "\C-c" 'ws-copy-block)
|
|
91 (define-key wordstar-C-k-map "d" 'save-buffers-kill-emacs)
|
|
92 (define-key wordstar-C-k-map "\C-d" 'save-buffers-kill-emacs)
|
|
93 (define-key wordstar-C-k-map "f" 'find-file)
|
|
94 (define-key wordstar-C-k-map "\C-f" 'find-file)
|
|
95 (define-key wordstar-C-k-map "h" 'ws-show-markers)
|
|
96 (define-key wordstar-C-k-map "\C-h" 'ws-show-markers)
|
|
97 (define-key wordstar-C-k-map "i" 'ws-indent-block)
|
|
98 (define-key wordstar-C-k-map "\C-i" 'ws-indent-block)
|
|
99 (define-key wordstar-C-k-map "k" 'ws-end-block)
|
|
100 (define-key wordstar-C-k-map "\C-k" 'ws-end-block)
|
|
101 (define-key wordstar-C-k-map "p" 'ws-print-block)
|
|
102 (define-key wordstar-C-k-map "\C-p" 'ws-print-block)
|
|
103 (define-key wordstar-C-k-map "q" 'kill-emacs)
|
|
104 (define-key wordstar-C-k-map "\C-q" 'kill-emacs)
|
|
105 (define-key wordstar-C-k-map "r" 'insert-file)
|
|
106 (define-key wordstar-C-k-map "\C-r" 'insert-file)
|
|
107 (define-key wordstar-C-k-map "s" 'save-some-buffers)
|
|
108 (define-key wordstar-C-k-map "\C-s" 'save-some-buffers)
|
|
109 (define-key wordstar-C-k-map "t" 'ws-mark-word)
|
|
110 (define-key wordstar-C-k-map "\C-t" 'ws-mark-word)
|
|
111 (define-key wordstar-C-k-map "u" 'ws-exdent-block)
|
|
112 (define-key wordstar-C-k-map "\C-u" 'keyboard-quit)
|
|
113 (define-key wordstar-C-k-map "v" 'ws-move-block)
|
|
114 (define-key wordstar-C-k-map "\C-v" 'ws-move-block)
|
|
115 (define-key wordstar-C-k-map "w" 'ws-write-block)
|
|
116 (define-key wordstar-C-k-map "\C-w" 'ws-write-block)
|
|
117 (define-key wordstar-C-k-map "x" 'save-buffers-kill-emacs)
|
|
118 (define-key wordstar-C-k-map "\C-x" 'save-buffers-kill-emacs)
|
|
119 (define-key wordstar-C-k-map "y" 'ws-delete-block)
|
|
120 (define-key wordstar-C-k-map "\C-y" 'ws-delete-block)
|
|
121
|
|
122 ;; wordstar-C-j-map not yet implemented
|
|
123
|
|
124 ;; wordstar-C-o-map
|
|
125
|
|
126 (define-key wordstar-C-o-map " " ())
|
72
|
127 (define-key wordstar-C-o-map "c" 'wordstar-center-line)
|
|
128 (define-key wordstar-C-o-map "\C-c" 'wordstar-center-line)
|
0
|
129 (define-key wordstar-C-o-map "b" 'switch-to-buffer)
|
|
130 (define-key wordstar-C-o-map "\C-b" 'switch-to-buffer)
|
|
131 (define-key wordstar-C-o-map "j" 'justify-current-line)
|
|
132 (define-key wordstar-C-o-map "\C-j" 'justify-current-line)
|
|
133 (define-key wordstar-C-o-map "k" 'kill-buffer)
|
|
134 (define-key wordstar-C-o-map "\C-k" 'kill-buffer)
|
|
135 (define-key wordstar-C-o-map "l" 'list-buffers)
|
|
136 (define-key wordstar-C-o-map "\C-l" 'list-buffers)
|
|
137 (define-key wordstar-C-o-map "m" 'auto-fill-mode)
|
|
138 (define-key wordstar-C-o-map "\C-m" 'auto-fill-mode)
|
|
139 (define-key wordstar-C-o-map "r" 'set-fill-column)
|
|
140 (define-key wordstar-C-o-map "\C-r" 'set-fill-column)
|
|
141 (define-key wordstar-C-o-map "\C-u" 'keyboard-quit)
|
|
142 (define-key wordstar-C-o-map "wd" 'delete-other-windows)
|
|
143 (define-key wordstar-C-o-map "wh" 'split-window-horizontally)
|
|
144 (define-key wordstar-C-o-map "wo" 'other-window)
|
|
145 (define-key wordstar-C-o-map "wv" 'split-window-vertically)
|
|
146
|
|
147 ;; wordstar-C-q-map
|
|
148 (define-key wordstar-C-q-map " " ())
|
|
149 (define-key wordstar-C-q-map "0" 'ws-find-marker-0)
|
|
150 (define-key wordstar-C-q-map "1" 'ws-find-marker-1)
|
|
151 (define-key wordstar-C-q-map "2" 'ws-find-marker-2)
|
|
152 (define-key wordstar-C-q-map "3" 'ws-find-marker-3)
|
|
153 (define-key wordstar-C-q-map "4" 'ws-find-marker-4)
|
|
154 (define-key wordstar-C-q-map "5" 'ws-find-marker-5)
|
|
155 (define-key wordstar-C-q-map "6" 'ws-find-marker-6)
|
|
156 (define-key wordstar-C-q-map "7" 'ws-find-marker-7)
|
|
157 (define-key wordstar-C-q-map "8" 'ws-find-marker-8)
|
|
158 (define-key wordstar-C-q-map "9" 'ws-find-marker-9)
|
|
159 (define-key wordstar-C-q-map "a" 'ws-query-replace)
|
|
160 (define-key wordstar-C-q-map "\C-a" 'ws-query-replace)
|
|
161 (define-key wordstar-C-q-map "b" 'ws-goto-block-begin)
|
|
162 (define-key wordstar-C-q-map "\C-b" 'ws-goto-block-begin)
|
|
163 (define-key wordstar-C-q-map "c" 'end-of-buffer)
|
|
164 (define-key wordstar-C-q-map "\C-c" 'end-of-buffer)
|
|
165 (define-key wordstar-C-q-map "d" 'end-of-line)
|
|
166 (define-key wordstar-C-q-map "\C-d" 'end-of-line)
|
|
167 (define-key wordstar-C-q-map "f" 'ws-search)
|
|
168 (define-key wordstar-C-q-map "\C-f" 'ws-search)
|
|
169 (define-key wordstar-C-q-map "k" 'ws-goto-block-end)
|
|
170 (define-key wordstar-C-q-map "\C-k" 'ws-goto-block-end)
|
|
171 (define-key wordstar-C-q-map "l" 'ws-undo)
|
|
172 (define-key wordstar-C-q-map "\C-l" 'ws-undo)
|
|
173 (define-key wordstar-C-q-map "p" 'ws-last-cursorp)
|
|
174 (define-key wordstar-C-q-map "\C-p" 'ws-last-cursorp)
|
|
175 (define-key wordstar-C-q-map "r" 'beginning-of-buffer)
|
|
176 (define-key wordstar-C-q-map "\C-r" 'beginning-of-buffer)
|
|
177 (define-key wordstar-C-q-map "s" 'beginning-of-line)
|
|
178 (define-key wordstar-C-q-map "\C-s" 'beginning-of-line)
|
|
179 (define-key wordstar-C-q-map "\C-u" 'keyboard-quit)
|
|
180 (define-key wordstar-C-q-map "w" 'ws-last-error)
|
|
181 (define-key wordstar-C-q-map "\C-w" 'ws-last-error)
|
|
182 (define-key wordstar-C-q-map "y" 'ws-kill-eol)
|
|
183 (define-key wordstar-C-q-map "\C-y" 'ws-kill-eol)
|
|
184 (define-key wordstar-C-q-map "\177" 'ws-kill-bol))
|
|
185
|
72
|
186 ;;;###autoload
|
|
187 (defun wordstar-mode ()
|
|
188 "Major mode with WordStar-like key bindings.
|
0
|
189
|
72
|
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 ()
|
0
|
300 "Center each line in the paragraph at or after point.
|
72
|
301 See `wordstar-center-line' for more info."
|
0
|
302 (interactive)
|
|
303 (save-excursion
|
|
304 (forward-paragraph)
|
|
305 (or (bolp) (newline 1))
|
|
306 (let ((end (point)))
|
|
307 (backward-paragraph)
|
72
|
308 (wordstar-center-region (point) end))))
|
0
|
309
|
72
|
310 (defun wordstar-center-region (from to)
|
0
|
311 "Center each line starting in the region.
|
72
|
312 See `wordstar-center-line' for more info."
|
0
|
313 (interactive "r")
|
|
314 (if (> from to)
|
|
315 (let ((tem to))
|
|
316 (setq to from from tem)))
|
|
317 (save-excursion
|
|
318 (save-restriction
|
|
319 (narrow-to-region from to)
|
|
320 (goto-char from)
|
|
321 (while (not (eobp))
|
72
|
322 (wordstar-center-line)
|
0
|
323 (forward-line 1)))))
|
|
324
|
72
|
325 (defun wordstar-center-line ()
|
0
|
326 "Center the line point is on, within the width specified by `fill-column'.
|
|
327 This means adjusting the indentation to match
|
|
328 the distance between the end of the text and `fill-column'."
|
|
329 (interactive)
|
|
330 (save-excursion
|
|
331 (let (line-length)
|
|
332 (beginning-of-line)
|
|
333 (delete-horizontal-space)
|
|
334 (end-of-line)
|
|
335 (delete-horizontal-space)
|
|
336 (setq line-length (current-column))
|
|
337 (beginning-of-line)
|
|
338 (indent-to
|
|
339 (+ left-margin
|
|
340 (/ (- fill-column left-margin line-length) 2))))))
|
|
341
|
|
342 (defun scroll-down-line ()
|
|
343 "Scroll one line down."
|
|
344 (interactive)
|
|
345 (scroll-down 1))
|
|
346
|
|
347 (defun scroll-up-line ()
|
|
348 "Scroll one line up."
|
|
349 (interactive)
|
|
350 (scroll-up 1))
|
|
351
|
|
352 ;;;;;;;;;;;
|
|
353 ;; wordstar special variables:
|
|
354
|
|
355 (defvar ws-marker-0 nil "Position marker 0 in WordStar mode.")
|
|
356 (defvar ws-marker-1 nil "Position marker 1 in WordStar mode.")
|
|
357 (defvar ws-marker-2 nil "Position marker 2 in WordStar mode.")
|
|
358 (defvar ws-marker-3 nil "Position marker 3 in WordStar mode.")
|
|
359 (defvar ws-marker-4 nil "Position marker 4 in WordStar mode.")
|
|
360 (defvar ws-marker-5 nil "Position marker 5 in WordStar mode.")
|
|
361 (defvar ws-marker-6 nil "Position marker 6 in WordStar mode.")
|
|
362 (defvar ws-marker-7 nil "Position marker 7 in WordStar mode.")
|
|
363 (defvar ws-marker-8 nil "Position marker 8 in WordStar mode.")
|
|
364 (defvar ws-marker-9 nil "Position marker 9 in WordStar mode.")
|
|
365
|
|
366 (defvar ws-block-begin-marker nil "Beginning of \"Block\" in WordStar mode.")
|
|
367 (defvar ws-block-end-marker nil "End of \"Block\" in WordStar mode.")
|
|
368
|
|
369 (defvar ws-search-string nil "String of last search in WordStar mode.")
|
|
370 (defvar ws-search-direction t
|
|
371 "Direction of last search in WordStar mode. T if forward, NIL if backward.")
|
|
372
|
|
373 (defvar ws-last-cursorposition nil
|
|
374 "Position before last search etc. in WordStar mode.")
|
|
375
|
|
376 (defvar ws-last-errormessage nil
|
|
377 "Last error message issued by a WordStar mode function.")
|
|
378
|
|
379 ;;;;;;;;;;;
|
|
380 ;; wordstar special functions:
|
|
381
|
|
382 (defun ws-error (string)
|
|
383 "Report error of a WordStar special function. Error message is saved
|
|
384 in ws-last-errormessage for recovery with C-q w."
|
|
385 (setq ws-last-errormessage string)
|
|
386 (error string))
|
|
387
|
|
388 (defun ws-set-marker-0 ()
|
|
389 "In WordStar mode: Set marker 0 to current cursor position."
|
|
390 (interactive)
|
|
391 (setq ws-marker-0 (point-marker))
|
|
392 (message "Marker 0 set"))
|
|
393
|
|
394 (defun ws-set-marker-1 ()
|
|
395 "In WordStar mode: Set marker 1 to current cursor position."
|
|
396 (interactive)
|
|
397 (setq ws-marker-1 (point-marker))
|
|
398 (message "Marker 1 set"))
|
|
399
|
|
400 (defun ws-set-marker-2 ()
|
|
401 "In WordStar mode: Set marker 2 to current cursor position."
|
|
402 (interactive)
|
|
403 (setq ws-marker-2 (point-marker))
|
|
404 (message "Marker 2 set"))
|
|
405
|
|
406 (defun ws-set-marker-3 ()
|
|
407 "In WordStar mode: Set marker 3 to current cursor position."
|
|
408 (interactive)
|
|
409 (setq ws-marker-3 (point-marker))
|
|
410 (message "Marker 3 set"))
|
|
411
|
|
412 (defun ws-set-marker-4 ()
|
|
413 "In WordStar mode: Set marker 4 to current cursor position."
|
|
414 (interactive)
|
|
415 (setq ws-marker-4 (point-marker))
|
|
416 (message "Marker 4 set"))
|
|
417
|
|
418 (defun ws-set-marker-5 ()
|
|
419 "In WordStar mode: Set marker 5 to current cursor position."
|
|
420 (interactive)
|
|
421 (setq ws-marker-5 (point-marker))
|
|
422 (message "Marker 5 set"))
|
|
423
|
|
424 (defun ws-set-marker-6 ()
|
|
425 "In WordStar mode: Set marker 6 to current cursor position."
|
|
426 (interactive)
|
|
427 (setq ws-marker-6 (point-marker))
|
|
428 (message "Marker 6 set"))
|
|
429
|
|
430 (defun ws-set-marker-7 ()
|
|
431 "In WordStar mode: Set marker 7 to current cursor position."
|
|
432 (interactive)
|
|
433 (setq ws-marker-7 (point-marker))
|
|
434 (message "Marker 7 set"))
|
|
435
|
|
436 (defun ws-set-marker-8 ()
|
|
437 "In WordStar mode: Set marker 8 to current cursor position."
|
|
438 (interactive)
|
|
439 (setq ws-marker-8 (point-marker))
|
|
440 (message "Marker 8 set"))
|
|
441
|
|
442 (defun ws-set-marker-9 ()
|
|
443 "In WordStar mode: Set marker 9 to current cursor position."
|
|
444 (interactive)
|
|
445 (setq ws-marker-9 (point-marker))
|
|
446 (message "Marker 9 set"))
|
|
447
|
|
448 (defun ws-begin-block ()
|
|
449 "In WordStar mode: Set block begin marker to current cursor position."
|
|
450 (interactive)
|
|
451 (setq ws-block-begin-marker (point-marker))
|
|
452 (message "Block begin marker set"))
|
|
453
|
|
454 (defun ws-show-markers ()
|
|
455 "In WordStar mode: Show block markers."
|
|
456 (interactive)
|
|
457 (if (or ws-block-begin-marker ws-block-end-marker)
|
|
458 (save-excursion
|
|
459 (if ws-block-begin-marker
|
|
460 (let ()
|
|
461 (goto-char ws-block-begin-marker)
|
|
462 (message "Block begin marker")
|
|
463 (sit-for 2))
|
|
464 (message "Block begin marker not set")
|
|
465 (sit-for 2))
|
|
466 (if ws-block-end-marker
|
|
467 (let ()
|
|
468 (goto-char ws-block-end-marker)
|
|
469 (message "Block end marker")
|
|
470 (sit-for 2))
|
|
471 (message "Block end marker not set"))
|
|
472 (message ""))
|
|
473 (message "Block markers not set")))
|
|
474
|
|
475
|
|
476 (defun ws-indent-block ()
|
72
|
477 "In WordStar mode: Indent block (not yet implemented)."
|
0
|
478 (interactive)
|
|
479 (ws-error "Indent block not yet implemented"))
|
|
480
|
|
481 (defun ws-end-block ()
|
|
482 "In WordStar mode: Set block end marker to current cursor position."
|
|
483 (interactive)
|
|
484 (setq ws-block-end-marker (point-marker))
|
|
485 (message "Block end marker set"))
|
|
486
|
|
487 (defun ws-print-block ()
|
|
488 "In WordStar mode: Print block."
|
|
489 (interactive)
|
|
490 (message "Don't do this. Write block to a file (C-k w) and print this file."))
|
|
491
|
|
492 (defun ws-mark-word ()
|
|
493 "In WordStar mode: Mark current word as block."
|
|
494 (interactive)
|
|
495 (save-excursion
|
72
|
496 (forward-word 1)
|
0
|
497 (sit-for 1)
|
|
498 (ws-end-block)
|
72
|
499 (forward-word -1)
|
0
|
500 (sit-for 1)
|
|
501 (ws-begin-block)))
|
|
502
|
|
503 (defun ws-exdent-block ()
|
|
504 "I don't know what this (C-k u) should do."
|
|
505 (interactive)
|
|
506 (ws-error "This won't be done -- not yet implemented."))
|
|
507
|
|
508 (defun ws-move-block ()
|
|
509 "In WordStar mode: Move block to current cursor position."
|
|
510 (interactive)
|
|
511 (if (and ws-block-begin-marker ws-block-end-marker)
|
72
|
512 (let ()
|
|
513 ;; XEmacs
|
0
|
514 (kill-region ws-block-begin-marker ws-block-end-marker 'silent)
|
|
515 (yank)
|
|
516 (save-excursion
|
|
517 (goto-char (region-beginning))
|
|
518 (setq ws-block-begin-marker (point-marker))
|
|
519 (goto-char (region-end))
|
|
520 (setq ws-block-end-marker (point-marker))))
|
|
521 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
522 (ws-block-end-marker "Block begin marker not set")
|
|
523 (t "Block markers not set")))))
|
|
524
|
|
525 (defun ws-write-block ()
|
|
526 "In WordStar mode: Write block to file."
|
|
527 (interactive)
|
|
528 (if (and ws-block-begin-marker ws-block-end-marker)
|
|
529 (let ((filename (read-file-name "Write block to file: ")))
|
|
530 (write-region ws-block-begin-marker ws-block-end-marker filename))
|
|
531 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
532 (ws-block-end-marker "Block begin marker not set")
|
|
533 (t "Block markers not set")))))
|
|
534
|
|
535
|
|
536 (defun ws-delete-block ()
|
|
537 "In WordStar mode: Delete block."
|
|
538 (interactive)
|
|
539 (if (and ws-block-begin-marker ws-block-end-marker)
|
|
540 (let ()
|
|
541 (kill-region ws-block-begin-marker ws-block-end-marker)
|
|
542 (setq ws-block-end-marker nil)
|
|
543 (setq ws-block-begin-marker nil))
|
|
544 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
545 (ws-block-end-marker "Block begin marker not set")
|
|
546 (t "Block markers not set")))))
|
|
547
|
|
548 (defun ws-find-marker-0 ()
|
|
549 "In WordStar mode: Go to marker 0."
|
|
550 (interactive)
|
|
551 (if ws-marker-0
|
|
552 (let ()
|
|
553 (setq ws-last-cursorposition (point-marker))
|
|
554 (goto-char ws-marker-0))
|
|
555 (ws-error "Marker 0 not set")))
|
|
556
|
|
557 (defun ws-find-marker-1 ()
|
|
558 "In WordStar mode: Go to marker 1."
|
|
559 (interactive)
|
|
560 (if ws-marker-1
|
|
561 (let ()
|
|
562 (setq ws-last-cursorposition (point-marker))
|
|
563 (goto-char ws-marker-1))
|
|
564 (ws-error "Marker 1 not set")))
|
|
565
|
|
566 (defun ws-find-marker-2 ()
|
|
567 "In WordStar mode: Go to marker 2."
|
|
568 (interactive)
|
|
569 (if ws-marker-2
|
|
570 (let ()
|
|
571 (setq ws-last-cursorposition (point-marker))
|
|
572 (goto-char ws-marker-2))
|
|
573 (ws-error "Marker 2 not set")))
|
|
574
|
|
575 (defun ws-find-marker-3 ()
|
|
576 "In WordStar mode: Go to marker 3."
|
|
577 (interactive)
|
|
578 (if ws-marker-3
|
|
579 (let ()
|
|
580 (setq ws-last-cursorposition (point-marker))
|
|
581 (goto-char ws-marker-3))
|
|
582 (ws-error "Marker 3 not set")))
|
|
583
|
|
584 (defun ws-find-marker-4 ()
|
|
585 "In WordStar mode: Go to marker 4."
|
|
586 (interactive)
|
|
587 (if ws-marker-4
|
|
588 (let ()
|
|
589 (setq ws-last-cursorposition (point-marker))
|
|
590 (goto-char ws-marker-4))
|
|
591 (ws-error "Marker 4 not set")))
|
|
592
|
|
593 (defun ws-find-marker-5 ()
|
|
594 "In WordStar mode: Go to marker 5."
|
|
595 (interactive)
|
|
596 (if ws-marker-5
|
|
597 (let ()
|
|
598 (setq ws-last-cursorposition (point-marker))
|
|
599 (goto-char ws-marker-5))
|
|
600 (ws-error "Marker 5 not set")))
|
|
601
|
|
602 (defun ws-find-marker-6 ()
|
|
603 "In WordStar mode: Go to marker 6."
|
|
604 (interactive)
|
|
605 (if ws-marker-6
|
|
606 (let ()
|
|
607 (setq ws-last-cursorposition (point-marker))
|
|
608 (goto-char ws-marker-6))
|
|
609 (ws-error "Marker 6 not set")))
|
|
610
|
|
611 (defun ws-find-marker-7 ()
|
|
612 "In WordStar mode: Go to marker 7."
|
|
613 (interactive)
|
|
614 (if ws-marker-7
|
|
615 (let ()
|
|
616 (setq ws-last-cursorposition (point-marker))
|
|
617 (goto-char ws-marker-7))
|
|
618 (ws-error "Marker 7 not set")))
|
|
619
|
|
620 (defun ws-find-marker-8 ()
|
|
621 "In WordStar mode: Go to marker 8."
|
|
622 (interactive)
|
|
623 (if ws-marker-8
|
|
624 (let ()
|
|
625 (setq ws-last-cursorposition (point-marker))
|
|
626 (goto-char ws-marker-8))
|
|
627 (ws-error "Marker 8 not set")))
|
|
628
|
|
629 (defun ws-find-marker-9 ()
|
|
630 "In WordStar mode: Go to marker 9."
|
|
631 (interactive)
|
|
632 (if ws-marker-9
|
|
633 (let ()
|
|
634 (setq ws-last-cursorposition (point-marker))
|
|
635 (goto-char ws-marker-9))
|
|
636 (ws-error "Marker 9 not set")))
|
|
637
|
|
638 (defun ws-goto-block-begin ()
|
|
639 "In WordStar mode: Go to block begin marker."
|
|
640 (interactive)
|
|
641 (if ws-block-begin-marker
|
|
642 (let ()
|
|
643 (setq ws-last-cursorposition (point-marker))
|
|
644 (goto-char ws-block-begin-marker))
|
|
645 (ws-error "Block begin marker not set")))
|
|
646
|
|
647 (defun ws-search (string)
|
|
648 "In WordStar mode: Search string, remember string for repetition."
|
|
649 (interactive "sSearch for: ")
|
|
650 (message "Forward (f) or backward (b)")
|
|
651 (let ((direction
|
|
652 (read-char)))
|
|
653 (cond ((equal (upcase direction) ?\F)
|
|
654 (setq ws-search-string string)
|
|
655 (setq ws-search-direction t)
|
|
656 (setq ws-last-cursorposition (point-marker))
|
|
657 (search-forward string))
|
|
658 ((equal (upcase direction) ?\B)
|
|
659 (setq ws-search-string string)
|
|
660 (setq ws-search-direction nil)
|
|
661 (setq ws-last-cursorposition (point-marker))
|
|
662 (search-backward string))
|
|
663 (t (keyboard-quit)))))
|
|
664
|
|
665 (defun ws-goto-block-end ()
|
|
666 "In WordStar mode: Go to block end marker."
|
|
667 (interactive)
|
|
668 (if ws-block-end-marker
|
|
669 (let ()
|
|
670 (setq ws-last-cursorposition (point-marker))
|
|
671 (goto-char ws-block-end-marker))
|
|
672 (ws-error "Block end marker not set")))
|
|
673
|
|
674 (defun ws-undo ()
|
|
675 "In WordStar mode: Undo and give message about undoing more changes."
|
|
676 (interactive)
|
|
677 (undo)
|
|
678 (message "Repeat C-q l to undo more changes."))
|
|
679
|
|
680 (defun ws-goto-last-cursorposition ()
|
|
681 "In WordStar mode: "
|
|
682 (interactive)
|
|
683 (if ws-last-cursorposition
|
|
684 (let ()
|
|
685 (setq ws-last-cursorposition (point-marker))
|
|
686 (goto-char ws-last-cursorposition))
|
|
687 (ws-error "No last cursor position available.")))
|
|
688
|
|
689 (defun ws-last-error ()
|
|
690 "In WordStar mode: repeat last error message.
|
|
691 This will only work for errors raised by WordStar mode functions."
|
|
692 (interactive)
|
|
693 (if ws-last-errormessage
|
|
694 (message ws-last-errormessage)
|
|
695 (message "No WordStar error yet.")))
|
|
696
|
|
697 (defun ws-kill-eol ()
|
|
698 "In WordStar mode: Kill to end of line (like WordStar, not like Emacs)."
|
|
699 (interactive)
|
|
700 (let ((p (point)))
|
|
701 (end-of-line)
|
|
702 (kill-region p (point))))
|
|
703
|
|
704 (defun ws-kill-bol ()
|
|
705 "In WordStar mode: Kill to beginning of line
|
72
|
706 \(like WordStar, not like Emacs)."
|
0
|
707 (interactive)
|
|
708 (let ((p (point)))
|
|
709 (beginning-of-line)
|
|
710 (kill-region (point) p)))
|
|
711
|
|
712 (defun kill-complete-line ()
|
|
713 "Kill the complete line."
|
|
714 (interactive)
|
|
715 (beginning-of-line)
|
|
716 (if (eobp) (error "End of buffer"))
|
|
717 (let ((beg (point)))
|
|
718 (forward-line 1)
|
|
719 (kill-region beg (point))))
|
|
720
|
|
721 (defun ws-repeat-search ()
|
|
722 "In WordStar mode: Repeat last search."
|
|
723 (interactive)
|
|
724 (setq ws-last-cursorposition (point-marker))
|
|
725 (if ws-search-string
|
|
726 (if ws-search-direction
|
|
727 (search-forward ws-search-string)
|
|
728 (search-backward ws-search-string))
|
|
729 (ws-error "No search to repeat")))
|
|
730
|
|
731 (defun ws-query-replace (from to)
|
|
732 "In WordStar mode: Search string, remember string for repetition."
|
|
733 (interactive "sReplace:
|
|
734 sWith: " )
|
|
735 (setq ws-search-string from)
|
|
736 (setq ws-search-direction t)
|
|
737 (setq ws-last-cursorposition (point-marker))
|
|
738 (query-replace from to))
|
|
739
|
|
740 (defun ws-copy-block ()
|
|
741 "In WordStar mode: Copy block to current cursor position."
|
|
742 (interactive)
|
|
743 (if (and ws-block-begin-marker ws-block-end-marker)
|
|
744 (let ()
|
|
745 (copy-region-as-kill ws-block-begin-marker ws-block-end-marker)
|
|
746 (yank)
|
|
747 (save-excursion
|
|
748 (goto-char (region-beginning))
|
|
749 (setq ws-block-begin-marker (point-marker))
|
|
750 (goto-char (region-end))
|
|
751 (setq ws-block-end-marker (point-marker))))
|
|
752 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
|
|
753 (ws-block-end-marker "Block begin marker not set")
|
|
754 (t "Block markers not set")))))
|
|
755
|
|
756 ;;; ws-mode.el ends here
|