unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* project-compilation-buffer-name-function and recompile
@ 2024-01-17 20:54 Jörg Bornemann
  2024-01-18  5:30 ` Eli Zaretskii
  2024-01-19  0:45 ` Dmitry Gutov
  0 siblings, 2 replies; 5+ messages in thread
From: Jörg Bornemann @ 2024-01-17 20:54 UTC (permalink / raw)
  To: emacs-devel

Hi,

One can use project-compile to build a project and then call recompile
to repeat the compilation.  This reuses the buffer named
"*compilation*".

If I set project-compilation-buffer-name-function to
#'project-prefixed-buffer-name, this creates a compilation buffer
"*myproject-compilation*" when executing project-compile.  Now,
recompile won't re-use "*myproject-compilation*" but create a new
buffer "*compilation*".

To reproduce this behavior, it is enough to start Emacs like this:
$ emacs -Q --eval "(setq project-compilation-buffer-name-function 
#'project-prefixed-buffer-name)"

It would be nice if recompile could re-use project-compile's buffer 
name.  I have fixed this locally by setting 
compilation-buffer-name-function like this:

---snip---
   (defun my-compilation-buffer-name (name-of-mode)
     (if (project-current)
         (apply project-compilation-buffer-name-function (list 
name-of-mode))
       (compilation--default-buffer-name name-of-mode)))

   (setq compilation-buffer-name-function #'my-compilation-buffer-name)
---snap---

Although I'm thinking by now that it might be more consistent to have a 
separate project-recompile command in addition to
recompile.  What do you think?


Cheers,

Joerg



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: project-compilation-buffer-name-function and recompile
  2024-01-17 20:54 project-compilation-buffer-name-function and recompile Jörg Bornemann
@ 2024-01-18  5:30 ` Eli Zaretskii
  2024-01-19  0:45 ` Dmitry Gutov
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-01-18  5:30 UTC (permalink / raw)
  To: Jörg Bornemann; +Cc: emacs-devel

> Date: Wed, 17 Jan 2024 21:54:53 +0100
> From: Jörg Bornemann <foss@jbornemann.de>
> 
> One can use project-compile to build a project and then call recompile
> to repeat the compilation.  This reuses the buffer named
> "*compilation*".
> 
> If I set project-compilation-buffer-name-function to
> #'project-prefixed-buffer-name, this creates a compilation buffer
> "*myproject-compilation*" when executing project-compile.  Now,
> recompile won't re-use "*myproject-compilation*" but create a new
> buffer "*compilation*".
> 
> To reproduce this behavior, it is enough to start Emacs like this:
> $ emacs -Q --eval "(setq project-compilation-buffer-name-function 
> #'project-prefixed-buffer-name)"
> 
> It would be nice if recompile could re-use project-compile's buffer 
> name.  I have fixed this locally by setting 
> compilation-buffer-name-function like this:
> 
> ---snip---
>    (defun my-compilation-buffer-name (name-of-mode)
>      (if (project-current)
>          (apply project-compilation-buffer-name-function (list 
> name-of-mode))
>        (compilation--default-buffer-name name-of-mode)))
> 
>    (setq compilation-buffer-name-function #'my-compilation-buffer-name)
> ---snap---
> 
> Although I'm thinking by now that it might be more consistent to have a 
> separate project-recompile command in addition to
> recompile.  What do you think?

Thanks, I think what you say makes a lot of sense.  I suggest to
submit a feature-request bug report using "M-x report-emacs-bug" with
these details, so we could track this request.  If you can suggest a
patch to implement these ideas, it would be even better.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: project-compilation-buffer-name-function and recompile
  2024-01-17 20:54 project-compilation-buffer-name-function and recompile Jörg Bornemann
  2024-01-18  5:30 ` Eli Zaretskii
@ 2024-01-19  0:45 ` Dmitry Gutov
  2024-01-19 15:05   ` Jörg Bornemann
  1 sibling, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2024-01-19  0:45 UTC (permalink / raw)
  To: Jörg Bornemann, emacs-devel

Hi!

On 17/01/2024 22:54, Jörg Bornemann wrote:
> Hi,
> 
> One can use project-compile to build a project and then call recompile
> to repeat the compilation.  This reuses the buffer named
> "*compilation*".
> 
> If I set project-compilation-buffer-name-function to
> #'project-prefixed-buffer-name, this creates a compilation buffer
> "*myproject-compilation*" when executing project-compile.  Now,
> recompile won't re-use "*myproject-compilation*" but create a new
> buffer "*compilation*".
> 
> To reproduce this behavior, it is enough to start Emacs like this:
> $ emacs -Q --eval "(setq project-compilation-buffer-name-function 
> #'project-prefixed-buffer-name)"
> 
> It would be nice if recompile could re-use project-compile's buffer 
> name.  I have fixed this locally by setting 
> compilation-buffer-name-function like this:
> 
> ---snip---
>    (defun my-compilation-buffer-name (name-of-mode)
>      (if (project-current)
>          (apply project-compilation-buffer-name-function (list 
> name-of-mode))
>        (compilation--default-buffer-name name-of-mode)))
> 
>    (setq compilation-buffer-name-function #'my-compilation-buffer-name)
> ---snap---

This works.

Alternatively, you could add around-advice to recompile which would 
temporarily bind compilation-buffer-file-name-function.

> Although I'm thinking by now that it might be more consistent to have a 
> separate project-recompile command in addition to
> recompile.  What do you think?

The command could look like this:

   (defun project-recompile (&optional edit-command)
     (interactive "P")
     (let ((compilation-buffer-name-function 
project-compilation-buffer-name-function ))
       (recompile edit-command)))

It probably doesn't deserve a default key binding in project-prefix-map, 
but you could the same way to invoke it as you did with 'recompile'.

TBF, whenever I need to do a recompile-y action, I usually switch to the 
corresponding compilation buffer and press 'g'. That usually has the 
same effect and doesn't require remembering an extra command.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: project-compilation-buffer-name-function and recompile
  2024-01-19  0:45 ` Dmitry Gutov
@ 2024-01-19 15:05   ` Jörg Bornemann
  2024-01-21  5:06     ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Jörg Bornemann @ 2024-01-19 15:05 UTC (permalink / raw)
  To: Dmitry Gutov, emacs-devel

On 1/19/24 01:45, Dmitry Gutov wrote:

> Alternatively, you could add around-advice to recompile which would 
> temporarily bind compilation-buffer-file-name-function.

Nice, thanks for the suggestion!

>> Although I'm thinking by now that it might be more consistent to have 
>> a separate project-recompile command in addition to
>> recompile.  What do you think?
> 
> The command could look like this:
> 
>    (defun project-recompile (&optional edit-command)
>      (interactive "P")
>      (let ((compilation-buffer-name-function 
> project-compilation-buffer-name-function ))
>        (recompile edit-command)))
> 
> It probably doesn't deserve a default key binding in project-prefix-map, 
> but you could the same way to invoke it as you did with 'recompile'.

FWIW, I've filed this - as suggested by Eli - as bug#68570.

I agree that project-recompile wouldn't deserve a default key binding
since recompile doesn't have one.

> TBF, whenever I need to do a recompile-y action, I usually switch to the 
> corresponding compilation buffer and press 'g'. That usually has the 
> same effect and doesn't require remembering an extra command.

That also works.  It seems to be a common suggestion (for example [1])
though to key-bind recompile instead of switching to the compilation
buffer first.


Cheers,

Joerg

[1] https://www.masteringemacs.org/article/compiling-running-scripts-emacs



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: project-compilation-buffer-name-function and recompile
  2024-01-19 15:05   ` Jörg Bornemann
@ 2024-01-21  5:06     ` Dmitry Gutov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2024-01-21  5:06 UTC (permalink / raw)
  To: Jörg Bornemann, emacs-devel

On 19/01/2024 17:05, Jörg Bornemann wrote:
> On 1/19/24 01:45, Dmitry Gutov wrote:
> 
>> Alternatively, you could add around-advice to recompile which would 
>> temporarily bind compilation-buffer-file-name-function.
> 
> Nice, thanks for the suggestion!
> 
>>> Although I'm thinking by now that it might be more consistent to have 
>>> a separate project-recompile command in addition to
>>> recompile.  What do you think?
>>
>> The command could look like this:
>>
>>    (defun project-recompile (&optional edit-command)
>>      (interactive "P")
>>      (let ((compilation-buffer-name-function 
>> project-compilation-buffer-name-function ))
>>        (recompile edit-command)))
>>
>> It probably doesn't deserve a default key binding in 
>> project-prefix-map, but you could the same way to invoke it as you did 
>> with 'recompile'.
> 
> FWIW, I've filed this - as suggested by Eli - as bug#68570.

All right, let's continue there.

> I agree that project-recompile wouldn't deserve a default key binding
> since recompile doesn't have one.
> 
>> TBF, whenever I need to do a recompile-y action, I usually switch to 
>> the corresponding compilation buffer and press 'g'. That usually has 
>> the same effect and doesn't require remembering an extra command.
> 
> That also works.  It seems to be a common suggestion (for example [1])
> though to key-bind recompile instead of switching to the compilation
> buffer first.

I suppose it's a valid preference (otherwise we wouldn't have that 
command, I guess).

> 
> 
> Cheers,
> 
> Joerg
> 
> [1] https://www.masteringemacs.org/article/compiling-running-scripts-emacs




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-21  5:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17 20:54 project-compilation-buffer-name-function and recompile Jörg Bornemann
2024-01-18  5:30 ` Eli Zaretskii
2024-01-19  0:45 ` Dmitry Gutov
2024-01-19 15:05   ` Jörg Bornemann
2024-01-21  5:06     ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).