2009-06-27 173 views
7

我從最寬鬆的意義上說「項目文件」。我有幾個python項目,我使用emacs W32 for Windows與ropemacs一起工作。最理想的是,如果我可以在桌面上點擊圖標打開emacs,打開rope項目,並將速度欄設置爲該項目的頂層目錄。然後,我也可能有辦法以相同的方式(但對於該項目)以自己的emacs打開下一個項目。當然,如果在我的桌面上有一個emacs命令或一個我可以用來實現相同效果而不是圖標的shell命令,也是可以接受的。有什麼辦法可以在Emacs中創建「項目文件」?

有沒有辦法做到這一點?我絕對沒有elisp-fu。 :-(

回答

1

你可以在bash/cmd.exe中自己打開,windows emacs發行版帶有一個名爲runemacs.bat的.bat文件,該文件接受要作爲參數打開的文件。編寫一個小腳本,它應該能夠從一個圖標打開所有東西

2

我爲自己使用以下「解決方案」:項目根由包含Makefile的目錄定義,我已將F12綁定到特定於模式的elisp函數,該函數「編譯」該項目通過創建相應的Makefile的第一個目標,這是通過遞歸地從當前文件的目錄向上發現的

這是一個有點設置,但你將neve r必須重新構建您的.metadata目錄,就像以前的Eclipse一樣。一旦建立起來,你只需要放置適當的Makefiles,並且你有你的項目。

(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)) 
) 

然後,例如,由乳膠和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") 
    ) 
) 
2

eproject,但它似乎非常稀疏記錄。

4

我實際上正在解決這個問題。我總是有一組我想同時打開/關閉的文件,另外還可以做一些事情,比如打開一個magit-status窗口,一個dired buffer等。我已經開始使用我自己的項目模式metaproject。它處於早期階段,但功能足夠強大,我現在正在將它用於項目組。

看看這裏:http://nafai77.github.com/metaproject/

是什麼在Git是相當穩定,雖然稀疏文件。我將很快在這裏再次開始工作。我目前擁有一個小插件體系結構的基礎知識,因此您可以註冊可在項目打開時完成的自定義操作。

+0

好,人們正在努力! 我習慣了一個商業代碼編輯器,並且對emacs非常新穎,我希望僅限於項目文件的搜索,自動完成,根據光標下的內容預覽函數原型......這些已經存在I猜測,但讓他們僅限於項目的內容,我不這麼認爲。 – Gauthier 2010-01-18 13:36:35

0

您可以使用桌面書籤,Dired書籤或書籤列表書籤來做你想做的事 - 見Bookmark+。您甚至可以將代碼和多個書籤封裝在單個書籤中,以獲取所需的狀態和設置。

另請參閱:Iciclessupport for projects更多選項。

相關問題