Как сделать, чтобы при переходе в другой каталог(исходники в проекте разложены по каталогам) emacs(M-x compile) искал Makefile в корне проекта, а не в каталоге с текущим файлом?
(defvar *project-root-dir-indicator* "root-project-dir")
;;; not too portable
(defun find-root-project-dir ()
"Return path to root project directory"
(loop for curdir = default-directory then (concat curdir "../")
and
max = 10 then (- max 1)
while (> max 0)
when (file-exists-p (concat curdir *project-root-dir-indicator*))
return curdir))
;;; compilation
(defun my-save-and-compile (&rest params)
"Saves all dirty buffers and tries to compile all the proj"
(interactive "")
(save-buffer 0)
(compile
(let ((dir (find-root-project-dir)))
(concat "make"
(when dir (concat " -C "
dir
" "
(with-temp-buffer
(insert-file-contents (concat dir "/" *project-root-dir-indicator*))
(buffer-string))))
(when params (concat " " (car params)))))))
(global-set-key [(f9)] 'my-save-and-compile)
Можете заменить "root-project-dir" на Makefile, но мне кажется это
неудобным.