Function: viper-insert-prev-from-insertion-ring

viper-insert-prev-from-insertion-ring is an interactive and byte-compiled function defined in viper-cmd.el.gz.

Signature

(viper-insert-prev-from-insertion-ring ARG)

Documentation

Cycle through insertion ring in the direction of older insertions.

Undoes previous insertion and inserts new. With prefix argument, cycles in the direction of newer elements. In minibuffer, this command executes whatever the invocation key is bound to in the global map, instead of cycling through the insertion ring.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/viper-cmd.el.gz
(defun viper-insert-prev-from-insertion-ring (arg)
  "Cycle through insertion ring in the direction of older insertions.
Undoes previous insertion and inserts new.
With prefix argument, cycles in the direction of newer elements.
In minibuffer, this command executes whatever the invocation key is bound
to in the global map, instead of cycling through the insertion ring."
  (interactive "P")
  (let (viper-intermediate-command)
    (if (eq last-command 'viper-insert-from-insertion-ring)
	(progn  ; repeated search through insertion history
	  (setq viper-intermediate-command 'repeating-insertion-from-ring)
	  (if (eq viper-current-state 'replace-state)
	      (undo 1)
	    (if viper-last-inserted-string-from-insertion-ring
		(delete-char
                 (- (length viper-last-inserted-string-from-insertion-ring)))))
	  )
      ;;first search through insertion history
      (setq viper-temp-insertion-ring (ring-copy viper-insertion-ring)))
    (setq this-command 'viper-insert-from-insertion-ring)
    ;; so that things will be undone properly
    (setq buffer-undo-list (cons nil buffer-undo-list))
    (setq viper-last-inserted-string-from-insertion-ring
	  (viper-special-ring-rotate1 viper-temp-insertion-ring (if arg 1 -1)))

    ;; this change of viper-intermediate-command must come after
    ;; viper-special-ring-rotate1, so that the ring will rotate, but before the
    ;; insertion.
    (setq viper-intermediate-command nil)
    (if viper-last-inserted-string-from-insertion-ring
	(insert viper-last-inserted-string-from-insertion-ring))
    ))