[英]Is there any way to create a “project file” in Emacs?
最簡單的說法是“項目檔案”。 我有幾個python項目,我使用emacs W32 for Windows使用ropemacs。 理想的是,如果我可以在我的桌面上點擊一個圖標來打開emacs,打開繩子項目,並在該項目的頂級目錄中設置速度欄。 然后我也許可以有辦法以相同的方式在自己的emacs中打開下一個項目(但是對於那個項目)。 當然,如果有一個emacs命令或一個shell命令我可以使用它來實現相同的效果而不是桌面上的圖標也是可以接受的。
有沒有辦法做到這一點? 我絕對沒有elisp-fu。 :-(
您可以按照項目的方式設置所有內容,然后使用我發布的有關使用desktop.el和命名會話的答案:
我實際上正致力於解決這個問題。 我總是有一組我想要同時打開/關閉的文件,還有像打開magit-status窗口,一個直接緩沖區等等。我已經開始使用我自己的項目模式metaproject。 它處於早期階段,但功能足以讓我現在正在將它用於項目組。
在這里查看: http : //nafai77.github.com/metaproject/
git中的內容非常穩定,盡管文檔很少。 我很快就會再次開始研究它。 我目前掌握了一個小型插件架構的基礎知識,因此您可以注冊可以在項目打開時完成的自定義操作。
我自己使用以下“解決方案”:項目根目錄由包含Makefile
的目錄定義。 我已經將F12綁定到模式特定的elisp函數,該函數通過創建相應Makefile的第一個目標來“編譯”項目。 這是通過遞歸地從當前文件的目錄向上發現的。
這是一些設置,但您永遠不必重建您的.metadata
目錄,就像之前的Eclipse常見情況一樣。 一旦設置完畢,您只需要放置正確的Makefile,然后就可以完成項目了。
(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))
)
然后使用例如LaTeX和Python模式,如下所示:
(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")
)
)
有一些項目 ,但它似乎很少有文件記載。
您可以在bash / cmd.exe中自行滾動。 windows emacs發行版附帶一個名為runemacs.bat的.bat文件,它接受要作為參數打開的文件。 寫一個小腳本,它應該能夠從一個圖標打開所有內容。
請參閱http://www.emacswiki.org/emacs/CategoryProgrammerUtils#ProjectSupport 。 有幾個包管理“項目”。 我贊成mk-project,但是我再次寫了它。 ;-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.