In my .emacs file, I have my dream recompile function,

(require 'compile)
(defun jidanni-recompile ()
  (interactive)(recompile 'nil))
(global-set-key "\C-xc" 'jidanni-recompile)

It's "the fastest gun in the west" recompile function. No ifs, ands, or buts: no questions asked if I want to save the file (yes) or if I want to use the same command (yes).

OK, if I want to change the command I was using from the compile job I did two seconds ago, I do M-x compile and enter the new command I want to start using. Fine.

But the problem comes when I go to some new directory. And I forgot to do M-x compile to enter the new command, and it switches back to the old directory and does the old command.

Anyway, I need to make it detect that I have switched directories, and go back to asking me what command to use in that case. Also in the case where it's the first compile of the day, and also when I do "C-u C-x c". And in fact it should also notice that I don't seem to be in either the compilation buffer, or the buffer I was just in when I did the last recompile, and also ask me if indeed I am sure I still want to use the same compile command as last time.

(New tag idea: recompile .)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.