]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/vip.el
Typo.
[gnu-emacs] / lisp / emulation / vip.el
index 588a6c6e31996c6de1e4b2cbe36ab9987f9d1c55..227fe88b1a18516a717b8b6e69841e3c19f00b99 100644 (file)
@@ -1,7 +1,7 @@
 ;;; vip.el --- a VI Package for GNU Emacs
 
-;; Copyright (C) 1986, 1987, 1988, 1992, 1993, 1998
-;;        Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1987, 1988, 1992, 1993, 1998, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Masahiko Sato <ms@sail.stanford.edu>
 ;; Keywords: emulations
@@ -20,8 +20,8 @@
 
 ;; 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, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -49,7 +49,7 @@
 
 (defvar vip-insert-local-map nil
   "Local map used in insert command mode.  (Buffer-specific.)")
-  
+
 (make-variable-buffer-local 'vip-emacs-local-map)
 (make-variable-buffer-local 'vip-insert-local-map)
 
 
 (defvar vip-f-forward nil
   "For use by \";\" command.")
-  
+
 (defvar vip-f-offset nil
   "For use by \";\" command.")
 
@@ -293,9 +293,6 @@ If nil then it is bound to `delete-backward-char'."
 (define-key vip-mode-map "~" 'vip-nil)
 (define-key vip-mode-map "\177" 'vip-delete-backward-char)
 
-(define-key ctl-x-map "3" 'vip-buffer-in-two-windows)
-(define-key ctl-x-map "\C-i" 'insert-file)
-
 (defun vip-version ()
   (interactive)
   (message "VIP version 3.5 of September 15, 1987"))
@@ -303,7 +300,11 @@ If nil then it is bound to `delete-backward-char'."
 \f
 ;; basic set up
 
-(global-set-key "\C-z" 'vip-change-mode-to-vi)
+;;;###autoload
+(defun vip-setup ()
+  "Set up bindings for C-x 7 and C-z that are useful for VIP users."
+  (define-key ctl-x-map "7" 'vip-buffer-in-two-windows)
+  (global-set-key "\C-z" 'vip-change-mode-to-vi))
 
 (defmacro vip-loop (count body)
   "(COUNT BODY) Execute BODY COUNT times."
@@ -378,7 +379,7 @@ No message."
                   'delete-backward-char))
               (define-key vip-insert-local-map "\C-w"
                 'vip-delete-backward-word))
-             ((eq new-mode 'emacs-mode) 
+             ((eq new-mode 'emacs-mode)
               (vip-change-mode-line "Emacs:")
               (use-local-map vip-emacs-local-map)))
        (setq vip-current-mode new-mode)
@@ -508,7 +509,7 @@ EVENTS is a list of events, which become the beginning of the command."
   "Compute numeric prefix arg value.  Invoked by CHAR.  VALUE is the value
 obtained so far, and COM is the command part obtained so far."
   (while (and (>= char ?0) (<= char ?9))
-    (setq value (+ (* (if (numberp value) value 0) 10) (- char ?0)))       
+    (setq value (+ (* (if (numberp value) value 0) 10) (- char ?0)))
     (setq char (read-char)))
   (setq prefix-arg value)
   (if com (setq prefix-arg (cons prefix-arg com)))
@@ -561,7 +562,7 @@ obtained so far, and COM is the command part obtained so far."
               (setq com char)
               (setq char (read-char)))))))
   (if (atom com)
-      ;; com is a single char, so we construct prefix-arg 
+      ;; com is a single char, so we construct prefix-arg
       ;; and if char is ?, describe prefix arg, otherwise exit by
       ;; pushing the char back
       (progn
@@ -615,7 +616,7 @@ obtained so far, and COM is the command part obtained so far."
   (interactive "P")
   (condition-case conditions
       (vip-prefix-arg-com
-       last-command-char   
+       last-command-char
        (cond ((null arg) nil)
             ((consp arg) (car arg))
             ((numberp arg) arg)
@@ -817,7 +818,7 @@ is the name of the register for COM."
          (com (car (cdr (cdr vip-d-com))))
          (reg (nth 3 vip-d-com)))
       (if (null val) (setq val (car (cdr vip-d-com))))
-      (if (null m-com) (error "No previous command to repeat."))
+      (if (null m-com) (error "No previous command to repeat"))
       (setq vip-use-register reg)
       (funcall m-com (cons val com)))))
 
@@ -892,7 +893,7 @@ is the name of the register for COM."
 each line in the region."
   (setq vip-quote-string
        (let ((str
-              (vip-read-string (format "quote string \(default \"%s\"\): "
+              (vip-read-string (format "quote string (default %s): "
                                        vip-quote-string))))
          (if (string= str "") vip-quote-string str)))
   (vip-enlarge-region (point) (mark))
@@ -935,7 +936,7 @@ vi command mode.  It will repeat the insertion command if original insertion
 command was invoked with argument > 1."
   (let ((i-com (car vip-d-com)) (val (car (cdr vip-d-com))))
     (if (and val (> val 1)) ;; first check that val is non-nil
-       (progn        
+       (progn
          (setq vip-d-com (list i-com (1- val) ?r))
          (vip-repeat nil)
          (setq vip-d-com (list i-com val ?r))))))
@@ -1037,7 +1038,7 @@ command was invoked with argument > 1."
          (vip-change-subr (mark) (point))
        (vip-change (mark) (point))))
     (setq vip-d-com (list 'vip-substitute val ?r))))
-  
+
 (defun vip-substitute-line (arg)
   "Substitute lines."
   (interactive "p")
@@ -1057,7 +1058,7 @@ command was invoked with argument > 1."
   (interactive "P")
   (let ((val (vip-p-val arg)))
     (vip-line (cons val ?Y))))
-    
+
 \f
 ;; region command
 
@@ -1076,7 +1077,7 @@ command was invoked with argument > 1."
     (move-marker vip-com-point (point))
     (exchange-point-and-mark)
     (vip-execute-com 'vip-Region val com)))
-  
+
 (defun vip-replace-char (arg)
   "Replace the following ARG chars by the character read."
   (interactive "P")
@@ -1111,9 +1112,10 @@ the query replace mode will toggle between string replace and regexp replace."
            (replace-match (vip-read-string
                            (format "Replace regexp \"%s\" with: " str))
                           nil nil))
-       (replace-string
-        str
-        (vip-read-string (format "Replace \"%s\" with: " str)))))))
+       (with-no-warnings
+         (replace-string
+          str
+          (vip-read-string (format "Replace \"%s\" with: " str))))))))
 
 \f
 ;; basic cursor movement.  j, k, l, m commands.
@@ -1171,7 +1173,7 @@ beginning of buffer, stop and signal error."
        (progn
          (forward-char)
          (vip-execute-com 'vip-end-of-word val com)))))
-                        
+
 (defun vip-backward-word (arg)
   "Backward word."
   (interactive "P")
@@ -1341,7 +1343,7 @@ after search."
 (defun vip-find-char-forward (arg)
   "Find char on the line.  If called interactively read the char to find
 from the terminal, and if called from vip-repeat, the char last used is
-used.  This behaviour is controlled by the sign of prefix numeric value."
+used.  This behavior is controlled by the sign of prefix numeric value."
   (interactive "P")
   (let ((val (vip-p-val arg)) (com (vip-getcom arg)))
     (if (> val 0)
@@ -1499,7 +1501,7 @@ used.  This behaviour is controlled by the sign of prefix numeric value."
   (let ((com (vip-getcom arg)))
     (if (numberp arg)
        (if (or (> arg 99) (< arg 1))
-           (error "Prefix must be between 1 and 99.")
+           (error "Prefix must be between 1 and 99")
          (goto-char
           (if (> (point-max) 80000)
               (* (/ (point-max) 100) arg)
@@ -1693,7 +1695,7 @@ STRING.  Search will be forward if FORWARD, otherwise backward."
   "Repeat previous search."
   (interactive "P")
   (let ((val (vip-p-val arg)) (com (vip-getcom arg)))
-    (if (null vip-s-string) (error "No previous search string."))
+    (if (null vip-s-string) (error "No previous search string"))
     (vip-search vip-s-string vip-s-forward arg)
     (if com (vip-execute-com 'vip-search-next val com))))
 
@@ -1701,7 +1703,7 @@ STRING.  Search will be forward if FORWARD, otherwise backward."
   "Repeat previous search in the reverse direction."
   (interactive "P")
   (let ((val (vip-p-val arg)) (com (vip-getcom arg)))
-    (if (null vip-s-string) (error "No previous search string."))
+    (if (null vip-s-string) (error "No previous search string"))
     (vip-search vip-s-string (not vip-s-forward) arg)
     (if com (vip-execute-com 'vip-search-Next val com))))
 
@@ -1742,11 +1744,11 @@ STRING.  Search will be forward if FORWARD, otherwise backward."
          (if (null buffer-name)
              (current-buffer)
            (get-buffer buffer-name)))
-    (if (null buffer) (error "Buffer %s nonexistent." buffer-name))
+    (if (null buffer) (error "Buffer %s nonexistent" buffer-name))
     (if (or (not (buffer-modified-p buffer))
            (y-or-n-p "Buffer is modified, are you sure? "))
        (kill-buffer buffer)
-      (error "Buffer not killed."))))
+      (error "Buffer not killed"))))
 
 (defun vip-find-file ()
   "Visit file in the current window."
@@ -2176,7 +2178,7 @@ a token has type \(command, address, end-mark\) and value."
                 (cond ((string= ex-token-type "plus") "add-number")
                       ((string= ex-token-type "minus") "sub-number")
                       (t "abs-number")))
-          (setq ex-token (string-to-int (buffer-substring (point) (mark)))))
+          (setq ex-token (string-to-number (buffer-substring (point) (mark)))))
          ((looking-at "\\$")
           (forward-char 1)
           (setq ex-token-type "end"))
@@ -2252,7 +2254,7 @@ a token has type \(command, address, end-mark\) and value."
           (setq ex-token-type "end-mark")
           (setq ex-token "goto"))
          (t
-          (error "illegal token")))))
+          (error "invalid token")))))
 
 (defun vip-ex (&optional string)
   "ex commands within VIP."
@@ -2291,7 +2293,7 @@ a token has type \(command, address, end-mark\) and value."
                             (setq cont nil))
                            (t (error "Extra character at end of a command")))))))
            ((string= ex-token-type "non-command")
-            (error (format "%s: Not an editor command" ex-token)))
+            (error "%s: Not an editor command" ex-token))
            ((string= ex-token-type "whole")
             (setq ex-addresses
                   (cons (point-max) (cons (point-min) ex-addresses))))
@@ -2470,14 +2472,14 @@ a token has type \(command, address, end-mark\) and value."
        (progn
          (set-mark (point))
          (re-search-forward "[0-9][0-9]*")
-         (setq ex-count (string-to-int (buffer-substring (point) (mark))))
+         (setq ex-count (string-to-number (buffer-substring (point) (mark))))
          (skip-chars-forward " \t")))
     (if (looking-at "[pl#]")
        (progn
          (setq ex-flag t)
          (forward-char 1)))
     (if (not (looking-at "[\n|]"))
-       (error "Illegal extra characters"))))
+       (error "Invalid extra characters"))))
 
 (defun vip-get-ex-count ()
   (setq ex-variant nil
@@ -2495,14 +2497,14 @@ a token has type \(command, address, end-mark\) and value."
        (progn
          (set-mark (point))
          (re-search-forward "[0-9][0-9]*")
-         (setq ex-count (string-to-int (buffer-substring (point) (mark))))
+         (setq ex-count (string-to-number (buffer-substring (point) (mark))))
          (skip-chars-forward " \t")))
     (if (looking-at "[pl#]")
        (progn
          (setq ex-flag t)
          (forward-char 1)))
     (if (not (looking-at "[\n|]"))
-       (error "Illegal extra characters"))))
+       (error "Invalid extra characters"))))
 
 (defun vip-get-ex-file ()
   "get a file name and set ex-variant, ex-append and ex-offset if found"
@@ -2829,7 +2831,8 @@ a token has type \(command, address, end-mark\) and value."
       (skip-chars-forward " \t")
       (if (looking-at "[\n|]") (error "Missing rhs"))
       (set-mark (point))
-      (end-of-buffer)
+      (with-no-warnings
+       (end-of-buffer))
       (backward-char 1)
       (setq string (buffer-substring (mark) (point))))
     (if (not (lookup-key ex-map char))
@@ -2899,7 +2902,8 @@ a token has type \(command, address, end-mark\) and value."
        (setq file (buffer-substring (point) (mark)))))
       (if variant
          (shell-command command t)
-       (insert-file file))))
+       (with-no-warnings
+         (insert-file file)))))
 
 (defun ex-set ()
   (eval (list 'setq
@@ -2911,7 +2915,7 @@ a token has type \(command, address, end-mark\) and value."
   (vip-change-mode-to-emacs)
   (shell))
 
-(defun ex-substitute (&optional repeat r-flag) 
+(defun ex-substitute (&optional repeat r-flag)
   "ex substitute.
 If REPEAT use previous reg-exp which is ex-reg-exp or
 vip-s-string"
@@ -3071,4 +3075,5 @@ vip-s-string"
 
 (provide 'vip)
 
+;;; arch-tag: bff623ef-48f7-41d4-9aa3-2e840c9ab415
 ;;; vip.el ends here