Remove more compilation warnings in MinGW64 build
[emacs.git] / lisp / obsolete / ws-mode.el
blob62cccf725af39a95a6dc69bd6590cf1e7a7a7476
1 ;;; ws-mode.el --- WordStar emulation mode for GNU Emacs
3 ;; Copyright (C) 1991, 2001-2017 Free Software Foundation, Inc.
5 ;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de>
6 ;; Version: 0.7
7 ;; Keywords: emulations
8 ;; Obsolete-since: 24.5
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;; This emulates WordStar, with a major mode.
29 ;;; Code:
30 (defvar wordstar-C-k-map
31 (let ((map (make-keymap)))
32 (define-key map " " ())
33 (define-key map "0" 'ws-set-marker-0)
34 (define-key map "1" 'ws-set-marker-1)
35 (define-key map "2" 'ws-set-marker-2)
36 (define-key map "3" 'ws-set-marker-3)
37 (define-key map "4" 'ws-set-marker-4)
38 (define-key map "5" 'ws-set-marker-5)
39 (define-key map "6" 'ws-set-marker-6)
40 (define-key map "7" 'ws-set-marker-7)
41 (define-key map "8" 'ws-set-marker-8)
42 (define-key map "9" 'ws-set-marker-9)
43 (define-key map "b" 'ws-begin-block)
44 (define-key map "\C-b" 'ws-begin-block)
45 (define-key map "c" 'ws-copy-block)
46 (define-key map "\C-c" 'ws-copy-block)
47 (define-key map "d" 'save-buffers-kill-emacs)
48 (define-key map "\C-d" 'save-buffers-kill-emacs)
49 (define-key map "f" 'find-file)
50 (define-key map "\C-f" 'find-file)
51 (define-key map "h" 'ws-show-markers)
52 (define-key map "\C-h" 'ws-show-markers)
53 (define-key map "i" 'ws-indent-block)
54 (define-key map "\C-i" 'ws-indent-block)
55 (define-key map "k" 'ws-end-block)
56 (define-key map "\C-k" 'ws-end-block)
57 (define-key map "p" 'ws-print-block)
58 (define-key map "\C-p" 'ws-print-block)
59 (define-key map "q" 'kill-emacs)
60 (define-key map "\C-q" 'kill-emacs)
61 (define-key map "r" 'insert-file)
62 (define-key map "\C-r" 'insert-file)
63 (define-key map "s" 'save-some-buffers)
64 (define-key map "\C-s" 'save-some-buffers)
65 (define-key map "t" 'ws-mark-word)
66 (define-key map "\C-t" 'ws-mark-word)
67 (define-key map "u" 'ws-exdent-block)
68 (define-key map "\C-u" 'keyboard-quit)
69 (define-key map "v" 'ws-move-block)
70 (define-key map "\C-v" 'ws-move-block)
71 (define-key map "w" 'ws-write-block)
72 (define-key map "\C-w" 'ws-write-block)
73 (define-key map "x" 'save-buffers-kill-emacs)
74 (define-key map "\C-x" 'save-buffers-kill-emacs)
75 (define-key map "y" 'ws-delete-block)
76 (define-key map "\C-y" 'ws-delete-block)
77 map))
79 (defvar wordstar-C-o-map
80 (let ((map (make-keymap)))
81 (define-key map " " ())
82 (define-key map "c" 'wordstar-center-line)
83 (define-key map "\C-c" 'wordstar-center-line)
84 (define-key map "b" 'switch-to-buffer)
85 (define-key map "\C-b" 'switch-to-buffer)
86 (define-key map "j" 'justify-current-line)
87 (define-key map "\C-j" 'justify-current-line)
88 (define-key map "k" 'kill-buffer)
89 (define-key map "\C-k" 'kill-buffer)
90 (define-key map "l" 'list-buffers)
91 (define-key map "\C-l" 'list-buffers)
92 (define-key map "m" 'auto-fill-mode)
93 (define-key map "\C-m" 'auto-fill-mode)
94 (define-key map "r" 'set-fill-column)
95 (define-key map "\C-r" 'set-fill-column)
96 (define-key map "\C-u" 'keyboard-quit)
97 (define-key map "wd" 'delete-other-windows)
98 (define-key map "wh" 'split-window-right)
99 (define-key map "wo" 'other-window)
100 (define-key map "wv" 'split-window-below)
101 map)
104 (defvar wordstar-C-q-map
105 (let ((map (make-keymap)))
106 (define-key map " " ())
107 (define-key map "0" 'ws-find-marker-0)
108 (define-key map "1" 'ws-find-marker-1)
109 (define-key map "2" 'ws-find-marker-2)
110 (define-key map "3" 'ws-find-marker-3)
111 (define-key map "4" 'ws-find-marker-4)
112 (define-key map "5" 'ws-find-marker-5)
113 (define-key map "6" 'ws-find-marker-6)
114 (define-key map "7" 'ws-find-marker-7)
115 (define-key map "8" 'ws-find-marker-8)
116 (define-key map "9" 'ws-find-marker-9)
117 (define-key map "a" 'ws-query-replace)
118 (define-key map "\C-a" 'ws-query-replace)
119 (define-key map "b" 'ws-goto-block-begin)
120 (define-key map "\C-b" 'ws-goto-block-begin)
121 (define-key map "c" 'end-of-buffer)
122 (define-key map "\C-c" 'end-of-buffer)
123 (define-key map "d" 'end-of-line)
124 (define-key map "\C-d" 'end-of-line)
125 (define-key map "f" 'ws-search)
126 (define-key map "\C-f" 'ws-search)
127 (define-key map "k" 'ws-goto-block-end)
128 (define-key map "\C-k" 'ws-goto-block-end)
129 (define-key map "l" 'ws-undo)
130 (define-key map "\C-l" 'ws-undo)
131 (define-key map "p" 'ws-last-cursorp)
132 (define-key map "\C-p" 'ws-last-cursorp)
133 (define-key map "r" 'beginning-of-buffer)
134 (define-key map "\C-r" 'beginning-of-buffer)
135 (define-key map "s" 'beginning-of-line)
136 (define-key map "\C-s" 'beginning-of-line)
137 (define-key map "\C-u" 'keyboard-quit)
138 (define-key map "w" 'ws-last-error)
139 (define-key map "\C-w" 'ws-last-error)
140 (define-key map "y" 'ws-kill-eol)
141 (define-key map "\C-y" 'ws-kill-eol)
142 (define-key map "\177" 'ws-kill-bol)
143 map))
145 (defvar wordstar-mode-map
146 (let ((map (make-keymap)))
147 (define-key map "\C-a" 'backward-word)
148 (define-key map "\C-b" 'fill-paragraph)
149 (define-key map "\C-c" 'scroll-up-command)
150 (define-key map "\C-d" 'forward-char)
151 (define-key map "\C-e" 'previous-line)
152 (define-key map "\C-f" 'forward-word)
153 (define-key map "\C-g" 'delete-char)
154 (define-key map "\C-h" 'backward-char)
155 (define-key map "\C-i" 'indent-for-tab-command)
156 (define-key map "\C-j" 'help-for-help)
157 (define-key map "\C-k" wordstar-C-k-map)
158 (define-key map "\C-l" 'ws-repeat-search)
159 (define-key map "\C-n" 'open-line)
160 (define-key map "\C-o" wordstar-C-o-map)
161 (define-key map "\C-p" 'quoted-insert)
162 (define-key map "\C-q" wordstar-C-q-map)
163 (define-key map "\C-r" 'scroll-down-command)
164 (define-key map "\C-s" 'backward-char)
165 (define-key map "\C-t" 'kill-word)
166 (define-key map "\C-u" 'keyboard-quit)
167 (define-key map "\C-v" 'overwrite-mode)
168 (define-key map "\C-w" 'scroll-down-line)
169 (define-key map "\C-x" 'next-line)
170 (define-key map "\C-y" 'kill-complete-line)
171 (define-key map "\C-z" 'scroll-up-line)
172 map))
174 ;; wordstar-C-j-map not yet implemented
175 (defvar wordstar-C-j-map nil)
178 (put 'wordstar-mode 'mode-class 'special)
180 ;;;###autoload
181 (define-derived-mode wordstar-mode fundamental-mode "WordStar"
182 "Major mode with WordStar-like key bindings.
184 BUGS:
185 - Help menus with WordStar commands (C-j just calls help-for-help)
186 are not implemented
187 - Options for search and replace
188 - Show markers (C-k h) is somewhat strange
189 - Search and replace (C-q a) is only available in forward direction
191 No key bindings beginning with ESC are installed, they will work
192 Emacs-like.")
195 (defun wordstar-center-paragraph ()
196 "Center each line in the paragraph at or after point.
197 See `wordstar-center-line' for more info."
198 (interactive)
199 (save-excursion
200 (forward-paragraph)
201 (or (bolp) (newline 1))
202 (let ((end (point)))
203 (backward-paragraph)
204 (wordstar-center-region (point) end))))
206 (defun wordstar-center-region (from to)
207 "Center each line starting in the region.
208 See `wordstar-center-line' for more info."
209 (interactive "r")
210 (if (> from to)
211 (let ((tem to))
212 (setq to from from tem)))
213 (save-excursion
214 (save-restriction
215 (narrow-to-region from to)
216 (goto-char from)
217 (while (not (eobp))
218 (wordstar-center-line)
219 (forward-line 1)))))
221 (defun wordstar-center-line ()
222 "Center the line point is on, within the width specified by `fill-column'.
223 This means adjusting the indentation to match
224 the distance between the end of the text and `fill-column'."
225 (interactive)
226 (save-excursion
227 (let (line-length)
228 (beginning-of-line)
229 (delete-horizontal-space)
230 (end-of-line)
231 (delete-horizontal-space)
232 (setq line-length (current-column))
233 (beginning-of-line)
234 (indent-to
235 (+ left-margin
236 (/ (- fill-column left-margin line-length) 2))))))
238 ;;;;;;;;;;;
239 ;; wordstar special variables:
241 (defvar ws-marker-0 nil "Position marker 0 in WordStar mode.")
242 (defvar ws-marker-1 nil "Position marker 1 in WordStar mode.")
243 (defvar ws-marker-2 nil "Position marker 2 in WordStar mode.")
244 (defvar ws-marker-3 nil "Position marker 3 in WordStar mode.")
245 (defvar ws-marker-4 nil "Position marker 4 in WordStar mode.")
246 (defvar ws-marker-5 nil "Position marker 5 in WordStar mode.")
247 (defvar ws-marker-6 nil "Position marker 6 in WordStar mode.")
248 (defvar ws-marker-7 nil "Position marker 7 in WordStar mode.")
249 (defvar ws-marker-8 nil "Position marker 8 in WordStar mode.")
250 (defvar ws-marker-9 nil "Position marker 9 in WordStar mode.")
252 (defvar ws-block-begin-marker nil "Beginning of \"Block\" in WordStar mode.")
253 (defvar ws-block-end-marker nil "End of \"Block\" in WordStar mode.")
255 (defvar ws-search-string nil "String of last search in WordStar mode.")
256 (defvar ws-search-direction t
257 "Direction of last search in WordStar mode. t if forward, nil if backward.")
259 (defvar ws-last-cursorposition nil
260 "Position before last search etc. in WordStar mode.")
262 (defvar ws-last-errormessage nil
263 "Last error message issued by a WordStar mode function.")
265 ;;;;;;;;;;;
266 ;; wordstar special functions:
268 (defun ws-error (string)
269 "Report error of a WordStar special function. Error message is saved
270 in ws-last-errormessage for recovery with C-q w."
271 (setq ws-last-errormessage string)
272 (error string))
274 (defun ws-set-marker-0 ()
275 "In WordStar mode: Set marker 0 to current cursor position."
276 (interactive)
277 (setq ws-marker-0 (point-marker))
278 (message "Marker 0 set"))
280 (defun ws-set-marker-1 ()
281 "In WordStar mode: Set marker 1 to current cursor position."
282 (interactive)
283 (setq ws-marker-1 (point-marker))
284 (message "Marker 1 set"))
286 (defun ws-set-marker-2 ()
287 "In WordStar mode: Set marker 2 to current cursor position."
288 (interactive)
289 (setq ws-marker-2 (point-marker))
290 (message "Marker 2 set"))
292 (defun ws-set-marker-3 ()
293 "In WordStar mode: Set marker 3 to current cursor position."
294 (interactive)
295 (setq ws-marker-3 (point-marker))
296 (message "Marker 3 set"))
298 (defun ws-set-marker-4 ()
299 "In WordStar mode: Set marker 4 to current cursor position."
300 (interactive)
301 (setq ws-marker-4 (point-marker))
302 (message "Marker 4 set"))
304 (defun ws-set-marker-5 ()
305 "In WordStar mode: Set marker 5 to current cursor position."
306 (interactive)
307 (setq ws-marker-5 (point-marker))
308 (message "Marker 5 set"))
310 (defun ws-set-marker-6 ()
311 "In WordStar mode: Set marker 6 to current cursor position."
312 (interactive)
313 (setq ws-marker-6 (point-marker))
314 (message "Marker 6 set"))
316 (defun ws-set-marker-7 ()
317 "In WordStar mode: Set marker 7 to current cursor position."
318 (interactive)
319 (setq ws-marker-7 (point-marker))
320 (message "Marker 7 set"))
322 (defun ws-set-marker-8 ()
323 "In WordStar mode: Set marker 8 to current cursor position."
324 (interactive)
325 (setq ws-marker-8 (point-marker))
326 (message "Marker 8 set"))
328 (defun ws-set-marker-9 ()
329 "In WordStar mode: Set marker 9 to current cursor position."
330 (interactive)
331 (setq ws-marker-9 (point-marker))
332 (message "Marker 9 set"))
334 (defun ws-begin-block ()
335 "In WordStar mode: Set block begin marker to current cursor position."
336 (interactive)
337 (setq ws-block-begin-marker (point-marker))
338 (message "Block begin marker set"))
340 (defun ws-show-markers ()
341 "In WordStar mode: Show block markers."
342 (interactive)
343 (if (or ws-block-begin-marker ws-block-end-marker)
344 (save-excursion
345 (if ws-block-begin-marker
346 (progn
347 (goto-char ws-block-begin-marker)
348 (message "Block begin marker")
349 (sit-for 2))
350 (message "Block begin marker not set")
351 (sit-for 2))
352 (if ws-block-end-marker
353 (progn
354 (goto-char ws-block-end-marker)
355 (message "Block end marker")
356 (sit-for 2))
357 (message "Block end marker not set"))
358 (message ""))
359 (message "Block markers not set")))
362 (defun ws-indent-block ()
363 "In WordStar mode: Indent block (not yet implemented)."
364 (interactive)
365 (ws-error "Indent block not yet implemented"))
367 (defun ws-end-block ()
368 "In WordStar mode: Set block end marker to current cursor position."
369 (interactive)
370 (setq ws-block-end-marker (point-marker))
371 (message "Block end marker set"))
373 (defun ws-print-block ()
374 "In WordStar mode: Print block."
375 (interactive)
376 (message "Don't do this. Write block to a file (C-k w) and print this file."))
378 (defun ws-mark-word ()
379 "In WordStar mode: Mark current word as block."
380 (interactive)
381 (save-excursion
382 (forward-word 1)
383 (sit-for 1)
384 (ws-end-block)
385 (forward-word -1)
386 (sit-for 1)
387 (ws-begin-block)))
389 (defun ws-exdent-block ()
390 "I don't know what this (C-k u) should do."
391 (interactive)
392 (ws-error "This won't be done -- not yet implemented."))
394 (defun ws-move-block ()
395 "In WordStar mode: Move block to current cursor position."
396 (interactive)
397 (if (and ws-block-begin-marker ws-block-end-marker)
398 (progn
399 (kill-region ws-block-begin-marker ws-block-end-marker)
400 (yank)
401 (save-excursion
402 (goto-char (region-beginning))
403 (setq ws-block-begin-marker (point-marker))
404 (goto-char (region-end))
405 (setq ws-block-end-marker (point-marker))))
406 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
407 (ws-block-end-marker "Block begin marker not set")
408 (t "Block markers not set")))))
410 (defun ws-write-block ()
411 "In WordStar mode: Write block to file."
412 (interactive)
413 (if (and ws-block-begin-marker ws-block-end-marker)
414 (let ((filename (read-file-name "Write block to file: ")))
415 (write-region ws-block-begin-marker ws-block-end-marker filename))
416 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
417 (ws-block-end-marker "Block begin marker not set")
418 (t "Block markers not set")))))
421 (defun ws-delete-block ()
422 "In WordStar mode: Delete block."
423 (interactive)
424 (if (and ws-block-begin-marker ws-block-end-marker)
425 (progn
426 (kill-region ws-block-begin-marker ws-block-end-marker)
427 (setq ws-block-end-marker nil)
428 (setq ws-block-begin-marker nil))
429 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
430 (ws-block-end-marker "Block begin marker not set")
431 (t "Block markers not set")))))
433 (defun ws-find-marker-0 ()
434 "In WordStar mode: Go to marker 0."
435 (interactive)
436 (if ws-marker-0
437 (progn
438 (setq ws-last-cursorposition (point-marker))
439 (goto-char ws-marker-0))
440 (ws-error "Marker 0 not set")))
442 (defun ws-find-marker-1 ()
443 "In WordStar mode: Go to marker 1."
444 (interactive)
445 (if ws-marker-1
446 (progn
447 (setq ws-last-cursorposition (point-marker))
448 (goto-char ws-marker-1))
449 (ws-error "Marker 1 not set")))
451 (defun ws-find-marker-2 ()
452 "In WordStar mode: Go to marker 2."
453 (interactive)
454 (if ws-marker-2
455 (progn
456 (setq ws-last-cursorposition (point-marker))
457 (goto-char ws-marker-2))
458 (ws-error "Marker 2 not set")))
460 (defun ws-find-marker-3 ()
461 "In WordStar mode: Go to marker 3."
462 (interactive)
463 (if ws-marker-3
464 (progn
465 (setq ws-last-cursorposition (point-marker))
466 (goto-char ws-marker-3))
467 (ws-error "Marker 3 not set")))
469 (defun ws-find-marker-4 ()
470 "In WordStar mode: Go to marker 4."
471 (interactive)
472 (if ws-marker-4
473 (progn
474 (setq ws-last-cursorposition (point-marker))
475 (goto-char ws-marker-4))
476 (ws-error "Marker 4 not set")))
478 (defun ws-find-marker-5 ()
479 "In WordStar mode: Go to marker 5."
480 (interactive)
481 (if ws-marker-5
482 (progn
483 (setq ws-last-cursorposition (point-marker))
484 (goto-char ws-marker-5))
485 (ws-error "Marker 5 not set")))
487 (defun ws-find-marker-6 ()
488 "In WordStar mode: Go to marker 6."
489 (interactive)
490 (if ws-marker-6
491 (progn
492 (setq ws-last-cursorposition (point-marker))
493 (goto-char ws-marker-6))
494 (ws-error "Marker 6 not set")))
496 (defun ws-find-marker-7 ()
497 "In WordStar mode: Go to marker 7."
498 (interactive)
499 (if ws-marker-7
500 (progn
501 (setq ws-last-cursorposition (point-marker))
502 (goto-char ws-marker-7))
503 (ws-error "Marker 7 not set")))
505 (defun ws-find-marker-8 ()
506 "In WordStar mode: Go to marker 8."
507 (interactive)
508 (if ws-marker-8
509 (progn
510 (setq ws-last-cursorposition (point-marker))
511 (goto-char ws-marker-8))
512 (ws-error "Marker 8 not set")))
514 (defun ws-find-marker-9 ()
515 "In WordStar mode: Go to marker 9."
516 (interactive)
517 (if ws-marker-9
518 (progn
519 (setq ws-last-cursorposition (point-marker))
520 (goto-char ws-marker-9))
521 (ws-error "Marker 9 not set")))
523 (defun ws-goto-block-begin ()
524 "In WordStar mode: Go to block begin marker."
525 (interactive)
526 (if ws-block-begin-marker
527 (progn
528 (setq ws-last-cursorposition (point-marker))
529 (goto-char ws-block-begin-marker))
530 (ws-error "Block begin marker not set")))
532 (defun ws-search (string)
533 "In WordStar mode: Search string, remember string for repetition."
534 (interactive "sSearch for: ")
535 (message "Forward (f) or backward (b)")
536 (let ((direction
537 (read-char)))
538 (cond ((equal (upcase direction) ?F)
539 (setq ws-search-string string)
540 (setq ws-search-direction t)
541 (setq ws-last-cursorposition (point-marker))
542 (search-forward string))
543 ((equal (upcase direction) ?B)
544 (setq ws-search-string string)
545 (setq ws-search-direction nil)
546 (setq ws-last-cursorposition (point-marker))
547 (search-backward string))
548 (t (keyboard-quit)))))
550 (defun ws-goto-block-end ()
551 "In WordStar mode: Go to block end marker."
552 (interactive)
553 (if ws-block-end-marker
554 (progn
555 (setq ws-last-cursorposition (point-marker))
556 (goto-char ws-block-end-marker))
557 (ws-error "Block end marker not set")))
559 (defun ws-undo ()
560 "In WordStar mode: Undo and give message about undoing more changes."
561 (interactive)
562 (undo)
563 (message "Repeat C-q l to undo more changes."))
565 (defun ws-goto-last-cursorposition ()
566 "In WordStar mode: "
567 (interactive)
568 (if ws-last-cursorposition
569 (progn
570 (setq ws-last-cursorposition (point-marker))
571 (goto-char ws-last-cursorposition))
572 (ws-error "No last cursor position available.")))
574 (defun ws-last-error ()
575 "In WordStar mode: repeat last error message.
576 This will only work for errors raised by WordStar mode functions."
577 (interactive)
578 (if ws-last-errormessage
579 (message "%s" ws-last-errormessage)
580 (message "No WordStar error yet.")))
582 (defun ws-kill-eol ()
583 "In WordStar mode: Kill to end of line (like WordStar, not like Emacs)."
584 (interactive)
585 (let ((p (point)))
586 (end-of-line)
587 (kill-region p (point))))
589 (defun ws-kill-bol ()
590 "In WordStar mode: Kill to beginning of line
591 \(like WordStar, not like Emacs)."
592 (interactive)
593 (let ((p (point)))
594 (beginning-of-line)
595 (kill-region (point) p)))
597 (defun kill-complete-line ()
598 "Kill the complete line."
599 (interactive)
600 (beginning-of-line)
601 (if (eobp) (error "End of buffer"))
602 (let ((beg (point)))
603 (forward-line 1)
604 (kill-region beg (point))))
606 (defun ws-repeat-search ()
607 "In WordStar mode: Repeat last search."
608 (interactive)
609 (setq ws-last-cursorposition (point-marker))
610 (if ws-search-string
611 (if ws-search-direction
612 (search-forward ws-search-string)
613 (search-backward ws-search-string))
614 (ws-error "No search to repeat")))
616 (defun ws-query-replace (from to)
617 "In WordStar mode: Search string, remember string for repetition."
618 (interactive "sReplace: \n\
619 sWith: " )
620 (setq ws-search-string from)
621 (setq ws-search-direction t)
622 (setq ws-last-cursorposition (point-marker))
623 (query-replace from to))
625 (defun ws-copy-block ()
626 "In WordStar mode: Copy block to current cursor position."
627 (interactive)
628 (if (and ws-block-begin-marker ws-block-end-marker)
629 (progn
630 (copy-region-as-kill ws-block-begin-marker ws-block-end-marker)
631 (yank)
632 (save-excursion
633 (goto-char (region-beginning))
634 (setq ws-block-begin-marker (point-marker))
635 (goto-char (region-end))
636 (setq ws-block-end-marker (point-marker))))
637 (ws-error (cond (ws-block-begin-marker "Block end marker not set")
638 (ws-block-end-marker "Block begin marker not set")
639 (t "Block markers not set")))))
641 (provide 'ws-mode)
643 ;;; ws-mode.el ends here