Io uso la seguente "soluzione" per me stesso: una radice di progetto è definita da una directory che contiene un Makefile
. Ho associato F12 alla funzione di elisp specifica della modalità che "compila" il progetto creando il primo target del corrispondente Makefile, che si trova ricorsivamente andando verso l'alto dalla directory del file corrente.
È un po 'di configurazione, ma si nevica Devo ricostruire la tua directory come succedeva spesso con Eclipse. E una volta impostato, devi solo posizionare i Makefile appropriati e avere i tuoi progetti.
(defun get-makefile-recursively-higher()
(loop for i below 100 for cwd = (expand-file-name default-directory)
then next for next = (expand-file-name (concat cwd "/..")) for file =
(concat cwd "/" "Makefile") do (cond ((and (file-exists-p file))
(return file))) until (equal cwd next))
)
Viene quindi utilizzato per es. dal LaTeX e modalità di Python come segue:
(defun py-execute-prog (&optional target)
"Invoke python on the file being edited in the current buffer using
arguments obtained from the minibuffer. It will save all of the modified
buffers before trying to execute the file."
(interactive)
(let* (makefile file cmd)
(setq makefile (get-makefile-recursively-higher))
(setq file (buffer-file-name (current-buffer)))
(setq cmd (concat "make -f " makefile))
(setq default-directory (file-name-directory makefile))
(save-some-buffers (not py-ask-about-save) nil)
(setq py-pdbtrack-do-tracking-p t)
(if (get-buffer py-output-buffer)
(kill-buffer py-output-buffer)) ; Get rid of buffer if it exists.
(global-unset-key "\C-x\C-l")
(global-unset-key "\C-x\C-p")
(global-unset-key "\C-x\C-e")
(global-unset-key "\C-x\C-n")
(global-set-key "\C-x\C-l" 'py-last-exception)
(global-set-key "\C-x\C-p" 'py-previous-exception)
(global-set-key "\C-x\C-e" 'py-current-line-exception)
(global-set-key "\C-x\C-n" 'py-next-exception)
(define-key comint-mode-map [mouse-3] 'py-current-line-exception)
(make-comint "Python Output" "make" nil "-f" makefile)
(if (not (get-buffer py-output-buffer))
(message "No output.")
(setq py-exception-buffer (current-buffer))
(pop-to-buffer py-output-buffer)
)))
(defun make-tex (&optional target)
(interactive)
(let (makefile cmd)
(setq makefile (get-makefile-recursively-higher))
(save-buffer)
(TeX-save-document (TeX-master-file))
(setq cmd (concat "make -j4 -f " makefile " LATEXPARAM=\"-halt-on-error -file-line-error\""
" TEXMASTER=" (expand-file-name (TeX-master-file)) ".tex"
" TEXMASTERDIR=" (file-name-directory makefile) "/"))
(when (stringp target)
(setq cmd (concat cmd " " target))
)
(ad-activate-regexp "auto-compile-yes-or-no-p-always-yes")
(compile cmd)
(ad-deactivate-regexp "auto-compile-yes-or-no-p-always-yes")
)
)
fonte
2009-06-27 15:11:36
Bene che le persone ci stanno lavorando! Sono abituato a un editor di codice commerciale e molto nuovo a emacs, mi piacerebbe avere una ricerca limitata a file di progetto, completamento automatico, anteprima di prototipi di funzioni a seconda di cosa è sotto il cursore ... Esistono già io Immagino, ma averli limitati al contenuto di un progetto non la penso così. – Gauthier