]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/viper-cmd.el
Merge from emacs-23; up to 2010-06-03T05:41:49Z!rgm@gnu.org.
[gnu-emacs] / lisp / emulation / viper-cmd.el
index 98d77b7212e2a7df13d5067da3f3c53eb11c051a..d9b79ccd317ad3d93ec9453edbd160819c137df0 100644 (file)
@@ -1,9 +1,9 @@
 ;;; viper-cmd.el --- Vi command support for Viper
 
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2011  Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
+;; Package: viper
 
 ;; This file is part of GNU Emacs.
 
@@ -41,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)
 
@@ -2064,23 +2064,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)
@@ -2179,10 +2178,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
@@ -2205,14 +2204,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))
@@ -3498,11 +3497,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))
@@ -4247,7 +4243,7 @@ Null string will repeat previous search."
          (setq viper-use-register nil)))
     (if (and (bolp) viper-ex-style-editing)
        (ding))
-    (delete-backward-char val t)))
+    (delete-char (- val) t)))
 
 
 (defun viper-del-backward-char-in-insert ()
@@ -4256,7 +4252,7 @@ Null string will repeat previous search."
   (if (and viper-ex-style-editing (bolp))
       (beep 1)
     ;; don't put on kill ring
-    (delete-backward-char 1 nil)))
+    (delete-char -1 nil)))
 
 
 (defun viper-del-backward-char-in-replace ()
@@ -4269,14 +4265,14 @@ cursor move past the beginning of line."
   (cond (viper-delete-backwards-in-replace
         (cond ((not (bolp))
                ;; don't put on kill ring
-               (delete-backward-char 1 nil))
+               (delete-char -1 nil))
               (viper-ex-style-editing
                (beep 1))
               ((bobp)
                (beep 1))
               (t
                ;; don't put on kill ring
-               (delete-backward-char 1 nil))))
+               (delete-char -1 nil))))
        (viper-ex-style-editing
         (if (bolp)
             (beep 1)
@@ -4344,7 +4340,7 @@ cursor move past the beginning of line."
            (insert-before-markers "@") ; put placeholder after the TAB
            (untabify (viper-replace-start) (point))
            ;; del @, don't put on kill ring
-           (delete-backward-char 1)
+           (delete-char -1)
 
            (viper-set-replace-overlay-glyphs
             viper-replace-region-start-delimiter
@@ -4622,12 +4618,10 @@ One can use `` and '' to temporarily jump 1 step back."
            (progn
              (if (eq ?^ (preceding-char))
                  (setq viper-preserve-indent t))
-             (delete-backward-char 1)
+             (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
@@ -4711,9 +4705,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)
@@ -5092,5 +5084,4 @@ Mail anyway (y or n)? ")
 
 
 
-;; arch-tag: 739a6450-5fda-44d0-88b0-325053d888c2
 ;;; viper-cmd.el ends here