Function: viper-repeat
viper-repeat is an interactive and byte-compiled function defined in
viper-cmd.el.gz.
Signature
(viper-repeat ARG)
Documentation
Re-execute last destructive command.
Use the info in viper-d-com, which has the form
(com val ch reg inserted-text command-keys),
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.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/emulation/viper-cmd.el.gz
(defun viper-repeat (arg)
"Re-execute last destructive command.
Use the info in viper-d-com, which has the form
\(com val ch reg inserted-text command-keys),
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'."
(interactive "P")
(let ((save-point (point)) ; save point before repeating prev cmd
;; Pass along that we are repeating a destructive command
;; This tells viper-set-destructive-command not to update
;; viper-command-ring
(viper-intermediate-command 'viper-repeat))
(if (eq last-command 'viper-undo)
;; if the last command was viper-undo, then undo-more
(viper-undo-more)
;; otherwise execute the command stored in viper-d-com. if arg is
;; non-nil its prefix value is used as new prefix value for the command.
(let ((m-com (car viper-d-com))
(val (viper-P-val arg))
(com (nth 2 viper-d-com))
(reg (nth 3 viper-d-com)))
(if (null val) (setq val (nth 1 viper-d-com)))
(if (null m-com) (error "No previous command to repeat"))
(setq viper-use-register reg)
(if (nth 4 viper-d-com) ; text inserted by command
(setq viper-last-insertion (nth 4 viper-d-com)
viper-d-char (nth 4 viper-d-com)))
(funcall m-com (cons val com))
(cond ((and (< save-point (point)) viper-keep-point-on-repeat)
(goto-char save-point)) ; go back to before repeat.
((and (< save-point (point)) viper-ex-style-editing)
(or (bolp) (backward-char 1))))
(if (and (eolp) (not (bolp)))
(backward-char 1))
))
(viper-adjust-undo) ; take care of undo
;; If the prev cmd was rotating the command ring, this means that `.' has
;; just executed a command from that ring. So, push it on the ring again.
;; If we are just executing previous command , then don't push viper-d-com
;; because viper-d-com is not fully constructed in this case (its keys and
;; the inserted text may be nil). Besides, in this case, the command
;; executed by `.' is already on the ring.
(if (eq last-command 'viper-display-current-destructive-command)
(viper-push-onto-ring viper-d-com 'viper-command-ring))
(deactivate-mark)
))