Switch to recommended form of GPLv3 permissions notice.
[bpt/emacs.git] / lisp / emulation / ws-mode.el
index d0fb619..d8a2fa2 100644 (file)
@@ -1,6 +1,7 @@
 ;;; ws-mode.el --- WordStar emulation mode for GNU Emacs
 
-;; Copyright (C) 1991 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Juergen Nickelsen <nickel@cs.tu-berlin.de>
 ;; Version: 0.7
@@ -8,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,8 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -41,7 +41,7 @@
   (setq wordstar-C-k-map (make-keymap))
   (setq wordstar-C-o-map (make-keymap))
   (setq wordstar-C-q-map (make-keymap))
-  
+
   (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)
@@ -67,9 +67,9 @@
   (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
-  
+
   (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 "\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
-  
+
   (define-key wordstar-C-o-map " " ())
-  (define-key wordstar-C-o-map "c" 'center-line)
-  (define-key wordstar-C-o-map "\C-c" 'center-line)
+  (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 "wh" 'split-window-horizontally)
   (define-key wordstar-C-o-map "wo" 'other-window)
   (define-key wordstar-C-o-map "wv" 'split-window-vertically)
-  
+
   ;; 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 "\C-y" 'ws-kill-eol)
   (define-key wordstar-C-q-map "\177" 'ws-kill-bol))
 
+(put 'wordstar-mode 'mode-class 'special)
+
 ;;;###autoload
 (defun wordstar-mode ()
   "Major mode with WordStar-like key bindings.
@@ -249,7 +251,7 @@ The key bindings are:
   C-k x                kill-emacs
   C-k y                ws-delete-block
 
-  C-o c                center-line
+  C-o c                wordstar-center-line
   C-o b                switch-to-buffer
   C-o j                justify-current-line
   C-o k                kill-buffer
@@ -290,23 +292,24 @@ The key bindings are:
   (kill-all-local-variables)
   (use-local-map wordstar-mode-map)
   (setq mode-name "WordStar")
-  (setq major-mode 'wordstar-mode))
+  (setq major-mode 'wordstar-mode)
+  (run-mode-hooks 'wordstar-mode-hook))
 
 
-(defun center-paragraph ()
+(defun wordstar-center-paragraph ()
   "Center each line in the paragraph at or after point.
-See center-line for more info."
+See `wordstar-center-line' for more info."
   (interactive)
   (save-excursion
     (forward-paragraph)
     (or (bolp) (newline 1))
     (let ((end (point)))
       (backward-paragraph)
-      (center-region (point) end))))
+      (wordstar-center-region (point) end))))
 
-(defun center-region (from to)
+(defun wordstar-center-region (from to)
   "Center each line starting in the region.
-See center-line for more info."
+See `wordstar-center-line' for more info."
   (interactive "r")
   (if (> from to)
       (let ((tem to))
@@ -316,10 +319,10 @@ See center-line for more info."
       (narrow-to-region from to)
       (goto-char from)
       (while (not (eobp))
-       (center-line)
+       (wordstar-center-line)
        (forward-line 1)))))
 
-(defun center-line ()
+(defun wordstar-center-line ()
   "Center the line point is on, within the width specified by `fill-column'.
 This means adjusting the indentation to match
 the distance between the end of the text and `fill-column'."
@@ -332,8 +335,8 @@ the distance between the end of the text and `fill-column'."
       (delete-horizontal-space)
       (setq line-length (current-column))
       (beginning-of-line)
-      (indent-to 
-       (+ left-margin 
+      (indent-to
+       (+ left-margin
          (/ (- fill-column left-margin line-length) 2))))))
 
 (defun scroll-down-line ()
@@ -364,13 +367,13 @@ the distance between the end of the text and `fill-column'."
 (defvar ws-block-end-marker nil "End of \"Block\" in WordStar mode.")
 
 (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.")
+(defvar ws-search-direction t
+  "Direction of last search in WordStar mode. t if forward, nil if backward.")
 
-(defvar ws-last-cursorposition nil 
+(defvar ws-last-cursorposition nil
   "Position before last search etc. in WordStar mode.")
 
-(defvar ws-last-errormessage nil 
+(defvar ws-last-errormessage nil
   "Last error message issued by a WordStar mode function.")
 
 ;;;;;;;;;;;
@@ -506,7 +509,7 @@ in ws-last-errormessage for recovery with C-q w."
   "In WordStar mode: Move block to current cursor position."
   (interactive)
   (if (and ws-block-begin-marker ws-block-end-marker)
-      (let () 
+      (let ()
        (kill-region ws-block-begin-marker ws-block-end-marker)
        (yank)
        (save-excursion
@@ -646,12 +649,12 @@ in ws-last-errormessage for recovery with C-q w."
   (message "Forward (f) or backward (b)")
   (let ((direction
         (read-char)))
-    (cond ((equal (upcase direction) \070)
+    (cond ((equal (upcase direction) ?F)
           (setq ws-search-string string)
           (setq ws-search-direction t)
           (setq ws-last-cursorposition (point-marker))
           (search-forward string))
-         ((equal (upcase direction) \066)
+         ((equal (upcase direction) ?B)
           (setq ws-search-string string)
           (setq ws-search-direction nil)
           (setq ws-last-cursorposition (point-marker))
@@ -687,7 +690,7 @@ in ws-last-errormessage for recovery with C-q w."
 This will only work for errors raised by WordStar mode functions."
   (interactive)
   (if ws-last-errormessage
-      (message ws-last-errormessage)
+      (message "%s" ws-last-errormessage)
     (message "No WordStar error yet.")))
 
 (defun ws-kill-eol ()
@@ -698,7 +701,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 
+  "In WordStar mode: Kill to beginning of line
 \(like WordStar, not like Emacs)."
   (interactive)
   (let ((p (point)))
@@ -726,7 +729,7 @@ This will only work for errors raised by WordStar mode functions."
 
 (defun ws-query-replace (from to)
   "In WordStar mode: Search string, remember string for repetition."
-  (interactive "sReplace: 
+  (interactive "sReplace:
 sWith: " )
   (setq ws-search-string from)
   (setq ws-search-direction t)
@@ -749,4 +752,7 @@ sWith: " )
                    (ws-block-end-marker "Block begin marker not set")
                    (t "Block markers not set")))))
 
+(provide 'ws-mode)
+
+;; arch-tag: 6dd864bf-2ccb-4d59-af6e-492eba2890a3
 ;;; ws-mode.el ends here