Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs ( recompile -y )

Tags:

emacs

elisp

Is it possible to pass a "-yes" flag to the 'recompile' command in emacs?

Excuse my complete lack of (e)lisp know-how. I got sick of going outside Emacs to compile my latex code, so i added the following key binding to my .emacs:

(global-set-key (kbd "<f12>") 'recompile);

Is it possible to automatically answer 'yes' to the following prompt that might appear: "A compilation process is running; kill it? (yes or no)."

Also, is it possible to make the window that opens and shows the output to scroll to the bottom automatically. The interesting stuff is typically down there. Maybe its possible to chain the following command after recompile: "C-x o, end-of-buffer".

Thanks!

like image 588
qonf Avatar asked Dec 06 '10 11:12

qonf


2 Answers

Here's some code to solve your first problem (interrupting the current compilation):

(defun interrupt-and-recompile ()
  "Interrupt old compilation, if any, and recompile."
  (interactive)
  (ignore-errors (kill-compilation))
  (recompile))

For your second problem (scrolling the compilation output), just customize the user setting compilation-scroll-output.

like image 198
Gareth Rees Avatar answered Nov 13 '22 10:11

Gareth Rees


This behaviour is governed by the compilation-always-kill global variable. Customize it via customize-variable and set it to t.

Not sure which version of emacs first had this, but 26 and newer certainly does.

like image 24
Perkins Avatar answered Nov 13 '22 10:11

Perkins