Function: ghostel--cycle
ghostel--cycle is a natively compiled function defined in ghostel.el.
Signature
(ghostel--cycle BUFS DIRECTION EMPTY-MSG SINGLE-MSG)
Documentation
Pop to the BUFS entry DIRECTION steps from current; wraps around.
DIRECTION is +1 or -1. Signals user-error with EMPTY-MSG when
BUFS is empty. Shows SINGLE-MSG when BUFS contains only the
current buffer. If the current buffer is not in BUFS, jump to
the first or last entry depending on DIRECTION.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--cycle (bufs direction empty-msg single-msg)
"Pop to the BUFS entry DIRECTION steps from current; wraps around.
DIRECTION is +1 or -1. Signals `user-error' with EMPTY-MSG when
BUFS is empty. Shows SINGLE-MSG when BUFS contains only the
current buffer. If the current buffer is not in BUFS, jump to
the first or last entry depending on DIRECTION."
(cond
((null bufs)
(user-error "%s" empty-msg))
((and (= (length bufs) 1) (eq (car bufs) (current-buffer)))
(message "%s" single-msg))
(t
(let* ((current (current-buffer))
(idx (cl-position current bufs))
(n (length bufs))
(next (cond
((null idx) (if (> direction 0) (car bufs) (car (last bufs))))
(t (nth (mod (+ idx direction) n) bufs)))))
(pop-to-buffer next (append display-buffer--same-window-action
'((category . comint))))))))