Spelling fixes.
[bpt/emacs.git] / lisp / emulation / vip.el
index a61e574..1298e54 100644 (file)
@@ -1,7 +1,7 @@
 ;;; vip.el --- a VI Package for GNU Emacs
 
-;; Copyright (C) 1986, 1987, 1988, 1992, 1993, 1998, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1986-1988, 1992-1993, 1998, 2001-2011
+;;   Free Software Foundation, Inc.
 
 ;; Author: Masahiko Sato <ms@sail.stanford.edu>
 ;; Keywords: emulations
   "How to reexecute last destructive command.  Value is list (M-COM VAL COM).")
 
 (defcustom vip-shift-width 8
-  "*The number of columns shifted by > and < command."
+  "The number of columns shifted by > and < command."
   :type 'integer
   :group 'vip)
 
 (defcustom vip-re-replace nil
-  "*If t then do regexp replace, if nil then do string replace."
+  "If t then do regexp replace, if nil then do string replace."
   :type 'boolean
   :group 'vip)
 
   "For use by \";\" command.")
 
 (defcustom vip-search-wrap-around t
-  "*If t, search wraps around."
+  "If t, search wraps around."
   :type 'boolean
   :group 'vip)
 
 (defcustom vip-re-search nil
-  "*If t, search is reg-exp search, otherwise vanilla search."
+  "If t, search is reg-exp search, otherwise vanilla search."
   :type 'boolean
   :group 'vip)
 
   "If t, search is forward.")
 
 (defcustom vip-case-fold-search nil
-  "*If t, search ignores cases."
+  "If t, search ignores cases."
   :type 'boolean
   :group 'vip)
 
 (defcustom vip-re-query-replace nil
-  "*If t then do regexp replace, if nil then do string replace."
+  "If t then do regexp replace, if nil then do string replace."
   :type 'boolean
   :group 'vip)
 
 (defcustom vip-open-with-indent nil
-  "*If t, indent when open a new line."
+  "If t, indent when open a new line."
   :type 'boolean
   :group 'vip)
 
 (defcustom vip-help-in-insert-mode nil
-  "*If t then C-h is bound to help-command in insert mode.
+  "If t then C-h is bound to help-command in insert mode.
 If nil then it is bound to `delete-backward-char'."
   :type 'boolean
   :group 'vip)
@@ -164,132 +164,133 @@ If nil then it is bound to `delete-backward-char'."
 \f
 ;; key bindings
 
-(defvar vip-mode-map (make-keymap))
-
-(define-key vip-mode-map "\C-a" 'beginning-of-line)
-(define-key vip-mode-map "\C-b" 'vip-scroll-back)
-(define-key vip-mode-map "\C-c" 'vip-ctl-c)
-(define-key vip-mode-map "\C-d" 'vip-scroll-up)
-(define-key vip-mode-map "\C-e" 'vip-scroll-up-one)
-(define-key vip-mode-map "\C-f" 'vip-scroll)
-(define-key vip-mode-map "\C-g" 'vip-keyboard-quit)
-(define-key vip-mode-map "\C-h" 'help-command)
-(define-key vip-mode-map "\C-m" 'vip-scroll-back)
-(define-key vip-mode-map "\C-n" 'vip-other-window)
-(define-key vip-mode-map "\C-o" 'vip-open-line-at-point)
-(define-key vip-mode-map "\C-u" 'vip-scroll-down)
-(define-key vip-mode-map "\C-x" 'vip-ctl-x)
-(define-key vip-mode-map "\C-y" 'vip-scroll-down-one)
-(define-key vip-mode-map "\C-z" 'vip-change-mode-to-emacs)
-(define-key vip-mode-map "\e" 'vip-ESC)
-
-(define-key vip-mode-map " " 'vip-scroll)
-(define-key vip-mode-map "!" 'vip-command-argument)
-(define-key vip-mode-map "\"" 'vip-command-argument)
-(define-key vip-mode-map "#" 'vip-command-argument)
-(define-key vip-mode-map "$" 'vip-goto-eol)
-(define-key vip-mode-map "%" 'vip-paren-match)
-(define-key vip-mode-map "&" 'vip-nil)
-(define-key vip-mode-map "'" 'vip-goto-mark-and-skip-white)
-(define-key vip-mode-map "(" 'vip-backward-sentence)
-(define-key vip-mode-map ")" 'vip-forward-sentence)
-(define-key vip-mode-map "*" 'call-last-kbd-macro)
-(define-key vip-mode-map "+" 'vip-next-line-at-bol)
-(define-key vip-mode-map "," 'vip-repeat-find-opposite)
-(define-key vip-mode-map "-" 'vip-previous-line-at-bol)
-(define-key vip-mode-map "." 'vip-repeat)
-(define-key vip-mode-map "/" 'vip-search-forward)
-
-(define-key vip-mode-map "0" 'vip-beginning-of-line)
-(define-key vip-mode-map "1" 'vip-digit-argument)
-(define-key vip-mode-map "2" 'vip-digit-argument)
-(define-key vip-mode-map "3" 'vip-digit-argument)
-(define-key vip-mode-map "4" 'vip-digit-argument)
-(define-key vip-mode-map "5" 'vip-digit-argument)
-(define-key vip-mode-map "6" 'vip-digit-argument)
-(define-key vip-mode-map "7" 'vip-digit-argument)
-(define-key vip-mode-map "8" 'vip-digit-argument)
-(define-key vip-mode-map "9" 'vip-digit-argument)
-
-(define-key vip-mode-map ":" 'vip-ex)
-(define-key vip-mode-map ";" 'vip-repeat-find)
-(define-key vip-mode-map "<" 'vip-command-argument)
-(define-key vip-mode-map "=" 'vip-command-argument)
-(define-key vip-mode-map ">" 'vip-command-argument)
-(define-key vip-mode-map "?" 'vip-search-backward)
-(define-key vip-mode-map "@" 'vip-nil)
-
-(define-key vip-mode-map "A" 'vip-Append)
-(define-key vip-mode-map "B" 'vip-backward-Word)
-(define-key vip-mode-map "C" 'vip-ctl-c-equivalent)
-(define-key vip-mode-map "D" 'vip-kill-line)
-(define-key vip-mode-map "E" 'vip-end-of-Word)
-(define-key vip-mode-map "F" 'vip-find-char-backward)
-(define-key vip-mode-map "G" 'vip-goto-line)
-(define-key vip-mode-map "H" 'vip-window-top)
-(define-key vip-mode-map "I" 'vip-Insert)
-(define-key vip-mode-map "J" 'vip-join-lines)
-(define-key vip-mode-map "K" 'vip-kill-buffer)
-(define-key vip-mode-map "L" 'vip-window-bottom)
-(define-key vip-mode-map "M" 'vip-window-middle)
-(define-key vip-mode-map "N" 'vip-search-Next)
-(define-key vip-mode-map "O" 'vip-Open-line)
-(define-key vip-mode-map "P" 'vip-Put-back)
-(define-key vip-mode-map "Q" 'vip-query-replace)
-(define-key vip-mode-map "R" 'vip-replace-string)
-(define-key vip-mode-map "S" 'vip-switch-to-buffer-other-window)
-(define-key vip-mode-map "T" 'vip-goto-char-backward)
-(define-key vip-mode-map "U" 'vip-nil)
-(define-key vip-mode-map "V" 'vip-find-file-other-window)
-(define-key vip-mode-map "W" 'vip-forward-Word)
-(define-key vip-mode-map "X" 'vip-ctl-x-equivalent)
-(define-key vip-mode-map "Y" 'vip-yank-line)
-(define-key vip-mode-map "ZZ" 'save-buffers-kill-emacs)
-
-(define-key vip-mode-map "[" 'vip-nil)
-(define-key vip-mode-map "\\" 'vip-escape-to-emacs)
-(define-key vip-mode-map "]" 'vip-nil)
-(define-key vip-mode-map "^" 'vip-bol-and-skip-white)
-(define-key vip-mode-map "_" 'vip-nil)
-(define-key vip-mode-map "`" 'vip-goto-mark)
-
-(define-key vip-mode-map "a" 'vip-append)
-(define-key vip-mode-map "b" 'vip-backward-word)
-(define-key vip-mode-map "c" 'vip-command-argument)
-(define-key vip-mode-map "d" 'vip-command-argument)
-(define-key vip-mode-map "e" 'vip-end-of-word)
-(define-key vip-mode-map "f" 'vip-find-char-forward)
-(define-key vip-mode-map "g" 'vip-info-on-file)
-(define-key vip-mode-map "h" 'vip-backward-char)
-(define-key vip-mode-map "i" 'vip-insert)
-(define-key vip-mode-map "j" 'vip-next-line)
-(define-key vip-mode-map "k" 'vip-previous-line)
-(define-key vip-mode-map "l" 'vip-forward-char)
-(define-key vip-mode-map "m" 'vip-mark-point)
-(define-key vip-mode-map "n" 'vip-search-next)
-(define-key vip-mode-map "o" 'vip-open-line)
-(define-key vip-mode-map "p" 'vip-put-back)
-(define-key vip-mode-map "q" 'vip-nil)
-(define-key vip-mode-map "r" 'vip-replace-char)
-(define-key vip-mode-map "s" 'vip-switch-to-buffer)
-(define-key vip-mode-map "t" 'vip-goto-char-forward)
-(define-key vip-mode-map "u" 'vip-undo)
-(define-key vip-mode-map "v" 'vip-find-file)
-(define-key vip-mode-map "w" 'vip-forward-word)
-(define-key vip-mode-map "x" 'vip-delete-char)
-(define-key vip-mode-map "y" 'vip-command-argument)
-(define-key vip-mode-map "zH" 'vip-line-to-top)
-(define-key vip-mode-map "zM" 'vip-line-to-middle)
-(define-key vip-mode-map "zL" 'vip-line-to-bottom)
-(define-key vip-mode-map "z\C-m" 'vip-line-to-top)
-(define-key vip-mode-map "z." 'vip-line-to-middle)
-(define-key vip-mode-map "z-" 'vip-line-to-bottom)
-
-(define-key vip-mode-map "{" 'vip-backward-paragraph)
-(define-key vip-mode-map "|" 'vip-goto-col)
-(define-key vip-mode-map "}" 'vip-forward-paragraph)
-(define-key vip-mode-map "~" 'vip-nil)
-(define-key vip-mode-map "\177" 'vip-delete-backward-char)
+(defvar vip-mode-map
+  (let ((map (make-keymap)))
+    (define-key map "\C-a" 'beginning-of-line)
+    (define-key map "\C-b" 'vip-scroll-back)
+    (define-key map "\C-c" 'vip-ctl-c)
+    (define-key map "\C-d" 'vip-scroll-up)
+    (define-key map "\C-e" 'vip-scroll-up-one)
+    (define-key map "\C-f" 'vip-scroll)
+    (define-key map "\C-g" 'vip-keyboard-quit)
+    (define-key map "\C-h" 'help-command)
+    (define-key map "\C-m" 'vip-scroll-back)
+    (define-key map "\C-n" 'vip-other-window)
+    (define-key map "\C-o" 'vip-open-line-at-point)
+    (define-key map "\C-u" 'vip-scroll-down)
+    (define-key map "\C-x" 'vip-ctl-x)
+    (define-key map "\C-y" 'vip-scroll-down-one)
+    (define-key map "\C-z" 'vip-change-mode-to-emacs)
+    (define-key map "\e" 'vip-ESC)
+
+    (define-key map " " 'vip-scroll)
+    (define-key map "!" 'vip-command-argument)
+    (define-key map "\"" 'vip-command-argument)
+    (define-key map "#" 'vip-command-argument)
+    (define-key map "$" 'vip-goto-eol)
+    (define-key map "%" 'vip-paren-match)
+    (define-key map "&" 'vip-nil)
+    (define-key map "'" 'vip-goto-mark-and-skip-white)
+    (define-key map "(" 'vip-backward-sentence)
+    (define-key map ")" 'vip-forward-sentence)
+    (define-key map "*" 'call-last-kbd-macro)
+    (define-key map "+" 'vip-next-line-at-bol)
+    (define-key map "," 'vip-repeat-find-opposite)
+    (define-key map "-" 'vip-previous-line-at-bol)
+    (define-key map "." 'vip-repeat)
+    (define-key map "/" 'vip-search-forward)
+
+    (define-key map "0" 'vip-beginning-of-line)
+    (define-key map "1" 'vip-digit-argument)
+    (define-key map "2" 'vip-digit-argument)
+    (define-key map "3" 'vip-digit-argument)
+    (define-key map "4" 'vip-digit-argument)
+    (define-key map "5" 'vip-digit-argument)
+    (define-key map "6" 'vip-digit-argument)
+    (define-key map "7" 'vip-digit-argument)
+    (define-key map "8" 'vip-digit-argument)
+    (define-key map "9" 'vip-digit-argument)
+
+    (define-key map ":" 'vip-ex)
+    (define-key map ";" 'vip-repeat-find)
+    (define-key map "<" 'vip-command-argument)
+    (define-key map "=" 'vip-command-argument)
+    (define-key map ">" 'vip-command-argument)
+    (define-key map "?" 'vip-search-backward)
+    (define-key map "@" 'vip-nil)
+
+    (define-key map "A" 'vip-Append)
+    (define-key map "B" 'vip-backward-Word)
+    (define-key map "C" 'vip-ctl-c-equivalent)
+    (define-key map "D" 'vip-kill-line)
+    (define-key map "E" 'vip-end-of-Word)
+    (define-key map "F" 'vip-find-char-backward)
+    (define-key map "G" 'vip-goto-line)
+    (define-key map "H" 'vip-window-top)
+    (define-key map "I" 'vip-Insert)
+    (define-key map "J" 'vip-join-lines)
+    (define-key map "K" 'vip-kill-buffer)
+    (define-key map "L" 'vip-window-bottom)
+    (define-key map "M" 'vip-window-middle)
+    (define-key map "N" 'vip-search-Next)
+    (define-key map "O" 'vip-Open-line)
+    (define-key map "P" 'vip-Put-back)
+    (define-key map "Q" 'vip-query-replace)
+    (define-key map "R" 'vip-replace-string)
+    (define-key map "S" 'vip-switch-to-buffer-other-window)
+    (define-key map "T" 'vip-goto-char-backward)
+    (define-key map "U" 'vip-nil)
+    (define-key map "V" 'vip-find-file-other-window)
+    (define-key map "W" 'vip-forward-Word)
+    (define-key map "X" 'vip-ctl-x-equivalent)
+    (define-key map "Y" 'vip-yank-line)
+    (define-key map "ZZ" 'save-buffers-kill-emacs)
+
+    (define-key map "[" 'vip-nil)
+    (define-key map "\\" 'vip-escape-to-emacs)
+    (define-key map "]" 'vip-nil)
+    (define-key map "^" 'vip-bol-and-skip-white)
+    (define-key map "_" 'vip-nil)
+    (define-key map "`" 'vip-goto-mark)
+
+    (define-key map "a" 'vip-append)
+    (define-key map "b" 'vip-backward-word)
+    (define-key map "c" 'vip-command-argument)
+    (define-key map "d" 'vip-command-argument)
+    (define-key map "e" 'vip-end-of-word)
+    (define-key map "f" 'vip-find-char-forward)
+    (define-key map "g" 'vip-info-on-file)
+    (define-key map "h" 'vip-backward-char)
+    (define-key map "i" 'vip-insert)
+    (define-key map "j" 'vip-next-line)
+    (define-key map "k" 'vip-previous-line)
+    (define-key map "l" 'vip-forward-char)
+    (define-key map "m" 'vip-mark-point)
+    (define-key map "n" 'vip-search-next)
+    (define-key map "o" 'vip-open-line)
+    (define-key map "p" 'vip-put-back)
+    (define-key map "q" 'vip-nil)
+    (define-key map "r" 'vip-replace-char)
+    (define-key map "s" 'vip-switch-to-buffer)
+    (define-key map "t" 'vip-goto-char-forward)
+    (define-key map "u" 'vip-undo)
+    (define-key map "v" 'vip-find-file)
+    (define-key map "w" 'vip-forward-word)
+    (define-key map "x" 'vip-delete-char)
+    (define-key map "y" 'vip-command-argument)
+    (define-key map "zH" 'vip-line-to-top)
+    (define-key map "zM" 'vip-line-to-middle)
+    (define-key map "zL" 'vip-line-to-bottom)
+    (define-key map "z\C-m" 'vip-line-to-top)
+    (define-key map "z." 'vip-line-to-middle)
+    (define-key map "z-" 'vip-line-to-bottom)
+
+    (define-key map "{" 'vip-backward-paragraph)
+    (define-key map "|" 'vip-goto-col)
+    (define-key map "}" 'vip-forward-paragraph)
+    (define-key map "~" 'vip-nil)
+    (define-key map "\177" 'vip-delete-backward-char)
+    map))
 
 (defun vip-version ()
   (interactive)
@@ -419,10 +420,9 @@ Type `n' to quit this window for now.\n")
        (goto-char (point-min))
        (if (y-or-n-p "Inhibit VIP startup message? ")
            (progn
-             (save-excursion
-               (set-buffer
-                (find-file-noselect
-                 (substitute-in-file-name vip-startup-file)))
+             (with-current-buffer
+                  (find-file-noselect
+                   (substitute-in-file-name vip-startup-file))
                (goto-char (point-max))
                (insert "\n(setq vip-inhibit-startup-message t)\n")
                (save-buffer)
@@ -606,7 +606,7 @@ obtained so far, and COM is the command part obtained so far."
 (defun vip-digit-argument (arg)
   "Begin numeric argument for the next command."
   (interactive "P")
-  (vip-prefix-arg-value last-command-char nil
+  (vip-prefix-arg-value last-command-event nil
                        (if (consp arg) (cdr arg) nil)))
 
 (defun vip-command-argument (arg)
@@ -614,7 +614,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-event
        (cond ((null arg) nil)
             ((consp arg) (car arg))
             ((numberp arg) arg)
@@ -877,7 +877,7 @@ is the name of the register for COM."
   (if (> beg end) (exchange-point-and-mark)))
 
 (defun vip-global-execute ()
-  "Call last keyboad macro for each line in the region."
+  "Call last keyboard macro for each line in the region."
   (if (> (point) (mark)) (exchange-point-and-mark))
   (beginning-of-line)
   (call-last-kbd-macro)
@@ -1605,7 +1605,7 @@ used.  This behavior is controlled by the sign of prefix numeric value."
   "Show current buffer in two windows."
   (interactive)
   (delete-other-windows)
-  (split-window-vertically nil))
+  (split-window-below))
 
 \f
 ;; searching
@@ -2158,8 +2158,7 @@ is a command.")
 (defun vip-get-ex-token ()
   "get an ex-token which is either an address or a command.
 a token has type \(command, address, end-mark\) and value."
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
+  (with-current-buffer " *ex-working-space*"
     (skip-chars-forward " \t")
     (cond ((looking-at "[k#]")
           (setq ex-token-type "command")
@@ -2262,8 +2261,7 @@ a token has type \(command, address, end-mark\) and value."
            ex-g-variant nil))
   (let ((com-str (or string (vip-read-string ":")))
        (address nil) (cont t) (dot (point)))
-    (save-window-excursion
-      (set-buffer (get-buffer-create " *ex-working-space*"))
+    (with-current-buffer (get-buffer-create " *ex-working-space*")
       (delete-region (point-min) (point-max))
       (insert com-str "\n")
       (goto-char (point-min)))
@@ -2282,8 +2280,7 @@ a token has type \(command, address, end-mark\) and value."
                    (setq cont nil))
                   (t
                    (vip-execute-ex-command)
-                   (save-window-excursion
-                     (set-buffer " *ex-working-space*")
+                   (with-current-buffer " *ex-working-space*"
                      (skip-chars-forward " \t")
                      (cond ((looking-at "|")
                             (forward-char 1))
@@ -2307,8 +2304,7 @@ a token has type \(command, address, end-mark\) and value."
 
 (defun vip-get-ex-pat ()
   "get a regular expression and set ex-variant if found"
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
+  (with-current-buffer " *ex-working-space*"
     (skip-chars-forward " \t")
     (if (looking-at "!")
        (progn
@@ -2334,8 +2330,7 @@ a token has type \(command, address, end-mark\) and value."
 
 (defun vip-get-ex-command ()
   "get an ex command"
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
+  (with-current-buffer " *ex-working-space*"
     (if (looking-at "/") (forward-char 1))
     (skip-chars-forward " \t")
     (cond ((looking-at "[a-z]")
@@ -2349,8 +2344,7 @@ a token has type \(command, address, end-mark\) and value."
 
 (defun vip-get-ex-opt-gc ()
   "get an ex option g or c"
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
+  (with-current-buffer " *ex-working-space*"
     (if (looking-at "/") (forward-char 1))
     (skip-chars-forward " \t")
     (cond ((looking-at "g")
@@ -2458,8 +2452,7 @@ a token has type \(command, address, end-mark\) and value."
   (setq ex-buffer nil)
   (setq ex-count nil)
   (setq ex-flag nil)
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
+  (with-current-buffer " *ex-working-space*"
     (skip-chars-forward " \t")
     (if (looking-at "[a-zA-Z]")
        (progn
@@ -2483,8 +2476,7 @@ a token has type \(command, address, end-mark\) and value."
   (setq ex-variant nil
        ex-count nil
        ex-flag nil)
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
+  (with-current-buffer " *ex-working-space*"
     (skip-chars-forward " \t")
     (if (looking-at "!")
        (progn
@@ -2510,8 +2502,7 @@ a token has type \(command, address, end-mark\) and value."
        ex-variant nil
        ex-append nil
        ex-offset nil)
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
+  (with-current-buffer " *ex-working-space*"
     (skip-chars-forward " \t")
     (if (looking-at "!")
        (progn
@@ -2680,8 +2671,7 @@ a token has type \(command, address, end-mark\) and value."
   (goto-char (point-min))
   (if ex-offset
       (progn
-       (save-window-excursion
-         (set-buffer " *ex-working-space*")
+       (with-current-buffer " *ex-working-space*"
          (delete-region (point-min) (point-max))
          (insert ex-offset "\n")
          (goto-char (point-min)))
@@ -2733,19 +2723,18 @@ a token has type \(command, address, end-mark\) and value."
          (if (bobp) (setq cont nil)
            (forward-line -1)
            (end-of-line)))))
-  (save-window-excursion
-    (set-buffer " *ex-working-space*")
-    (setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
-  (while marks
-    (goto-char (car marks))
-    ; report progress of execution on a slow machine.
-    ;(message "Executing global command...")
-    ;(if (zerop (% mark-count 10))
-       ;(message "Executing global command...%d" mark-count))
-    (vip-ex com-str)
-    (setq mark-count (1- mark-count))
-    (setq marks (cdr marks)))))
-  ;(message "Executing global command...done")))
+    (with-current-buffer " *ex-working-space*"
+      (setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
+    (while marks
+      (goto-char (car marks))
+      ;; report progress of execution on a slow machine.
+      ;;(message "Executing global command...")
+      ;;(if (zerop (% mark-count 10))
+      ;;    (message "Executing global command...%d" mark-count))
+      (vip-ex com-str)
+      (setq mark-count (1- mark-count))
+      (setq marks (cdr marks)))))
+;;(message "Executing global command...done")))
 
 (defun ex-line (com)
   "ex line commands.  COM is join, shift-right or shift-left."
@@ -2801,8 +2790,7 @@ a token has type \(command, address, end-mark\) and value."
     (if (null ex-addresses)
        (setq ex-addresses
              (cons (point) nil)))
-    (save-window-excursion
-      (set-buffer " *ex-working-space*")
+    (with-current-buffer " *ex-working-space*"
       (skip-chars-forward " \t")
       (if (looking-at "[a-z]")
          (progn
@@ -2821,8 +2809,7 @@ a token has type \(command, address, end-mark\) and value."
 (defun ex-map ()
   "ex map"
   (let (char string)
-    (save-window-excursion
-      (set-buffer " *ex-working-space*")
+    (with-current-buffer " *ex-working-space*"
       (skip-chars-forward " \t")
       (setq char (char-to-string (following-char)))
       (forward-char 1)
@@ -2847,8 +2834,7 @@ a token has type \(command, address, end-mark\) and value."
 (defun ex-unmap ()
   "ex unmap"
   (let (char)
-    (save-window-excursion
-      (set-buffer " *ex-working-space*")
+    (with-current-buffer " *ex-working-space*"
       (skip-chars-forward " \t")
       (setq char (char-to-string (following-char)))
       (forward-char 1)
@@ -2870,8 +2856,7 @@ a token has type \(command, address, end-mark\) and value."
 (defun ex-quit ()
   "ex quit"
   (let (char)
-    (save-window-excursion
-      (set-buffer " *ex-working-space*")
+    (with-current-buffer " *ex-working-space*"
       (skip-chars-forward " \t")
       (setq char (following-char)))
     (if (= char ?!) (kill-emacs t) (save-buffers-kill-emacs))))
@@ -2883,8 +2868,7 @@ a token has type \(command, address, end-mark\) and value."
     (goto-char point)
     (if (not (= point 0)) (with-no-warnings (next-line 1)))
     (beginning-of-line)
-    (save-window-excursion
-      (set-buffer " *ex-working-space*")
+    (with-current-buffer " *ex-working-space*"
       (skip-chars-forward " \t")
       (if (looking-at "!")
          (progn
@@ -2981,8 +2965,7 @@ vip-s-string"
 (defun ex-tag ()
   "ex tag"
   (let (tag)
-    (save-window-excursion
-      (set-buffer " *ex-working-space*")
+    (with-current-buffer " *ex-working-space*"
       (skip-chars-forward " \t")
       (set-mark (point))
       (skip-chars-forward "^ |\t\n")
@@ -3045,8 +3028,7 @@ vip-s-string"
 (defun ex-command ()
   "execute shell command"
   (let (command)
-    (save-window-excursion
-      (set-buffer " *ex-working-space*")
+    (with-current-buffer " *ex-working-space*"
       (skip-chars-forward " \t")
       (set-mark (point))
       (end-of-line)
@@ -3073,5 +3055,4 @@ vip-s-string"
 
 (provide 'vip)
 
-;; arch-tag: bff623ef-48f7-41d4-9aa3-2e840c9ab415
 ;;; vip.el ends here