Subject: bug#68570: 29.1; recompile might not re-use project-compile's buffer

From: Juri Linkov <[email-masked]>
Date: Sat, 27 Jan 2024 19:53:34 +0200

>> It's very useful to always create a unique buffer for every compilation:
>> this allows keeping error messages from previous compilations.
>
> Hmm, but I suppose it can be a personal preference whether a "recompile"
> should create a new buffer or not.
>
> Because it's also reasonable to expect that 'M-x compile' creates a new
> buffer (e.g. project-prefixed and unique), but 'recompile', or
> 'revert-buffer' - keep that buffer around and reuse it. When one wants to
> keep the old contents, they could 'M-x compile' (or 'M-x project-compile')
> instead.
>
> This might be my preference anyway, because OT1H old compilations are often
> (but not always) handy to have around, OT2H I don't like to have too many
> buffers, and the above distinction between 'compile' and 'recompile' would
> be a tool to make that choice.

A new option could be added indeed.  But currently 'g' after 'compile'
uses 'compilation-buffer-name-function' that can be configured
to generate a new buffer.  So it's expected that 'g' after
'project-compile' should do the same and use
'project-compilation-buffer-name-function', especially
when it's configured to generate a new buffer.

IOW, I think these two 'compile' and 'project-compile'
should be in sync in regard to what 'recompile' does.

>> I propose even to add such an option to the choice list in
>> project-compilation-buffer-name-function, e.g.:
>> (defcustom project-compilation-buffer-name-function nil
>>    :type '(choice (const :tag "Default" nil)
>>                   (const :tag "Prefixed with project name"
>>                          project-prefixed-buffer-name)
>>                   (const :tag "Prefixed and unique with project name"
>>                          project-prefixed-unique-buffer-name)
>>                   (function :tag "Custom function")))
>
> Sounds good.

There is also a proposal to add the same option
to 'compilation-buffer-name-function' in bug#68697.

>> The previous patch would be needed as well since currently
>> there is no way to allow unique project compilation buffers.
>
> The one in 0a07603ae8d?

Actually I meant https://debbugs.gnu.org/68570#23