Subject: bug#31446: 26.1; sql-interactive-mode buffer naming is broken

From: Filipp Gunbin <[email-masked]>
Date: Fri, 18 May 2018 18:44:38 +0300

On 18/05/2018 15:19 +0300, Eli Zaretskii wrote:
...
>                  (funcall (sql-get-product-feature product :sqli-comint-func)
>                           product
>                           (sql-get-product-feature product :sqli-options)
> -                         (if (and new-name (string-prefix-p "SQL" new-name t))
> -                             new-name
> -                           (concat "SQL: " new-name))))
> +                         (cond
> +                          ((zerop new-name)
> +                           "*SQL*")
> +                          ((stringp new-name)
> +                           (if (string-prefix-p "SQL" new-name t)
> +                               new-name
> +                             (concat "*SQL: " new-name "*")))
> +                          ((eq new-name '(4))
> +                           (sql-rename-buffer new-name)
> +                           sql-alternate-buffer-name)
> +                          (t
> +                           (format "*SQL: %s*" new-name)))))
...

But `sql-comint' (called from `sql-comint-postgres' and the like) has
logic which prepares buffer name (adding those asterisks etc.)

In `sql-product-interactive', `new-name', if set to '(4) from prefix, or
to some other value from argument, controls this:

          (if (and (not new-name) buf)
              (pop-to-buffer buf)

So if `new-name' is set, we shouldn't switch to existing buffer.

Maybe just pass `new-name' to comint func like this (undoing possible
setting of `new-name' to '(4) above), letting it do all the
name-choosing work?

                (funcall (sql-get-product-feature product :sqli-comint-func)
                         product
                         (sql-get-product-feature product :sqli-options)
                         (if (equal '(4) new-name)
                            nil
                          new-name))

Filipp