How to move to previous or next buffer in a fixed & arbitrary order? I am using C-<left> and C-<right> but they move in a variable order, depending on the last viewed buffer, but if I want to switch back and forth between the two last files I worked in, with C-x b RET, then C-<left> and C-<right> would be always setting the two last viewed files in the ring, making it pointless.
When moving with next/previous, the idea is to have different alternatives: a manually sorted ring, last viewed ring, and other sorts (alphabetical, size, etc.). This by preserving or integrating the option of moving back and forth between the two last viewed the way C-x b RET does.
Individually sorting buffers is maybe too much, but is kind of important, since the typical tab system of ordinary editors allow for manually sorting the tabs.
Hopefully the sorting work for picking the buffers with ido-mode too.
Need to install a library or not necessary?
buffer-list
andburied-buffer-list
cannot reliably be controlled in terms of ordering all buffers -- i.e., the list will change outside of your control. So, consider using something to organize those buffers first and then select a particular buffer. Alternatively, consider setting a value of buffers in a particular order and recording/embedding that list in theframe-parameter
-- updating as needed. Then, you can access buffers from that recorded/embedded list that will be frame-local. You can programmatically alter or sort that list. Seeframe-bufs
by Alp Aker for some idea. – lawlist May 15 '16 at 3:24magic-buffer-list
will do the alphabetic sort that you want out-of-the-box with a little customization of the default sorting: raw.githubusercontent.com/aclements/.emacs.d/master/lisp/… There is a previous and next function. Read through the library to understand how to set the defaults to your liking. You can then prevent the buffer list buffer from appearing if you don't want to see it. Word search forwards and backwards in the source code to see theinteractive
functions meant to be called by the user interactively. – lawlist May 15 '16 at 6:21(defun ido-alpha-switch-buffer () (interactive) (let* ( (string-buffer-list (mapcar (lambda (x) (buffer-name x)) (buffer-list))) (buffer-list-alphabetized (sort string-buffer-list #'(lambda (e1 e2) (string-lessp e1 e2)))) (buffer (ido-completing-read "Select Buffer: " buffer-list-alphabetized)) ) (unless (minibufferp buffer) (switch-to-buffer buffer))))
– lawlist May 15 '16 at 17:26