Subject: Re: bug#68081: 30.0.50; derived-mode and display-buffer-alist

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Dec 2023 12:12:35 +0200

> Date: Sat, 30 Dec 2023 10:30:40 +0100
> Cc: [email-masked], [email-masked]
> From: martin rudalics <[email-masked]>
> 
>  > Thanks.  I tend to document this subtlety, and otherwise leave it
>  > alone.
> 
> This was not an issue when 'display-buffer' was rewritten in 2011.  It
> became an issue when it started to use 'buffer-match-p' in 2022.

I guess it's a problem on the emacs-29 branch as well, then?

> A fairly safe fix would be
> 
> diff --git a/lisp/info.el b/lisp/info.el
> index 51e9eb72edf..e0d35591ee5 100644
> --- a/lisp/info.el
> +++ b/lisp/info.el
> @@ -768,6 +768,12 @@ info
>       ;; of names that might have been wrapped (in emails, etc.).
>       (setq file-or-node
>             (string-replace "\n" " " file-or-node)))
> +
> +  (unless (or buffer (derived-mode-p 'Info-mode))
> +    (setq buffer (get-buffer-create "*info*"))
> +    (with-current-buffer buffer
> +      (Info-mode)))
> +
>     (info-setup file-or-node
>   	      (pop-to-buffer-same-window (or buffer "*info*"))))
> 
> A still conservative but more advanced fix (that should DTRT in the case
> no window can be found) would be
> 
> diff --git a/lisp/info.el b/lisp/info.el
> index 51e9eb72edf..11e228b9bf8 100644
> --- a/lisp/info.el
> +++ b/lisp/info.el
> @@ -768,8 +768,16 @@ info
>       ;; of names that might have been wrapped (in emails, etc.).
>       (setq file-or-node
>             (string-replace "\n" " " file-or-node)))
> -  (info-setup file-or-node
> -	      (pop-to-buffer-same-window (or buffer "*info*"))))
> +
> +  (unless buffer
> +    (if (derived-mode-p 'Info-mode)
> +	(setq buffer "*info*")
> +      (setq buffer (get-buffer-create "*info*"))
> +      (with-current-buffer buffer
> +	(Info-mode))))
> +
> +  (pop-to-buffer-same-window buffer)
> +  (info-setup file-or-node buffer))
> 
>   (defun info-setup (file-or-node buffer)
>     "Display Info node FILE-OR-NODE in BUFFER."
> 
> Otherwise, you could suggest using
> 
> (setq display-buffer-alist '(((derived-mode . Info-mode)
>                                (display-buffer-in-side-window))
> 			     ("*info*" (display-buffer-in-side-window))))
> 
> as a fallback.

Thanks.  Would you recommend any of the above for the emacs-29 branch?
Or are these not safe enough there?