From 1c3a86e7fc220963a1691462dbfa25b37799e287 Mon Sep 17 00:00:00 2001 From: Ivan Sokolov Date: Fri, 23 Apr 2021 03:14:44 +0300 Subject: [PATCH] Introduce project-compilation-buffer-name-function * lisp/progmodes/project.el (project-compilation-buffer-name-function): New option. (project-compile): Use it. (project-prefixed-buffer-name): New function. Copyright-paperwork-exempt: yes --- lisp/progmodes/project.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 1023b75e668..35ce5eb2d15 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -994,12 +994,33 @@ loop using the command \\[fileloop-continue]." (defvar compilation-read-command) (declare-function compilation-read-command "compile") +(defun project-prefixed-buffer-name (mode) + (concat "*" + (file-name-nondirectory + (directory-file-name default-directory)) + "-" + (downcase mode) + "*")) + +(defcustom project-compilation-buffer-name-function nil + "Function to compute the name of a project compilation buffer. +If non-nil, it overrides `compilation-buffer-name-function' for +`project-compile'." + :group 'project + :type '(choice (const :tag "Default" nil) + (const :tag "Prefixed with root directory name" + project-prefixed-buffer-name) + (function :tag "Custom function"))) + ;;;###autoload (defun project-compile () "Run `compile' in the project root." (declare (interactive-only compile)) (interactive) - (let ((default-directory (project-root (project-current t)))) + (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))) (defun project--read-project-buffer () -- 2.39.2