rpav / cmake-build.el

CMake building with multiple targets, run configurations, and interactive menu
GNU General Public License v3.0
14 stars 5 forks source link

Use emacs compile instead of async-shell-command. #5

Closed dlyr closed 4 years ago

dlyr commented 4 years ago

Also use the compile split window with auto scroll instead of the customized one. Still use custom name.

One issue is that next-error tracks the last started compilation output.

dlyr commented 4 years ago

Maybe I do not catch everything on the current behavior, but on my side this seems to work as I like to ;)

rpav commented 4 years ago

While compile is nice and I've been meaning to look at it (I didn't realize it was such a simple call), this patch is mostly about reversing the behavior I want and at the same time has issues (e.g., you should almost certainly not (setq compilation-buffer-name-function ..).. this is what LET is for).

The acceptable approach would be:

As such this will not be merged; however if you want to make something like the above, let me know. I can also do this and @ you for the (compile) stuff if you'd like.

dlyr commented 4 years ago

Fair, So actually what I would like to have is a next-error function, and auto scroll. If you see how to handle that with your package that's perfect. I could also maintain my fork with compile until I see some issue. As far as I understand compile package, the setq is to have compile package stuff use the new buffer name, until you set it again, to compile another project for instance. Another way is to call compilation-start which takes the name-function as optional argument.

rpav commented 4 years ago

Generally in lispy languages you avoid setq/setf especially for dynamic variables (that is, things created with defvar). This is because you can easily set them with let:

(let ((compilation-buffer-name-function #'cmake-build--build-buffer-name))
  (compile ...)

This has the same effect, but the binding is only in effect during the let block.

rpav commented 4 years ago

Err.. also, what do you mean "auto-scroll" .. does the compile buffer not scroll for you during compilation? (Because it does for me...) Or is this part of the next-error stuff?

dlyr commented 4 years ago

I didn't know for the let things (i'm far from a lisp guru ;)) and definitely give it a try. Yes the autoscroll is that the compilation buffer do not scroll automatically. I do not dig too far to check why, it may be some of my other config that interfere. If it's not the case I will give you feedback in an issue (but I do not have the time right now). Thanks for you quick answer.

dlyr commented 4 years ago

(you're right auto scroll works perfectly with master version ... dunno why I could not get it working) (the let alternative you propose works also perfectly) (so the things that I miss is easy jump to error, and kill-compilation, but maybe it's already there I just do not know how to have it)

rpav commented 4 years ago

OK I added these things.

The compile window scrolling thing was a bit of an annoyance, and it's still unclear what the cause is, but if you switch to the window, temporarily or permanently, then call COMPILE, scrolling works. This lead to me implementing a "switch to the compile buffer" option too, which I'm even using now.

Note I also use the t flag to use comint mode with compile .. I'm not entirely sure what this is, except if it's not active, I can't hit C-c C-c to stop the build, which is bad. ;)

dlyr commented 4 years ago

Not sure it's your question, but to kill the compilation I use 'kill-compilation

laurynas-biveinis commented 4 years ago

Thank you both for working on this - this was also on my TODO list, but you beat me into it.

Re, https://github.com/rpav/cmake-build.el/commit/624220b27028e13e9d58af316a1de6aa39164f93, would it be possible not to touch compilation-scroll-output in cmake-build--compile? It's a user configuration, IMHO, the package should honor it. For example, I have it set to 'first-error and intend to keep it this way with cmake-build too.

rpav commented 4 years ago

Fixed. That was an artifact of experimenting to get it to work at all really.