]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/viper-cmd.el
Merge from emacs-23
[gnu-emacs] / lisp / emulation / viper-cmd.el
index a56c69e095b4ba1de5a877206b24e64d62c16601..4e90889ddd0d8daf66b79329e4cd4d849d5014c1 100644 (file)
@@ -1,16 +1,17 @@
 ;;; viper-cmd.el --- Vi command support for Viper
 
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
+;; Package: viper
 
 ;; 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 3, 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
@@ -18,9 +19,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, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -43,7 +42,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)
 
           (marker-position viper-insert-point))
       (setq viper-pre-command-point (marker-position viper-insert-point))))
 
-(defsubst viper-R-state-post-command-sentinel ()
+(defun viper-R-state-post-command-sentinel ()
   ;; Restoring cursor color is needed despite
   ;; viper-replace-state-pre-command-sentinel: When you jump to another buffer
   ;; in another frame, the pre-command hook won't change cursor color to
                          (assoc major-mode viper-emacs-state-modifier-alist))
                       viper-empty-keymap))
               ))
-       
+
   ;; This var is not local in Emacs, so we make it local.  It must be local
   ;; because although the stack of minor modes can be the same for all buffers,
   ;; the associated *keymaps* can be different.  In Viper,
 ARG is used as the prefix value for the executed command.  If
 EVENTS is a list of events, which become the beginning of the command."
   (interactive "P")
-  (if (viper= last-command-char ?\\)
+  (if (viper= (viper-last-command-char) ?\\)
       (message "Switched to EMACS state for the next command..."))
   (viper-escape-to-state arg events 'emacs-state))
 
@@ -775,8 +774,7 @@ Vi's prefix argument will be used.  Otherwise, the prefix argument passed to
                    last-command-char (event-to-character last-command-event))
            ;; Emacs represents them as sequences (str or vec)
            (setq last-command-event
-                 (viper-copy-event (viper-seq-last-elt key))
-                 last-command-char last-command-event))
+                 (viper-copy-event (viper-seq-last-elt key))))
 
          (if (commandp com)
              ;; pretend that current state is the state we excaped to
@@ -894,7 +892,7 @@ Vi's prefix argument will be used.  Otherwise, the prefix argument passed to
 
 
 (defun viper-exec-form-in-vi  (form)
-  "Execute FORM in Vi state, regardless of the Ccurrent Vi state."
+  "Execute FORM in Vi state, regardless of the current Vi state."
   (let ((buff (current-buffer))
        result)
     (viper-set-mode-vars-for 'vi-state)
@@ -906,22 +904,20 @@ Vi's prefix argument will be used.  Otherwise, the prefix argument passed to
        (signal 'quit nil)))
 
     (if (not (equal buff (current-buffer))) ; cmd switched buffer
-       (save-excursion
-         (set-buffer buff)
+       (with-current-buffer buff
          (viper-set-mode-vars-for viper-current-state)))
     (viper-set-mode-vars-for viper-current-state)
     result))
 
 (defun viper-exec-form-in-emacs  (form)
   "Execute FORM in Emacs, temporarily disabling Viper's minor modes.
-Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
+Similar to `viper-escape-to-emacs', but accepts forms rather than keystrokes."
   (let ((buff (current-buffer))
        result)
     (viper-set-mode-vars-for 'emacs-state)
     (setq result (eval form))
     (if (not (equal buff (current-buffer))) ; cmd switched buffer
-       (save-excursion
-         (set-buffer buff)
+       (with-current-buffer buff
          (viper-set-mode-vars-for viper-current-state)))
     (viper-set-mode-vars-for viper-current-state)
     result))
@@ -937,14 +933,14 @@ Similar to viper-escape-to-emacs, but accepts forms rather than keystrokes."
 ;; bindings.  By letting Viper know which files these modes are in, it will
 ;; arrange to reorganize minor-mode-map-alist so that things will work right.
 (defun viper-harness-minor-mode (load-file)
-  "Familiarize Viper with a minor mode defined in LOAD_FILE.
+  "Familiarize Viper with a minor mode defined in LOAD-FILE.
 Minor modes that have their own keymaps may overshadow Viper keymaps.
 This function is designed to make Viper aware of the packages that define
 such minor modes.
 Usage:
     (viper-harness-minor-mode load-file)
 
-LOAD-FILE is a name of the file where the specific minor mode is defined.
+LOAD-FILE is the name of the file where the specific minor mode is defined.
 Suffixes such as .el or .elc should be stripped."
 
   (interactive "sEnter name of the load file: ")
@@ -966,9 +962,9 @@ Prevents multiple escape keystrokes if viper-no-multiple-ESC is true.
 If viper-no-multiple-ESC is 'twice double ESC would ding in vi-state.
 Other ESC sequences are emulated via the current Emacs's major mode
 keymap.  This is more convenient on TTYs, since this won't block
-function keys such as up,down, etc.  ESC will also will also work as
-a Meta key in this case.  When viper-no-multiple-ESC is nil, ESC functions
-as a Meta key and any number of multiple escapes is allowed."
+function keys such as up, down, etc.  ESC will also will also work as
+a Meta key in this case.  When viper-no-multiple-ESC is nil, ESC works
+as a Meta key and any number of multiple escapes are allowed."
   (interactive "P")
   (let (char)
     (cond ((and (not viper-no-multiple-ESC) (eq viper-current-state 'vi-state))
@@ -1048,7 +1044,7 @@ as a Meta key and any number of multiple escapes is allowed."
                (let* ((first-key (elt keyseq 0))
                       (key-mod (event-modifiers first-key)))
                  (cond ((and (viper-ESC-event-p first-key)
-                             (not viper-translate-all-ESC-keysequences))
+                             (not (viper-translate-all-ESC-keysequences)))
                         ;; put keys following ESC on the unread list
                         ;; and return ESC as the key-sequence
                         (viper-set-unread-command-events (viper-subseq keyseq 1))
@@ -1172,7 +1168,7 @@ as a Meta key and any number of multiple escapes is allowed."
        ;; then execute it with funcall and clear prefix-arg in order to not
        ;; confuse subsequent commands
        (progn
-         ;; last-command-char is the char we want emacs to think was typed
+         ;; last-command-event is the char we want emacs to think was typed
          ;; last.  If com is not nil, the viper-digit-argument command was
          ;; called from within viper-prefix-arg command, such as `d', `w',
          ;; etc., i.e., the user typed, say, d2.  In this case, `com' would be
@@ -1180,13 +1176,16 @@ as a Meta key and any number of multiple escapes is allowed."
          ;; viper-escape-to-vi (which is indicated by the fact that the
          ;; current state is not vi-state), then `event-char' represents the
          ;; vi command to be executed (e.g., `d', `w', etc).  Again,
-         ;; last-command-char must make emacs believe that this is the command
+         ;; last-command-event must make emacs believe that this is the command
          ;; we typed.
          (cond ((eq event-char 'return) (setq event-char ?\C-m))
                ((eq event-char 'delete) (setq event-char ?\C-?))
                ((eq event-char 'backspace) (setq event-char ?\C-h))
                ((eq event-char 'space) (setq event-char ?\ )))
-         (setq last-command-char (or com event-char))
+         (setq last-command-event
+               (if (featurep 'xemacs)
+                   (character-to-event (or com event-char))
+                 (or com event-char)))
          (setq func (viper-exec-form-in-vi
                      `(key-binding (char-to-string ,event-char))))
          (funcall func prefix-arg)
@@ -1259,7 +1258,7 @@ as a Meta key and any number of multiple escapes is allowed."
 
       ;; as com is non-nil, this means that we have a command to execute
       (if (viper-memq-char (car com) '(?r ?R))
-         ;; execute apropriate region command.
+         ;; execute appropriate region command.
          (let ((char (car com)) (com (cdr com)))
            (setq prefix-arg (cons value com))
            (if (viper= char ?r)
@@ -1287,10 +1286,9 @@ as a Meta key and any number of multiple escapes is allowed."
         ;; gg  acts as G0
         ((equal (car com) ?g)   (viper-goto-line 0))
         (t (error "Viper bell")))))
-    
+
     (if cmd-to-exec-at-end
        (progn
-         (setq last-command-char char)
          (setq last-command-event
                (viper-copy-event
                 (if (featurep 'xemacs) (character-to-event char) char)))
@@ -1317,7 +1315,7 @@ as a Meta key and any number of multiple escapes is allowed."
   (interactive "P")
   (viper-leave-region-active)
   (viper-prefix-arg-value
-   last-command-char (if (consp arg) (cdr arg) nil)))
+   (viper-last-command-char) (if (consp arg) (cdr arg) nil)))
 
 (defun viper-command-argument (arg)
   "Accept a motion command as an argument."
@@ -1325,7 +1323,7 @@ as a Meta key and any number of multiple escapes is allowed."
   (let ((viper-intermediate-command 'viper-command-argument))
     (condition-case nil
        (viper-prefix-arg-com
-        last-command-char
+        (viper-last-command-char)
         (cond ((null arg) nil)
               ((consp arg) (car arg))
               ((integerp arg) arg)
@@ -1624,7 +1622,7 @@ Use the info in viper-d-com, which has the form
 where `com' is the command to be re-executed, `val' is the
 argument to `com', `ch' is a flag for repeat, and `reg' is optional;
 if it exists, it is the name of the register for `com'.
-If the prefix argument, ARG, is non-nil, it is used instead of `val'."
+If the prefix argument ARG is non-nil, it is used instead of `val'."
   (interactive "P")
   (let ((save-point (point)) ; save point before repeating prev cmd
        ;; Pass along that we are repeating a destructive command
@@ -1839,13 +1837,13 @@ invokes the command before that, etc."
             (concat "`" (viper-array-to-string keys) "'")
             (viper-abbreviate-string
              (if (featurep 'xemacs)
-              (replace-in-string ; xemacs
-               (cond ((characterp text) (char-to-string text))
-                     ((stringp text) text)
-                     (t ""))
-               "\n" "^J")
-              text ; emacs
-              )
+                 (replace-in-string ; xemacs
+                  (cond ((characterp text) (char-to-string text))
+                        ((stringp text) text)
+                        (t ""))
+                  "\n" "^J")
+               text ; emacs
+               )
              max-text-len
              "  inserting  `" "'" "    ......."))
     ))
@@ -1947,7 +1945,7 @@ Undo previous insertion and inserts new."
                 require-final-newline
                 ;; add newline only if we actually edited buffer. otherwise it
                 ;; might unintentionally modify binary buffers
-                (buffer-modified-p) 
+                (buffer-modified-p)
                 (not (viper-is-in-minibuffer))
                 (not buffer-read-only))
            ;; text property may be read-only
@@ -2067,23 +2065,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)
@@ -2102,7 +2099,7 @@ Undo previous insertion and inserts new."
   "Exit minibuffer Viper way."
   (interactive)
   (let (command)
-    (setq command (local-key-binding (char-to-string last-command-char)))
+    (setq command (local-key-binding (char-to-string (viper-last-command-char))))
     (run-hooks 'viper-minibuffer-exit-hook)
     (if command
        (command-execute command)
@@ -2159,9 +2156,9 @@ To turn this feature off, set this variable to nil."
                        (key-binding (setq key (read-key-sequence nil))))
                  (cond ((eq cmd 'self-insert-command)
                         (if (featurep 'xemacs)
-                         (insert (events-to-keys key)) ; xemacs
-                         (insert key) ; emacs
-                         ))
+                            (insert (events-to-keys key)) ; xemacs
+                          (insert key) ; emacs
+                          ))
                        ((memq cmd '(exit-minibuffer viper-exit-minibuffer))
                         nil)
                        (t (command-execute cmd)))
@@ -2182,10 +2179,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
@@ -2208,14 +2205,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))
@@ -2542,7 +2539,7 @@ problems."
 
 (defun viper-replace-state-exit-cmd ()
   "Binding for keys that cause Replace state to switch to Vi or to Insert.
-These keys are ESC, RET, and LineFeed"
+These keys are ESC, RET, and LineFeed."
   (interactive)
   (if overwrite-mode   ; if in replace mode invoked via 'R'
       (viper-finish-R-mode)
@@ -2550,7 +2547,7 @@ These keys are ESC, RET, and LineFeed"
   (let (com)
     (if (eq this-command 'viper-intercept-ESC-key)
        (setq com 'viper-exit-insert-state)
-      (viper-set-unread-command-events last-input-char)
+      (viper-set-unread-command-events last-input-event)
       (setq com (key-binding (viper-read-key-sequence nil))))
 
     (condition-case conds
@@ -2571,7 +2568,7 @@ These keys are ESC, RET, and LineFeed"
   (if (or (< (point) (viper-replace-start))
          (> (point) (viper-replace-end)))
       (let (viper-replace-minor-mode com)
-       (viper-set-unread-command-events last-input-char)
+       (viper-set-unread-command-events last-input-event)
        (setq com (key-binding (read-key-sequence nil)))
        (condition-case conds
            (command-execute com)
@@ -2764,9 +2761,10 @@ On reaching beginning of line, stop and signal error."
 (defun viper-next-line-carefully (arg)
   (condition-case nil
       ;; do not use forward-line! need to keep column
-      (if (featurep 'emacs)
-         (with-no-warnings (next-line arg))
-       (next-line arg))
+      (let ((line-move-visual nil))
+       (if (featurep 'emacs)
+           (with-no-warnings (next-line arg))
+         (next-line arg)))
     (error nil)))
 
 
@@ -3066,9 +3064,10 @@ On reaching beginning of line, stop and signal error."
        (com (viper-getCom arg)))
     (if com (viper-move-marker-locally 'viper-com-point (point)))
     ;; do not use forward-line! need to keep column
-    (if (featurep 'emacs)
-       (with-no-warnings (next-line val))
-      (next-line val))
+    (let ((line-move-visual nil))
+      (if (featurep 'emacs)
+         (with-no-warnings (next-line val))
+       (next-line val)))
     (if viper-ex-style-motion
        (if (and (eolp) (not (bolp))) (backward-char 1)))
     (setq this-command 'next-line)
@@ -3115,9 +3114,10 @@ If point is on a widget or a button, simulate clicking on that widget/button."
        (com (viper-getCom arg)))
     (if com (viper-move-marker-locally 'viper-com-point (point)))
     ;; do not use forward-line! need to keep column
-    (if (featurep 'emacs)
-       (with-no-warnings (previous-line val))
-      (previous-line val))
+    (let ((line-move-visual nil))
+      (if (featurep 'emacs)
+         (with-no-warnings (previous-line val))
+       (previous-line val)))
     (if viper-ex-style-motion
        (if (and (eolp) (not (bolp))) (backward-char 1)))
     (setq this-command 'previous-line)
@@ -3450,7 +3450,8 @@ controlled by the sign of prefix numeric value."
 ;; (which is called from viper-search-forward/backward/next).  If the value of
 ;; viper-search-scroll-threshold is negative - don't scroll.
 (defun viper-adjust-window ()
-  (let ((win-height (if (featurep 'xemacs) (window-displayed-height)
+  (let ((win-height (if (featurep 'xemacs)
+                       (window-displayed-height)
                      (1- (window-height)))) ; adjust for modeline
        (pt (point))
        at-top-p at-bottom-p
@@ -3497,11 +3498,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))
@@ -3685,15 +3683,24 @@ controlled by the sign of prefix numeric value."
 \f
 ;; searching
 
+(defun viper-insert-isearch-string ()
+  "Insert `isearch' last search string."
+  (interactive)
+  (when isearch-string (insert isearch-string)))
+
 (defun viper-if-string (prompt)
   (if (memq viper-intermediate-command
            '(viper-command-argument viper-digit-argument viper-repeat))
       (setq viper-this-command-keys (this-command-keys)))
-  (let ((s (viper-read-string-with-history
+  (let* ((keymap (let ((keymap (copy-keymap minibuffer-local-map)))
+                   (define-key keymap [(control ?s)] 'viper-insert-isearch-string)
+                   keymap))
+         (s (viper-read-string-with-history
            prompt
            nil ; no initial
            'viper-search-history
-           (car viper-search-history))))
+             (car viper-search-history)
+             keymap)))
     (if (not (string= s ""))
        (setq viper-s-string s))))
 
@@ -3701,7 +3708,7 @@ controlled by the sign of prefix numeric value."
 (defun viper-toggle-search-style (arg)
   "Toggle the value of viper-case-fold-search/viper-re-search.
 Without prefix argument, will ask which search style to toggle.  With prefix
-arg 1,toggles viper-case-fold-search; with arg 2 toggles viper-re-search.
+arg 1, toggles viper-case-fold-search; with arg 2 toggles viper-re-search.
 
 Although this function is bound to \\[viper-toggle-search-style], the most
 convenient way to use it is to bind `//' to the macro
@@ -3764,6 +3771,8 @@ If MAJOR-MODE is set, set the macros only in that major mode."
               "///" 'vi-state
               [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
               scope)
+             ;; XEmacs has no called-interactively-p
+             ;; (if (called-interactively-p 'interactive)
              (if (interactive-p)
                  (message
                   "// and /// now toggle case-sensitivity and regexp search")))
@@ -3787,6 +3796,9 @@ With a prefix argument, unsets the macro."
             "%%%" 'vi-state
             [(meta x) v i p e r - t o g g l e - p a r s e - s e x p - i g n o r e - c o m m e n t s return]
             't)
+           ;; XEmacs has no called-interactively-p. And interactive-p
+           ;; works fine here.
+           ;; (if (called-interactively-p 'interactive)
            (if (interactive-p)
                (message
                 "%%%%%% now toggles whether comments should be parsed for matching parentheses")))
@@ -3816,6 +3828,9 @@ the macros are set in the current major mode.
             "///" 'emacs-state
             [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
             (or arg-majormode major-mode))
+           ;; called-interactively-p does not work for
+           ;; XEmacs. interactive-p is ok here.
+           ;; (if (called-interactively-p 'interactive)
            (if (interactive-p)
                (message
                 "// and /// now toggle case-sensitivity and regexp search.")))
@@ -3897,7 +3912,7 @@ Null string will repeat previous search."
                (if (not (equal start-point (point)))
                    (push-mark start-point t)))
            (search-failed
-            (if (and (not fail-if-not-found) viper-search-wrap-around-t)
+            (if (and (not fail-if-not-found) viper-search-wrap-around)
                 (progn
                   (message "Search wrapped around BOTTOM of buffer")
                   (goto-char (point-min))
@@ -3926,7 +3941,7 @@ Null string will repeat previous search."
              (if (not (equal start-point (point)))
                  (push-mark start-point t)))
          (search-failed
-          (if (and (not fail-if-not-found) viper-search-wrap-around-t)
+          (if (and (not fail-if-not-found) viper-search-wrap-around)
               (progn
                 (message "Search wrapped around TOP of buffer")
                 (goto-char (point-max))
@@ -4229,7 +4244,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 ()
@@ -4238,27 +4253,27 @@ 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 ()
   "Delete one character in replace mode.
 If `viper-delete-backwards-in-replace' is t, then DEL key actually deletes
-charecters.  If it is nil, then the cursor just moves backwards, similarly
+characters.  If it is nil, then the cursor just moves backwards, similarly
 to Vi.  The variable `viper-ex-style-editing', if t, doesn't let the
 cursor move past the beginning of line."
   (interactive)
   (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)
@@ -4326,7 +4341,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
@@ -4596,7 +4611,7 @@ One can use `` and '' to temporarily jump 1 step back."
   (indent-to (+ (current-column) viper-shift-width)))
 
 (defun viper-backward-indent ()
-  "Backtab, C-d in VI"
+  "Backtab, `C-d' in Vi."
   (interactive)
   (if viper-cted
       (let ((p (point)) (c (current-column)) bol (indent t))
@@ -4604,12 +4619,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
@@ -4671,7 +4684,7 @@ One can use `` and '' to temporarily jump 1 step back."
              viper-InvalidRegister reg)))))
 
 (defun viper-brac-function (arg)
-  "Function called by \[, the brac.  View textmarkers and call \[\["
+  "Function called by \[, the brac.  View textmarkers and call \[\[."
   (interactive "P")
   (let ((reg (read-char)))
     (cond ((viper= ?\[ reg)
@@ -4688,15 +4701,12 @@ One can use `` and '' to temporarily jump 1 step back."
             (with-output-to-temp-buffer " *viper-info*"
               (if (and buf pos)
                   (progn
-                    (save-excursion
-                      (set-buffer buf)
+                    (with-current-buffer buf
                       (setq line-no (1+ (count-lines (point-min) val)))
                       (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)
@@ -4774,7 +4784,7 @@ sensitive for VI-style look-and-feel."
         (setq viper-no-multiple-ESC           t
               viper-re-search                 t
               viper-vi-style-in-minibuffer    t
-              viper-search-wrap-around-t      t
+              viper-search-wrap-around        t
               viper-electric-mode             nil
               viper-want-emacs-keys-in-vi     nil
               viper-want-emacs-keys-in-insert nil))
@@ -4905,7 +4915,7 @@ Please, specify your level now: ")
 
 ;; if ENFORCE-BUFFER is not nil, error if CHAR is a marker in another buffer
 (defun viper-register-to-point (char &optional enforce-buffer)
-  "Like jump-to-register, but switches to another buffer in another window."
+  "Like `jump-to-register', but switches to another buffer in another window."
   (interactive "cViper register to point: ")
   (let ((val (get-register char)))
     (cond
@@ -5030,7 +5040,7 @@ PLEASE FOLLOW THESE PROCEDURES
 ------------------------------
 
 Before reporting a bug, please verify that it is related to Viper, and is
-not cause by other packages you are using.
+not caused by other packages you are using.
 
 Don't report compilation warnings, unless you are certain that there is a
 problem.  These warnings are normal and unavoidable.
@@ -5075,5 +5085,4 @@ Mail anyway (y or n)? ")
 
 
 
-;; arch-tag: 739a6450-5fda-44d0-88b0-325053d888c2
 ;;; viper-cmd.el ends here