GNU bug report logs - #73545
30.0.91; Strange behaviour on switch-to-next-buffer

Previous Next

Package: emacs;

Reported by: Rahul Martim Juliato <rahuljuliato <at> gmail.com>

Date: Sun, 29 Sep 2024 04:27:02 UTC

Severity: normal

Found in version 30.0.91

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 73545 <at> debbugs.gnu.org (full text, mbox):

From: Rahul Martim Juliato <rahuljuliato <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 73545 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Rahul Martim Juliato <rahuljuliato <at> gmail.com>
Subject: Re: bug#73545: 30.0.91; Strange behaviour on switch-to-next-buffer
Date: Thu, 3 Oct 2024 18:19:23 -0300
[Message part 1 (text/plain, inline)]
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
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 226 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.