Open mihaiolteanu opened 2 years ago
You can use this function.
(defun cbm-cycle-reverse ()
"Cycles reverse through buffers with same `major-mode'."
(interactive)
(unless (eq last-command #'cbm-cycle-reverse)
(setq cbm-buffers nil))
(unless cbm-buffers
(cbm-make-buffer-list))
(setq cbm-buffers (append (last cbm-buffers) (butlast cbm-buffers)))
(let ((buffer (car cbm-buffers)))
(when (bufferp buffer)
(switch-to-buffer buffer))))
I tested this with 5 buffers, it worked. (note: last and butlast are in ‘subr.el’.)
How would one cycle backwards using cbm?
That is, suppose I have three buffers,
one
,two
,three
. The current selected buffer isone
. I callcbm-cycle
and now the selected buffer istwo
. If I want to select the bufferone
again, I would have to callcbm-cycle
two times, one to select bufferthree
and the second time to wrap-around to bufferone
. How would one implement acbm-cycle-back
function that would go fromtwo
toone
in the previous scenario in a single step?