有没有办法在Emacs中创建“项目文件”?

时间:2009-06-27 14:56:05

标签: python windows emacs elisp ropemacs

我说的是最简单的“项目文件”。我有几个python项目,我使用emacs W32 for Windows使用ropemacs。理想的是,如果我可以在我的桌面上点击一个图标来打开emacs,打开绳子项目,并在该项目的顶级目录中设置速度栏。然后我也许可以有办法以相同的方式在自己的emacs中打开下一个项目(但是对于那个项目)。当然,如果有一个emacs命令或一个shell命令可以用来实现相同的效果而不是桌面上的图标,那也是可以接受的。

有没有办法做到这一点?我绝对没有elisp-fu。 : - (

7 个答案:

答案 0 :(得分:6)

您可以按照项目的方式设置所有内容,然后使用我发布的有关使用desktop.el和命名会话的答案:

What alternate session managers are available for Emacs?

答案 1 :(得分:4)

我正在努力解决这个问题。我总是有一组我想要同时打开/关闭的文件,还有像打开magit-status窗口,一个直接缓冲区等等。我已经开始使用我自己的项目模式metaproject。它处于早期阶段,但功能足以让我现在正在将它用于项目组。

请在此处查看:http://nafai77.github.com/metaproject/

git中的内容非常稳定,尽管文档很少。我很快就会再次开始研究它。我目前掌握了一个小型插件架构的基础知识,因此您可以注册可以在项目打开时完成的自定义操作。

答案 2 :(得分:2)

我自己使用以下“解决方案”:项目根目录由包含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")
    )
  ) 

答案 3 :(得分:2)

eproject,但似乎记录很少。

答案 4 :(得分:1)

您可以在bash / cmd.exe中自行滚动。 windows emacs发行版附带一个名为runemacs.bat的.bat文件,它接受要作为参数打开的文件。写一个小脚本,它应该可以从一个图标打开所有内容。

答案 5 :(得分:1)

http://www.emacswiki.org/emacs/CategoryProgrammerUtils#ProjectSupport。有几个包管理“项目”。我赞成mk-project,但是我再次写了它。 ; - )

答案 6 :(得分:0)

您可以使用桌面书签,Dired书签或书签列表书签来执行您想要的操作 - 请参阅Bookmark+。您甚至可以将代码和多个书签封装在一个书签中,以获得您想要的状态和设置。

另请参阅:Icicles support for projects了解更多选项。