]> git.eshelyaron.com Git - emacs.git/commitdiff
Introduce project-compilation-buffer-name-function
authorIvan Sokolov <ivan-p-sokolov@ya.ru>
Fri, 23 Apr 2021 00:14:44 +0000 (03:14 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 23 Apr 2021 00:14:44 +0000 (03:14 +0300)
* 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

index 1023b75e6686ff1b5139fab89e9aa06cca530159..35ce5eb2d15acdfe89e9ead8500c87e55ce7c41c 100644 (file)
@@ -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 ()