Spelling fixes.
[bpt/emacs.git] / lisp / emulation / viper-cmd.el
index 07719ba..ce3cc3c 100644 (file)
@@ -1,7 +1,6 @@
 ;;; viper-cmd.el --- Vi command support for Viper
 
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2011  Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Package: viper
@@ -42,7 +41,7 @@
 (defvar quail-current-str)
 (defvar mark-even-if-inactive)
 (defvar init-message)
-(defvar initial)
+(defvar viper-initial)
 (defvar undo-beg-posn)
 (defvar undo-end-posn)
 
     (or (viper-overlay-p viper-replace-overlay)
       (viper-set-replace-overlay (point-min) (point-min)))
     (viper-hide-replace-overlay)
-    (if abbrev-mode (expand-abbrev))
+    ;; Expand abbrevs iff the previous character has word syntax.
+    (and abbrev-mode
+        (eq (char-syntax (preceding-char)) ?w)
+        (expand-abbrev))
     (if (and auto-fill-function (> (current-column) fill-column))
        (funcall auto-fill-function))
     ;; don't leave whitespace lines around
@@ -777,7 +779,7 @@ Vi's prefix argument will be used.  Otherwise, the prefix argument passed to
                  (viper-copy-event (viper-seq-last-elt key))))
 
          (if (commandp com)
-             ;; pretend that current state is the state we excaped to
+             ;; pretend that current state is the state we escaped to
              (let ((viper-current-state state))
                (setq prefix-arg (or prefix-arg arg))
                (command-execute com)))
@@ -1085,7 +1087,7 @@ as a Meta key and any number of multiple escapes are allowed."
   "Function that implements ESC key in Viper emulation of Vi."
   (interactive)
   (let ((cmd (or (key-binding (viper-envelop-ESC-key))
-                '(lambda () (interactive) (error "Viper bell")))))
+                (lambda () (interactive) (error "Viper bell")))))
 
     ;; call the actual function to execute ESC (if no other symbols followed)
     ;; or the key bound to the ESC sequence (if the sequence was issued
@@ -1385,7 +1387,7 @@ as a Meta key and any number of multiple escapes are allowed."
        (insert " ")(backward-char 1)))
   (if (= viper-com-point (point))
       (viper-forward-char-carefully))
-  (set-mark viper-com-point)
+  (push-mark viper-com-point)
   (if (eq m-com 'viper-next-line-at-bol)
       (viper-enlarge-region (mark t) (point)))
   (if (< (point) (mark t))
@@ -1394,8 +1396,7 @@ as a Meta key and any number of multiple escapes are allowed."
       (viper-backward-char-carefully)) ; give back the newline
   (if (eq viper-intermediate-command 'viper-repeat)
       (viper-change-subr (mark t) (point))
-    (viper-change (mark t) (point))
-    ))
+    (viper-change (mark t) (point))))
 
 ;; this is invoked by viper-substitute-line
 (defun viper-exec-Change (m-com com)
@@ -1598,7 +1599,7 @@ as a Meta key and any number of multiple escapes are allowed."
 ;; call viper-execute-com to execute viper-exec-change, which eventually will
 ;; call viper-change to invoke the replace mode on the region.
 ;;
-;; The var viper-d-com is set to (M-COM VAL COM REG INSETED-TEXT COMMAND-KEYS)
+;; The var viper-d-com is set to (M-COM VAL COM REG INSERTED-TEXT COMMAND-KEYS)
 ;; via a call to viper-set-destructive-command, for later use by viper-repeat.
 (defun viper-execute-com (m-com val com)
   (let ((reg viper-use-register))
@@ -2065,23 +2066,22 @@ Undo previous insertion and inserts new."
     (funcall hook)
     ))
 
-;; Thie is a temp hook that uses free variables init-message and initial.
+;; This is a temp hook that uses free variables init-message and viper-initial.
 ;; A dirty feature, but it is the simplest way to have it do the right thing.
-;; The INIT-MESSAGE and INITIAL vars come from the scope set by
+;; The INIT-MESSAGE and VIPER-INITIAL vars come from the scope set by
 ;; viper-read-string-with-history
 (defun viper-minibuffer-standard-hook ()
   (if (stringp init-message)
       (viper-tmp-insert-at-eob init-message))
-  (if (stringp initial)
-      (progn
-       ;; don't wait if we have unread events or in kbd macro
-       (or unread-command-events
-           executing-kbd-macro
-           (sit-for 840))
-       (if (fboundp 'minibuffer-prompt-end)
-           (delete-region (minibuffer-prompt-end) (point-max))
-         (erase-buffer))
-       (insert initial))))
+  (when (stringp viper-initial)
+    ;; don't wait if we have unread events or in kbd macro
+    (or unread-command-events
+       executing-kbd-macro
+       (sit-for 840))
+    (if (fboundp 'minibuffer-prompt-end)
+       (delete-region (minibuffer-prompt-end) (point-max))
+      (erase-buffer))
+    (insert viper-initial)))
 
 (defsubst viper-minibuffer-real-start ()
   (if (fboundp 'minibuffer-prompt-end)
@@ -2180,10 +2180,10 @@ problems."
 \f
 ;;; Reading string with history
 
-(defun viper-read-string-with-history (prompt &optional initial
+(defun viper-read-string-with-history (prompt &optional viper-initial
                                              history-var default keymap
                                              init-message)
-  ;; Read string, prompting with PROMPT and inserting the INITIAL
+  ;; Read string, prompting with PROMPT and inserting the VIPER-INITIAL
   ;; value.  Uses HISTORY-VAR.  DEFAULT is the default value to accept if the
   ;; input is an empty string.
   ;; Default value is displayed until the user types something in the
@@ -2206,14 +2206,14 @@ problems."
        temp-msg)
 
     (setq keymap (or keymap minibuffer-local-map)
-         initial (or initial "")
+         viper-initial (or viper-initial "")
          temp-msg (if default
                       (format "(default %s) " default)
                     ""))
 
     (setq viper-incomplete-ex-cmd nil)
     (setq val (read-from-minibuffer prompt
-                                   (concat temp-msg initial val padding)
+                                   (concat temp-msg viper-initial val padding)
                                    keymap nil history-var))
     (setq minibuffer-setup-hook nil
          padding (viper-array-to-string (this-command-keys))
@@ -2377,7 +2377,7 @@ problems."
     (if (eq viper-intermediate-command 'viper-repeat)
        (viper-change-subr (mark t) (point))
       (viper-change (mark t) (point)))
-    ;; com is set to ?r when we repeat this comand with dot
+    ;; com is set to ?r when we repeat this command with dot
     (viper-set-destructive-command (list 'viper-substitute val ?r nil nil nil))
     ))
 
@@ -3499,11 +3499,8 @@ controlled by the sign of prefix numeric value."
        (if (and (eolp) (not (bolp))) (forward-char -1))
        (if (not (looking-at "[][(){}]"))
            (setq anchor-point (point)))
-       (save-excursion
-         (beginning-of-line)
-         (setq beg-lim (point))
-         (end-of-line)
-         (setq end-lim (point)))
+       (setq beg-lim (point-at-bol)
+             end-lim (point-at-eol))
        (cond ((re-search-forward "[][(){}]" end-lim t)
               (backward-char) )
              ((re-search-backward "[][(){}]" beg-lim t))
@@ -3718,7 +3715,7 @@ Although this function is bound to \\[viper-toggle-search-style], the most
 convenient way to use it is to bind `//' to the macro
 `1 M-x viper-toggle-search-style' and `///' to
 `2 M-x viper-toggle-search-style'.  In this way, hitting `//' quickly will
-toggle case-fold-search and hitting `/' three times witth toggle regexp
+toggle case-fold-search and hitting `/' three times with toggle regexp
 search.  Macros are more convenient in this case because they don't affect
 the Emacs binding of `/'."
   (interactive "P")
@@ -4626,9 +4623,7 @@ One can use `` and '' to temporarily jump 1 step back."
              (delete-char -1)
              (setq p (point))
              (setq indent nil)))
-       (save-excursion
-         (beginning-of-line)
-         (setq bol (point)))
+       (setq bol (point-at-bol))
        (if (re-search-backward "[^ \t]" bol 1) (forward-char))
        (delete-region (point) p)
        (if indent
@@ -4712,9 +4707,7 @@ One can use `` and '' to temporarily jump 1 step back."
                       (goto-char pos)
                       (beginning-of-line)
                       (if (re-search-backward "[^ \t]" nil t)
-                          (progn
-                            (beginning-of-line)
-                            (setq s (point))))
+                          (setq s (point-at-bol)))
                       (goto-char pos)
                       (forward-line 1)
                       (if (re-search-forward "[^ \t]" nil t)
@@ -5093,5 +5086,4 @@ Mail anyway (y or n)? ")
 
 
 
-;; arch-tag: 739a6450-5fda-44d0-88b0-325053d888c2
 ;;; viper-cmd.el ends here