ITADN

Compilation commands: use project-compilation-buffer-name-function

#21ClosedDivineDominion 创建于 2025-09-25
D
DivineDominioncommented
This affects `projection-commands-build-project` here, but also projection integration with compile-multi, so I'm bringing that idea up here for discussion. With project.el, you can have per-project compilation buffers See e.g. https://www.youtube.com/watch?v=Ta2bR6fNwBQ "Efficient Multi-Project Hacking in Emacs - System Crafters Live!" (1:35:00) ```elisp (defun ct/project-compilation-buffer-name-function (name-of-mode) (format "*compilation: %s*" (project-name (project-current)))) (setq project-compilation-buffer-name-function #'ct/project-compilation-buffer-name-function) ``` For `project-compile`, that creates e.g. `*compilation: projection*` buffer so you can have multiple per-project compilation processes running at the same time, instead of sharing `*compilation*`. With `projection-commands-build-project` and e.g. `projection-multi-compile`, you only get the default behavior as a user, unless you write an advice to override the compilation buffer resolution. For reference, the implementation is rather simple: ```elisp (defun project-compile () "Run `compile' in the project root." (declare (interactive-only compile)) (interactive) (let ((default-directory (project-root (project-current t))) (compilation-buffer-name-function (or project-compilation-buffer-name-function compilation-buffer-name-function))) (call-interactively #'compile))) ``` The interesting part boils down to: ```elisp (let ((compilation-buffer-name-function (or project-compilation-buffer-name-function compilation-buffer-name-function)) ....) ``` I'm not sure what the best approach would be for this. `projection-commands--run-command-for-type` could be decorated to set the buffer name function like this as it is a rather fundamental way to create compilation commands. Would that make sense or are there better ways?
关闭于 2025-09-27 1 条评论