diff options
Diffstat (limited to 'lisp/obsolete/ws-mode.el')
-rw-r--r-- | lisp/obsolete/ws-mode.el | 240 |
1 files changed, 68 insertions, 172 deletions
diff --git a/lisp/obsolete/ws-mode.el b/lisp/obsolete/ws-mode.el index 05dca959dad..16156106710 100644 --- a/lisp/obsolete/ws-mode.el +++ b/lisp/obsolete/ws-mode.el @@ -1,4 +1,4 @@ -;;; ws-mode.el --- WordStar emulation mode for GNU Emacs +;;; ws-mode.el --- WordStar emulation mode for GNU Emacs -*- lexical-binding: t -*- ;; Copyright (C) 1991, 2001-2019 Free Software Foundation, Inc. @@ -24,9 +24,20 @@ ;;; Commentary: -;; This emulates WordStar, with a major mode. +;; This provides emulation of WordStar with a minor mode. ;;; Code: + +(defgroup wordstar nil + "WordStar emulation within Emacs." + :prefix "wordstar-" + :prefix "ws-" + :group 'emulations) + +(defcustom wordstar-mode-lighter " WordStar" + "Lighter shown in the modeline for `wordstar' mode." + :type 'string) + (defvar wordstar-C-k-map (let ((map (make-keymap))) (define-key map " " ()) @@ -98,8 +109,7 @@ (define-key map "wh" 'split-window-right) (define-key map "wo" 'other-window) (define-key map "wv" 'split-window-below) - map) - "") + map)) (defvar wordstar-C-q-map (let ((map (make-keymap))) @@ -174,12 +184,9 @@ ;; wordstar-C-j-map not yet implemented (defvar wordstar-C-j-map nil) - -(put 'wordstar-mode 'mode-class 'special) - ;;;###autoload -(define-derived-mode wordstar-mode fundamental-mode "WordStar" - "Major mode with WordStar-like key bindings. +(define-minor-mode wordstar-mode + "Minor mode with WordStar-like key bindings. BUGS: - Help menus with WordStar commands (C-j just calls help-for-help) @@ -189,8 +196,18 @@ BUGS: - Search and replace (C-q a) is only available in forward direction No key bindings beginning with ESC are installed, they will work -Emacs-like.") +Emacs-like." + :group 'wordstar + :lighter wordstar-mode-lighter + :keymap wordstar-mode-map) + +(defun turn-on-wordstar-mode () + (when (and (not (minibufferp)) + (not wordstar-mode)) + (wordstar-mode 1))) +(define-globalized-minor-mode global-wordstar-mode wordstar-mode + turn-on-wordstar-mode) (defun wordstar-center-paragraph () "Center each line in the paragraph at or after point. @@ -254,7 +271,7 @@ the distance between the end of the text and `fill-column'." (defvar ws-search-string nil "String of last search in WordStar mode.") (defvar ws-search-direction t - "Direction of last search in WordStar mode. t if forward, nil if backward.") + "Direction of last search in WordStar mode. t if forward, nil if backward.") (defvar ws-last-cursorposition nil "Position before last search etc. in WordStar mode.") @@ -266,71 +283,12 @@ the distance between the end of the text and `fill-column'." ;; wordstar special functions: (defun ws-error (string) - "Report error of a WordStar special function. Error message is saved -in ws-last-errormessage for recovery with C-q w." + "Report error of a WordStar special function. +Error message is saved in `ws-last-errormessage' for recovery +with C-q w." (setq ws-last-errormessage string) (error string)) -(defun ws-set-marker-0 () - "In WordStar mode: Set marker 0 to current cursor position." - (interactive) - (setq ws-marker-0 (point-marker)) - (message "Marker 0 set")) - -(defun ws-set-marker-1 () - "In WordStar mode: Set marker 1 to current cursor position." - (interactive) - (setq ws-marker-1 (point-marker)) - (message "Marker 1 set")) - -(defun ws-set-marker-2 () - "In WordStar mode: Set marker 2 to current cursor position." - (interactive) - (setq ws-marker-2 (point-marker)) - (message "Marker 2 set")) - -(defun ws-set-marker-3 () - "In WordStar mode: Set marker 3 to current cursor position." - (interactive) - (setq ws-marker-3 (point-marker)) - (message "Marker 3 set")) - -(defun ws-set-marker-4 () - "In WordStar mode: Set marker 4 to current cursor position." - (interactive) - (setq ws-marker-4 (point-marker)) - (message "Marker 4 set")) - -(defun ws-set-marker-5 () - "In WordStar mode: Set marker 5 to current cursor position." - (interactive) - (setq ws-marker-5 (point-marker)) - (message "Marker 5 set")) - -(defun ws-set-marker-6 () - "In WordStar mode: Set marker 6 to current cursor position." - (interactive) - (setq ws-marker-6 (point-marker)) - (message "Marker 6 set")) - -(defun ws-set-marker-7 () - "In WordStar mode: Set marker 7 to current cursor position." - (interactive) - (setq ws-marker-7 (point-marker)) - (message "Marker 7 set")) - -(defun ws-set-marker-8 () - "In WordStar mode: Set marker 8 to current cursor position." - (interactive) - (setq ws-marker-8 (point-marker)) - (message "Marker 8 set")) - -(defun ws-set-marker-9 () - "In WordStar mode: Set marker 9 to current cursor position." - (interactive) - (setq ws-marker-9 (point-marker)) - (message "Marker 9 set")) - (defun ws-begin-block () "In WordStar mode: Set block begin marker to current cursor position." (interactive) @@ -358,7 +316,6 @@ in ws-last-errormessage for recovery with C-q w." (message "")) (message "Block markers not set"))) - (defun ws-indent-block () "In WordStar mode: Indent block (not yet implemented)." (interactive) @@ -373,7 +330,7 @@ in ws-last-errormessage for recovery with C-q w." (defun ws-print-block () "In WordStar mode: Print block." (interactive) - (message "Don't do this. Write block to a file (C-k w) and print this file.")) + (message "Don't do this. Write block to a file (C-k w) and print this file")) (defun ws-mark-word () "In WordStar mode: Mark current word as block." @@ -389,7 +346,7 @@ in ws-last-errormessage for recovery with C-q w." (defun ws-exdent-block () "I don't know what this (C-k u) should do." (interactive) - (ws-error "This won't be done -- not yet implemented.")) + (ws-error "This won't be done -- not yet implemented")) (defun ws-move-block () "In WordStar mode: Move block to current cursor position." @@ -430,96 +387,6 @@ in ws-last-errormessage for recovery with C-q w." (ws-block-end-marker "Block begin marker not set") (t "Block markers not set"))))) -(defun ws-find-marker-0 () - "In WordStar mode: Go to marker 0." - (interactive) - (if ws-marker-0 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-0)) - (ws-error "Marker 0 not set"))) - -(defun ws-find-marker-1 () - "In WordStar mode: Go to marker 1." - (interactive) - (if ws-marker-1 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-1)) - (ws-error "Marker 1 not set"))) - -(defun ws-find-marker-2 () - "In WordStar mode: Go to marker 2." - (interactive) - (if ws-marker-2 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-2)) - (ws-error "Marker 2 not set"))) - -(defun ws-find-marker-3 () - "In WordStar mode: Go to marker 3." - (interactive) - (if ws-marker-3 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-3)) - (ws-error "Marker 3 not set"))) - -(defun ws-find-marker-4 () - "In WordStar mode: Go to marker 4." - (interactive) - (if ws-marker-4 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-4)) - (ws-error "Marker 4 not set"))) - -(defun ws-find-marker-5 () - "In WordStar mode: Go to marker 5." - (interactive) - (if ws-marker-5 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-5)) - (ws-error "Marker 5 not set"))) - -(defun ws-find-marker-6 () - "In WordStar mode: Go to marker 6." - (interactive) - (if ws-marker-6 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-6)) - (ws-error "Marker 6 not set"))) - -(defun ws-find-marker-7 () - "In WordStar mode: Go to marker 7." - (interactive) - (if ws-marker-7 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-7)) - (ws-error "Marker 7 not set"))) - -(defun ws-find-marker-8 () - "In WordStar mode: Go to marker 8." - (interactive) - (if ws-marker-8 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-8)) - (ws-error "Marker 8 not set"))) - -(defun ws-find-marker-9 () - "In WordStar mode: Go to marker 9." - (interactive) - (if ws-marker-9 - (progn - (setq ws-last-cursorposition (point-marker)) - (goto-char ws-marker-9)) - (ws-error "Marker 9 not set"))) - (defun ws-goto-block-begin () "In WordStar mode: Go to block begin marker." (interactive) @@ -560,16 +427,16 @@ in ws-last-errormessage for recovery with C-q w." "In WordStar mode: Undo and give message about undoing more changes." (interactive) (undo) - (message "Repeat C-q l to undo more changes.")) + (message "Repeat C-q l to undo more changes")) (defun ws-goto-last-cursorposition () - "In WordStar mode: " + "In WordStar mode: Go to position before last search." (interactive) (if ws-last-cursorposition (progn (setq ws-last-cursorposition (point-marker)) (goto-char ws-last-cursorposition)) - (ws-error "No last cursor position available."))) + (ws-error "No last cursor position available"))) (defun ws-last-error () "In WordStar mode: repeat last error message. @@ -577,7 +444,7 @@ This will only work for errors raised by WordStar mode functions." (interactive) (if ws-last-errormessage (message "%s" ws-last-errormessage) - (message "No WordStar error yet."))) + (message "No WordStar error yet"))) (defun ws-kill-eol () "In WordStar mode: Kill to end of line (like WordStar, not like Emacs)." @@ -587,8 +454,7 @@ This will only work for errors raised by WordStar mode functions." (kill-region p (point)))) (defun ws-kill-bol () - "In WordStar mode: Kill to beginning of line -\(like WordStar, not like Emacs)." + "In WordStar mode: Kill to beginning of line (like WordStar, not like Emacs)." (interactive) (let ((p (point))) (beginning-of-line) @@ -638,6 +504,36 @@ sWith: " ) (ws-block-end-marker "Block begin marker not set") (t "Block markers not set"))))) +(defmacro ws-set-marker (&rest indices) + (let (n forms) + (while indices + (setq n (pop indices)) + (push `(defun ,(intern (format "ws-set-marker-%d" n)) () + ,(format "In WordStar mode: Set marker %d to current cursor position" n) + (interactive) + (setq ,(intern (format "ws-marker-%d" n)) (point-marker)) + (message ,(format "Marker %d set" n))) + forms)) + `(progn ,@(nreverse forms)))) + +(ws-set-marker 0 1 2 3 4 5 6 7 8 9) + +(defmacro ws-find-marker (&rest indices) + (let (n forms) + (while indices + (setq n (pop indices)) + (push `(defun ,(intern (format "ws-find-marker-%d" n)) () + ,(format "In WordStar mode: Go to marker %d." n) + (interactive) + (if ,(intern (format "ws-marker-%d" n)) + (progn (setq ws-last-cursorposition (point-marker)) + (goto-char ,(intern (format "ws-marker-%d" n)))) + (ws-error ,(format "Marker %d not set" n)))) + forms)) + `(progn ,@(nreverse forms)))) + +(ws-find-marker 0 1 2 3 4 5 6 7 8 9) + (provide 'ws-mode) ;;; ws-mode.el ends here |