On Sun, Sep 29, 2024 at 05:49:35PM +0200, martin rudalics wrote: > > What > > is the value of that variable? > > Found as: > > (setq switch-to-prev-buffer-skip-regexp "\\*[^*]+\\*") > > And the explanation is this snippet from 'switch-to-prev-buffer': > > (when (and skipped (not (functionp switch-to-prev-buffer-skip))) > ;; Show first skipped buffer, unless skip was a function. > (setq new-buffer skipped) > (set-window-buffer-start-and-point window new-buffer))) > > That is, if the regexp excludes a specific buffer but > 'switch-to-prev-buffer' didn't find another suitable buffer, it switches > to the first excluded buffer. The Elisp manual is clear about this: > > This user option should be either a regular expression or a list of > regular expressions. Buffers whose names match one of those > regular expressions will be ignored by ‘switch-to-prev-buffer’ and > ‘switch-to-next-buffer’ (except when there’s no other buffer to > switch to). > > So if you want to make sure that *Messages* gets always excluded, you > have to specify a function based on that regexp like > > (defun skip-these-buffers (_window buffer _bury-or-kill) > "Function for `switch-to-prev-buffer-skip'." > (string-match "\\*[^*]+\\*" (buffer-name buffer))) > > (setq switch-to-prev-buffer-skip 'skip-these-buffers) > > martin Thanks a lot for the clarification! I just found a bit strange the default behaviour (I guess I am biased by my use case) being this way. The snippet you provided is exactly what I was looking for. I think this is all for this thread :) -- Rahul Martim Juliato https://www.rahuljuliato.com PGP Fingerprint: 6B68 4353 84E2 2C7E 5A26 B79A C666 FC94 BD7E A483 PGP Public Key : https://www.rahuljuliato.com/rahul_pub_key.asc