Function: evil-alternate-buffer

evil-alternate-buffer is a byte-compiled function defined in evil-commands.el.

Signature

(evil-alternate-buffer &optional WINDOW)

Documentation

Return the last buffer WINDOW has displayed other than the current one.

This is equivalent to Vim's alternate buffer.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
(defun evil-alternate-buffer (&optional window)
  "Return the last buffer WINDOW has displayed other than the current one.
This is equivalent to Vim's alternate buffer."
  ;; If the last buffer visited has been killed, then `window-prev-buffers'
  ;; returns a list with `window-buffer' at the head.
  (let* ((prev-buffers (window-prev-buffers))
         (head (car prev-buffers)))
    (if (eq (car head) (window-buffer window))
        (cadr prev-buffers)
      head)))