Function: ghostel--read-buffer

ghostel--read-buffer is a natively compiled function defined in ghostel.el.

Signature

(ghostel--read-buffer PROMPT BUFS)

Documentation

Prompt with PROMPT for one of BUFS via read-buffer.

Default candidate is the buffer ghostel-next would land on, so RET matches the forward-cycle direction. Returns the chosen buffer or signals user-error if BUFS is empty.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--read-buffer (prompt bufs)
  "Prompt with PROMPT for one of BUFS via `read-buffer'.
Default candidate is the buffer `ghostel-next' would land on, so RET
matches the forward-cycle direction.  Returns the chosen buffer or
signals `user-error' if BUFS is empty."
  (when (null bufs)
    (user-error "No ghostel buffers"))
  (let* ((names (mapcar #'buffer-name bufs))
         (current (current-buffer))
         (idx (cl-position current bufs))
         (default (cond
                   ((null idx) (car names))
                   (t (nth (mod (1+ idx) (length bufs)) names))))
         (completion-extra-properties
          (list :annotation-function #'ghostel-annotate-buffer))
         (chosen (read-buffer prompt default t
                              (lambda (cand)
                                (let ((name (if (consp cand) (car cand) cand)))
                                  (member name names))))))
    (get-buffer chosen)))