Function: viper-prefix-arg-value

viper-prefix-arg-value is a byte-compiled function defined in viper-cmd.el.gz.

Signature

(viper-prefix-arg-value EVENT-CHAR COM)

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/viper-cmd.el.gz
;; Compute numeric prefix arg value.
;; Invoked by EVENT-CHAR.  COM is the command part obtained so far.
(defun viper-prefix-arg-value (event-char com)
  (let ((viper-intermediate-command 'viper-digit-argument)
	value func)
    ;; read while number
    (while (and (characterp event-char)
		(>= event-char ?0) (<= event-char ?9))
      (setq value (+ (* (if (integerp value) value 0) 10) (- event-char ?0)))
      (setq event-char (read-event)))

    (setq prefix-arg value)
    (if com (setq prefix-arg (cons prefix-arg com)))
    (while (eq event-char ?U)
      (viper-describe-arg prefix-arg)
      (setq event-char (read-event)))

    (if (or com (and (not (eq viper-current-state 'vi-state))
		     ;; make sure it is a Vi command
		     (characterp event-char)
		     (viper-vi-command-p event-char)
		     ))
	;; If appears to be one of the vi commands,
	;; then execute it with funcall and clear prefix-arg in order to not
	;; confuse subsequent commands
	(progn
	  ;; 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
	  ;; `d', `w', etc.  If viper-digit-argument was invoked by
	  ;; 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-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-event (or com event-char))
	  (setq func (viper-exec-form-in-vi
		      `(key-binding (char-to-string ,event-char))))
	  (funcall func prefix-arg)
	  (setq prefix-arg nil))
      ;; some other command -- let emacs do it in its own way
      (viper-set-unread-command-events event-char))
    ))