Emacs: Next/Previous User Buffer π
emacs has commands to switch to prev/next buffer.
next-buffer
γCtrl+x Ctrl+βγ- switch to next buffer.
previous-buffer
γCtrl+x Ctrl+βγ- switch to previous buffer.
one problem is that they will go thru many buffers user are not interested in cycling thru.
Examples of emacs generated buffers:
*scratch*
*Messages*
*shell*
*Shell Command Output*
*Occur*
*Completions*
*Apropos*
*info*
Prev / Next User Buffers
here's commands that just cycle thru user buffers, or emacs buffers.
(defun xah-user-buffer-p () "Return t if current buffer is a user buffer, else nil. A user buffer has buffer name NOT starts with * or space, and is not dired mode, help mode, etc. This function is used by buffer switching command and close buffer command, so that next buffer shown is a user buffer. You can override this function to get your idea of βuser bufferβ. URL `http://xahlee.info/emacs/emacs/elisp_next_prev_user_buffer.html' Created: 2016-06-18 Version: 2025-09-05" (interactive) (cond ((string-match "^\*" (buffer-name)) nil) ;; ((eq major-mode 'dired-mode) nil) ;; ((eq major-mode 'eww-mode) nil) ;; ((eq major-mode 'help-mode) nil) (t t)))
(defun xah-next-user-buffer () "Switch to the next user buffer. User Buffer here is determined by `xah-user-buffer-p'. URL `http://xahlee.info/emacs/emacs/elisp_next_prev_user_buffer.html' Created: 2016-06-19 Version: 2025-09-08" (interactive) (seq-some (lambda (_) (next-buffer) (xah-user-buffer-p)) (make-list 50 0)))
(defun xah-previous-user-buffer () "Switch to the previous user buffer. User Buffer here is determined by `xah-user-buffer-p'. URL `http://xahlee.info/emacs/emacs/elisp_next_prev_user_buffer.html' Created: 2016-06-19 Version: 2025-09-08" (interactive) (seq-some (lambda (_) (previous-buffer) (xah-user-buffer-p)) (make-list 50 0)))
Latest code in Emacs: Xah Fly Keys π¦
Be sure to set a easy key for them, such as F11 F12 γsee Emacs Keys: Define Keyγ