Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Make *compilation* per-project #1517
Comments
|
Nice idea! I think that'd be pretty easy to implement. |
|
I started poking at this, but ran into some problems. ;; Run the compilation for each project in a buffer that contains the project name.
;;
;; This works, but I use direnv, and for some reason all the *compilation*
;; buffers seem to share a common direnv environment. I.e., whenever I switch
;; between *compilation* buffers, I have to `M-x direnv-update-environment`
;; before I can compile in it.
(setq compilation-buffer-name-function
(lambda (compilation-mode)
(concat "*" (downcase compilation-mode) "*<" (projectile-project-name) ">")))
;; When compiling, only ask to save buffers for the project getting compiled.
;;
;; This doesn't work at all. The problem is that this gets called like
;;
;; (with-current-buffer <unsaved-file-buffer>
;; (funcall compilation-save-buffers-predicate))
;;
;; which means that this always returns `t`, since `(projectile-project-root)`
;; is relative to `(current-buffer)`. To complain about Emacs a bit I wish
;; `(current-buffer)` referred to the *compilation* buffer, and the
;; unsaved-file-buffer was passed as a parameter ... this is a thunk for no good
;; reason, AFAICT.
;;
;; Since the *compilation* buffers are now named based on the project, I don't
;; see how I can find the correct projectile-project-root. E.g.,
;;
;; (let ((root (with-current-buffer "*compilation*" (projectile-project-root)))) ...)
;;
;; could approximate it if I wasn't trying to distinguish the buffers.
(setq compilation-save-buffers-predicate
(lambda ()
(let ((root (projectile-project-root)))
(or (not root)
(projectile-project-buffer-p (current-buffer) root))))) |
|
I think the direnv thing is probably independent (wbolster/emacs-direnv#16). Just probably hadn't noticed before because I wasn't switching between projects as often. |
|
For the second problem, figured out that I can do (with-current-buffer (window-buffer) (projectile-project-root))so that problem is solved. |
Currently, this requires that the user explicitly set
(setq compilation-buffer-name-function #'projectile-compilation-buffer-name)
(setq compilation-save-buffers-predicate #'projectile-current-project-buffer-p)
both of these degrade properly when not inside a project. Is there a better way
to enable these than telling a user that they should set the variables?
Fixes bbatsov#1517.
Currently, this requires that the user explicitly set
(setq compilation-buffer-name-function
#'projectile-compilation-buffer-name)
(setq compilation-save-buffers-predicate
#'projectile-current-project-buffer-p)
both of these degrade properly when not inside a project. Is there a
better way to enable these than telling a user that they should set the
variables?
Fixes bbatsov#1517.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Right now any compilation/test/etc. happens in the single
*compilation*buffer, so switching between projects isn't as independent as I would like (if the first project has a long compilation, I can't go work on something else and compile it while I wait for the first project to finish).Expected behavior
C-c p cto compile the current projectC-c p pto switch projectsC-c p cto compile the second project, both now compiling concurrently, ideally in buffers named something like*compilation*<project1>and*compilation*<project2>Actual behavior
The second
C-c p csays "A compilation process is running` kill it?"Steps to reproduce the problem
The expected behavior steps should do it, I think. You need two projects that have a compilation time of over a few seconds. Using
yesas the compilation command should get it to just run indefinitely.Environment & Version information
Projectile version information
Projectile 20191216.2105
Emacs version
GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.13)
Operating system
NixOS 20.03