Function: erc-previous-command

erc-previous-command is an interactive and byte-compiled function defined in erc-ring.el.gz.

Signature

(erc-previous-command)

Documentation

Replace current command with the previous one from the history.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-ring.el.gz
(defun erc-previous-command ()
  "Replace current command with the previous one from the history."
  (interactive)
  (unless erc-input-ring (erc-input-ring-setup))
  ;; if the ring isn't empty
  (when (> (ring-length erc-input-ring) 0)
    (if (and erc-input-ring-index
             (= (ring-length erc-input-ring) (1+ erc-input-ring-index)))
        (progn
          (erc-replace-current-command "")
          (setq erc-input-ring-index nil))

      ;; If we are not viewing old input and there's text in the input
      ;; area, push it on the history ring before moving back through
      ;; the input history, so it will be there when we return to the
      ;; front.
      (when (and (null erc-input-ring-index)
                 (> (point-max) erc-input-marker))
        (erc-add-to-input-ring (erc-user-input))
        (setq erc-input-ring-index 0))

      (setq erc-input-ring-index (if erc-input-ring-index
                                     (ring-plus1 erc-input-ring-index
                                                 (ring-length erc-input-ring))
                                   0))
      (erc-replace-current-command (ring-ref erc-input-ring
                                             erc-input-ring-index)))))