diff lisp/emulation/ws-mode.el @ 110909:cc035ccb9275

Declare and define in one step various mode maps. * lisp/shell.el (shell-mode-map): * lisp/progmodes/modula2.el (m2-mode-map): * lisp/progmodes/inf-lisp.el (inferior-lisp-mode-map): * lisp/play/mpuz.el (mpuz-mode-map): * lisp/play/landmark.el (lm-mode-map): * lisp/play/decipher.el (decipher-mode-map): * lisp/play/5x5.el (5x5-mode-map): * lisp/net/telnet.el (telnet-mode-map): * lisp/net/quickurl.el (quickurl-list-mode-map): * lisp/net/mairix.el (mairix-searches-mode-map): * lisp/net/eudc-hotlist.el (eudc-hotlist-mode-map): * lisp/net/dig.el (dig-mode-map): * lisp/mail/mspools.el (mspools-mode-map): * lisp/hexl.el (hexl-mode-map): * lisp/emulation/ws-mode.el (wordstar-C-k-map, wordstar-mode-map) (wordstar-C-o-map, wordstar-C-q-map): * lisp/emacs-lisp/edebug.el (edebug-eval-mode-map): * lisp/emacs-lisp/chart.el (chart-map): * lisp/edmacro.el (edmacro-mode-map): * lisp/array.el (array-mode-map): Declare and define in one step. * lisp/erc/erc-list.el (erc-list-menu-mode-map): Declare and define in one step.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 10 Oct 2010 16:12:30 -0700
parents 1479a3d1e0f3
children 417b1e4d63cd
line wrap: on
line diff
--- a/lisp/emulation/ws-mode.el	Sun Oct 10 22:48:40 2010 +0000
+++ b/lisp/emulation/ws-mode.el	Sun Oct 10 16:12:30 2010 -0700
@@ -27,158 +27,156 @@
 ;; This emulates WordStar, with a major mode.
 
 ;;; Code:
-
-(defvar wordstar-mode-map nil "")
-(defvar wordstar-C-j-map nil "")
-(defvar wordstar-C-k-map nil "")
-(defvar wordstar-C-o-map nil "")
-(defvar wordstar-C-q-map nil "")
-
-(if wordstar-mode-map
-    ()
-  (setq wordstar-mode-map (make-keymap))
-  ;;  (setq wordstar-C-j-map (make-keymap)) ; later, perhaps
-  (setq wordstar-C-k-map (make-keymap))
-  (setq wordstar-C-o-map (make-keymap))
-  (setq wordstar-C-q-map (make-keymap))
+(defvar wordstar-C-k-map
+  (let ((map (make-keymap)))
+    (define-key map " " ())
+    (define-key map "0" 'ws-set-marker-0)
+    (define-key map "1" 'ws-set-marker-1)
+    (define-key map "2" 'ws-set-marker-2)
+    (define-key map "3" 'ws-set-marker-3)
+    (define-key map "4" 'ws-set-marker-4)
+    (define-key map "5" 'ws-set-marker-5)
+    (define-key map "6" 'ws-set-marker-6)
+    (define-key map "7" 'ws-set-marker-7)
+    (define-key map "8" 'ws-set-marker-8)
+    (define-key map "9" 'ws-set-marker-9)
+    (define-key map "b" 'ws-begin-block)
+    (define-key map "\C-b" 'ws-begin-block)
+    (define-key map "c" 'ws-copy-block)
+    (define-key map "\C-c" 'ws-copy-block)
+    (define-key map "d" 'save-buffers-kill-emacs)
+    (define-key map "\C-d" 'save-buffers-kill-emacs)
+    (define-key map "f" 'find-file)
+    (define-key map "\C-f" 'find-file)
+    (define-key map "h" 'ws-show-markers)
+    (define-key map "\C-h" 'ws-show-markers)
+    (define-key map "i" 'ws-indent-block)
+    (define-key map "\C-i" 'ws-indent-block)
+    (define-key map "k" 'ws-end-block)
+    (define-key map "\C-k" 'ws-end-block)
+    (define-key map "p" 'ws-print-block)
+    (define-key map "\C-p" 'ws-print-block)
+    (define-key map "q" 'kill-emacs)
+    (define-key map "\C-q" 'kill-emacs)
+    (define-key map "r" 'insert-file)
+    (define-key map "\C-r" 'insert-file)
+    (define-key map "s" 'save-some-buffers)
+    (define-key map "\C-s" 'save-some-buffers)
+    (define-key map "t" 'ws-mark-word)
+    (define-key map "\C-t" 'ws-mark-word)
+    (define-key map "u" 'ws-exdent-block)
+    (define-key map "\C-u" 'keyboard-quit)
+    (define-key map "v" 'ws-move-block)
+    (define-key map "\C-v" 'ws-move-block)
+    (define-key map "w" 'ws-write-block)
+    (define-key map "\C-w" 'ws-write-block)
+    (define-key map "x" 'save-buffers-kill-emacs)
+    (define-key map "\C-x" 'save-buffers-kill-emacs)
+    (define-key map "y" 'ws-delete-block)
+    (define-key map "\C-y" 'ws-delete-block)
+    map)
+  "")
 
-  (define-key wordstar-mode-map "\C-a" 'backward-word)
-  (define-key wordstar-mode-map "\C-b" 'fill-paragraph)
-  (define-key wordstar-mode-map "\C-c" 'scroll-up)
-  (define-key wordstar-mode-map "\C-d" 'forward-char)
-  (define-key wordstar-mode-map "\C-e" 'previous-line)
-  (define-key wordstar-mode-map "\C-f" 'forward-word)
-  (define-key wordstar-mode-map "\C-g" 'delete-char)
-  (define-key wordstar-mode-map "\C-h" 'backward-char)
-  (define-key wordstar-mode-map "\C-i" 'indent-for-tab-command)
-  (define-key wordstar-mode-map "\C-j" 'help-for-help)
-  (define-key wordstar-mode-map "\C-k" wordstar-C-k-map)
-  (define-key wordstar-mode-map "\C-l" 'ws-repeat-search)
-  (define-key wordstar-mode-map "\C-n" 'open-line)
-  (define-key wordstar-mode-map "\C-o" wordstar-C-o-map)
-  (define-key wordstar-mode-map "\C-p" 'quoted-insert)
-  (define-key wordstar-mode-map "\C-q" wordstar-C-q-map)
-  (define-key wordstar-mode-map "\C-r" 'scroll-down)
-  (define-key wordstar-mode-map "\C-s" 'backward-char)
-  (define-key wordstar-mode-map "\C-t" 'kill-word)
-  (define-key wordstar-mode-map "\C-u" 'keyboard-quit)
-  (define-key wordstar-mode-map "\C-v" 'overwrite-mode)
-  (define-key wordstar-mode-map "\C-w" 'scroll-down-line)
-  (define-key wordstar-mode-map "\C-x" 'next-line)
-  (define-key wordstar-mode-map "\C-y" 'kill-complete-line)
-  (define-key wordstar-mode-map "\C-z" 'scroll-up-line)
-
-  ;; wordstar-C-k-map
+(defvar wordstar-C-o-map
+  (let ((map (make-keymap)))
+    (define-key map " " ())
+    (define-key map "c" 'wordstar-center-line)
+    (define-key map "\C-c" 'wordstar-center-line)
+    (define-key map "b" 'switch-to-buffer)
+    (define-key map "\C-b" 'switch-to-buffer)
+    (define-key map "j" 'justify-current-line)
+    (define-key map "\C-j" 'justify-current-line)
+    (define-key map "k" 'kill-buffer)
+    (define-key map "\C-k" 'kill-buffer)
+    (define-key map "l" 'list-buffers)
+    (define-key map "\C-l" 'list-buffers)
+    (define-key map "m" 'auto-fill-mode)
+    (define-key map "\C-m" 'auto-fill-mode)
+    (define-key map "r" 'set-fill-column)
+    (define-key map "\C-r" 'set-fill-column)
+    (define-key map "\C-u" 'keyboard-quit)
+    (define-key map "wd" 'delete-other-windows)
+    (define-key map "wh" 'split-window-horizontally)
+    (define-key map "wo" 'other-window)
+    (define-key map "wv" 'split-window-vertically)
+    map)
+  "")
 
-  (define-key wordstar-C-k-map " " ())
-  (define-key wordstar-C-k-map "0" 'ws-set-marker-0)
-  (define-key wordstar-C-k-map "1" 'ws-set-marker-1)
-  (define-key wordstar-C-k-map "2" 'ws-set-marker-2)
-  (define-key wordstar-C-k-map "3" 'ws-set-marker-3)
-  (define-key wordstar-C-k-map "4" 'ws-set-marker-4)
-  (define-key wordstar-C-k-map "5" 'ws-set-marker-5)
-  (define-key wordstar-C-k-map "6" 'ws-set-marker-6)
-  (define-key wordstar-C-k-map "7" 'ws-set-marker-7)
-  (define-key wordstar-C-k-map "8" 'ws-set-marker-8)
-  (define-key wordstar-C-k-map "9" 'ws-set-marker-9)
-  (define-key wordstar-C-k-map "b" 'ws-begin-block)
-  (define-key wordstar-C-k-map "\C-b" 'ws-begin-block)
-  (define-key wordstar-C-k-map "c" 'ws-copy-block)
-  (define-key wordstar-C-k-map "\C-c" 'ws-copy-block)
-  (define-key wordstar-C-k-map "d" 'save-buffers-kill-emacs)
-  (define-key wordstar-C-k-map "\C-d" 'save-buffers-kill-emacs)
-  (define-key wordstar-C-k-map "f" 'find-file)
-  (define-key wordstar-C-k-map "\C-f" 'find-file)
-  (define-key wordstar-C-k-map "h" 'ws-show-markers)
-  (define-key wordstar-C-k-map "\C-h" 'ws-show-markers)
-  (define-key wordstar-C-k-map "i" 'ws-indent-block)
-  (define-key wordstar-C-k-map "\C-i" 'ws-indent-block)
-  (define-key wordstar-C-k-map "k" 'ws-end-block)
-  (define-key wordstar-C-k-map "\C-k" 'ws-end-block)
-  (define-key wordstar-C-k-map "p" 'ws-print-block)
-  (define-key wordstar-C-k-map "\C-p" 'ws-print-block)
-  (define-key wordstar-C-k-map "q" 'kill-emacs)
-  (define-key wordstar-C-k-map "\C-q" 'kill-emacs)
-  (define-key wordstar-C-k-map "r" 'insert-file)
-  (define-key wordstar-C-k-map "\C-r" 'insert-file)
-  (define-key wordstar-C-k-map "s" 'save-some-buffers)
-  (define-key wordstar-C-k-map "\C-s" 'save-some-buffers)
-  (define-key wordstar-C-k-map "t" 'ws-mark-word)
-  (define-key wordstar-C-k-map "\C-t" 'ws-mark-word)
-  (define-key wordstar-C-k-map "u" 'ws-exdent-block)
-  (define-key wordstar-C-k-map "\C-u" 'keyboard-quit)
-  (define-key wordstar-C-k-map "v" 'ws-move-block)
-  (define-key wordstar-C-k-map "\C-v" 'ws-move-block)
-  (define-key wordstar-C-k-map "w" 'ws-write-block)
-  (define-key wordstar-C-k-map "\C-w" 'ws-write-block)
-  (define-key wordstar-C-k-map "x" 'save-buffers-kill-emacs)
-  (define-key wordstar-C-k-map "\C-x" 'save-buffers-kill-emacs)
-  (define-key wordstar-C-k-map "y" 'ws-delete-block)
-  (define-key wordstar-C-k-map "\C-y" 'ws-delete-block)
-
-  ;; wordstar-C-j-map not yet implemented
-
-  ;; wordstar-C-o-map
+(defvar wordstar-C-q-map
+  (let ((map (make-keymap)))
+    (define-key map " " ())
+    (define-key map "0" 'ws-find-marker-0)
+    (define-key map "1" 'ws-find-marker-1)
+    (define-key map "2" 'ws-find-marker-2)
+    (define-key map "3" 'ws-find-marker-3)
+    (define-key map "4" 'ws-find-marker-4)
+    (define-key map "5" 'ws-find-marker-5)
+    (define-key map "6" 'ws-find-marker-6)
+    (define-key map "7" 'ws-find-marker-7)
+    (define-key map "8" 'ws-find-marker-8)
+    (define-key map "9" 'ws-find-marker-9)
+    (define-key map "a" 'ws-query-replace)
+    (define-key map "\C-a" 'ws-query-replace)
+    (define-key map "b" 'ws-goto-block-begin)
+    (define-key map "\C-b" 'ws-goto-block-begin)
+    (define-key map "c" 'end-of-buffer)
+    (define-key map "\C-c" 'end-of-buffer)
+    (define-key map "d" 'end-of-line)
+    (define-key map "\C-d" 'end-of-line)
+    (define-key map "f" 'ws-search)
+    (define-key map "\C-f" 'ws-search)
+    (define-key map "k" 'ws-goto-block-end)
+    (define-key map "\C-k" 'ws-goto-block-end)
+    (define-key map "l" 'ws-undo)
+    (define-key map "\C-l" 'ws-undo)
+    (define-key map "p" 'ws-last-cursorp)
+    (define-key map "\C-p" 'ws-last-cursorp)
+    (define-key map "r" 'beginning-of-buffer)
+    (define-key map "\C-r" 'beginning-of-buffer)
+    (define-key map "s" 'beginning-of-line)
+    (define-key map "\C-s" 'beginning-of-line)
+    (define-key map "\C-u" 'keyboard-quit)
+    (define-key map "w" 'ws-last-error)
+    (define-key map "\C-w" 'ws-last-error)
+    (define-key map "y" 'ws-kill-eol)
+    (define-key map "\C-y" 'ws-kill-eol)
+    (define-key map "\177" 'ws-kill-bol)
+    map)
+  "")
 
-  (define-key wordstar-C-o-map " " ())
-  (define-key wordstar-C-o-map "c" 'wordstar-center-line)
-  (define-key wordstar-C-o-map "\C-c" 'wordstar-center-line)
-  (define-key wordstar-C-o-map "b" 'switch-to-buffer)
-  (define-key wordstar-C-o-map "\C-b" 'switch-to-buffer)
-  (define-key wordstar-C-o-map "j" 'justify-current-line)
-  (define-key wordstar-C-o-map "\C-j" 'justify-current-line)
-  (define-key wordstar-C-o-map "k" 'kill-buffer)
-  (define-key wordstar-C-o-map "\C-k" 'kill-buffer)
-  (define-key wordstar-C-o-map "l" 'list-buffers)
-  (define-key wordstar-C-o-map "\C-l" 'list-buffers)
-  (define-key wordstar-C-o-map "m" 'auto-fill-mode)
-  (define-key wordstar-C-o-map "\C-m" 'auto-fill-mode)
-  (define-key wordstar-C-o-map "r" 'set-fill-column)
-  (define-key wordstar-C-o-map "\C-r" 'set-fill-column)
-  (define-key wordstar-C-o-map "\C-u" 'keyboard-quit)
-  (define-key wordstar-C-o-map "wd" 'delete-other-windows)
-  (define-key wordstar-C-o-map "wh" 'split-window-horizontally)
-  (define-key wordstar-C-o-map "wo" 'other-window)
-  (define-key wordstar-C-o-map "wv" 'split-window-vertically)
+(defvar wordstar-mode-map 
+  (let ((map (make-keymap)))
+    (define-key map "\C-a" 'backward-word)
+    (define-key map "\C-b" 'fill-paragraph)
+    (define-key map "\C-c" 'scroll-up)
+    (define-key map "\C-d" 'forward-char)
+    (define-key map "\C-e" 'previous-line)
+    (define-key map "\C-f" 'forward-word)
+    (define-key map "\C-g" 'delete-char)
+    (define-key map "\C-h" 'backward-char)
+    (define-key map "\C-i" 'indent-for-tab-command)
+    (define-key map "\C-j" 'help-for-help)
+    (define-key map "\C-k" wordstar-C-k-map)
+    (define-key map "\C-l" 'ws-repeat-search)
+    (define-key map "\C-n" 'open-line)
+    (define-key map "\C-o" wordstar-C-o-map)
+    (define-key map "\C-p" 'quoted-insert)
+    (define-key map "\C-q" wordstar-C-q-map)
+    (define-key map "\C-r" 'scroll-down)
+    (define-key map "\C-s" 'backward-char)
+    (define-key map "\C-t" 'kill-word)
+    (define-key map "\C-u" 'keyboard-quit)
+    (define-key map "\C-v" 'overwrite-mode)
+    (define-key map "\C-w" 'scroll-down-line)
+    (define-key map "\C-x" 'next-line)
+    (define-key map "\C-y" 'kill-complete-line)
+    (define-key map "\C-z" 'scroll-up-line)
+    map)
+  "")
 
-  ;; wordstar-C-q-map
-  (define-key wordstar-C-q-map " " ())
-  (define-key wordstar-C-q-map "0" 'ws-find-marker-0)
-  (define-key wordstar-C-q-map "1" 'ws-find-marker-1)
-  (define-key wordstar-C-q-map "2" 'ws-find-marker-2)
-  (define-key wordstar-C-q-map "3" 'ws-find-marker-3)
-  (define-key wordstar-C-q-map "4" 'ws-find-marker-4)
-  (define-key wordstar-C-q-map "5" 'ws-find-marker-5)
-  (define-key wordstar-C-q-map "6" 'ws-find-marker-6)
-  (define-key wordstar-C-q-map "7" 'ws-find-marker-7)
-  (define-key wordstar-C-q-map "8" 'ws-find-marker-8)
-  (define-key wordstar-C-q-map "9" 'ws-find-marker-9)
-  (define-key wordstar-C-q-map "a" 'ws-query-replace)
-  (define-key wordstar-C-q-map "\C-a" 'ws-query-replace)
-  (define-key wordstar-C-q-map "b" 'ws-goto-block-begin)
-  (define-key wordstar-C-q-map "\C-b" 'ws-goto-block-begin)
-  (define-key wordstar-C-q-map "c" 'end-of-buffer)
-  (define-key wordstar-C-q-map "\C-c" 'end-of-buffer)
-  (define-key wordstar-C-q-map "d" 'end-of-line)
-  (define-key wordstar-C-q-map "\C-d" 'end-of-line)
-  (define-key wordstar-C-q-map "f" 'ws-search)
-  (define-key wordstar-C-q-map "\C-f" 'ws-search)
-  (define-key wordstar-C-q-map "k" 'ws-goto-block-end)
-  (define-key wordstar-C-q-map "\C-k" 'ws-goto-block-end)
-  (define-key wordstar-C-q-map "l" 'ws-undo)
-  (define-key wordstar-C-q-map "\C-l" 'ws-undo)
-  (define-key wordstar-C-q-map "p" 'ws-last-cursorp)
-  (define-key wordstar-C-q-map "\C-p" 'ws-last-cursorp)
-  (define-key wordstar-C-q-map "r" 'beginning-of-buffer)
-  (define-key wordstar-C-q-map "\C-r" 'beginning-of-buffer)
-  (define-key wordstar-C-q-map "s" 'beginning-of-line)
-  (define-key wordstar-C-q-map "\C-s" 'beginning-of-line)
-  (define-key wordstar-C-q-map "\C-u" 'keyboard-quit)
-  (define-key wordstar-C-q-map "w" 'ws-last-error)
-  (define-key wordstar-C-q-map "\C-w" 'ws-last-error)
-  (define-key wordstar-C-q-map "y" 'ws-kill-eol)
-  (define-key wordstar-C-q-map "\C-y" 'ws-kill-eol)
-  (define-key wordstar-C-q-map "\177" 'ws-kill-bol))
+;; wordstar-C-j-map not yet implemented
+(defvar wordstar-C-j-map nil "")
+
 
 (put 'wordstar-mode 'mode-class 'special)