7

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

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

4

7 回答 7

6

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

Emacs 可以使用哪些备用会话管理器?

于 2009-06-27T21:37:17.360 回答
4

我实际上正在研究解决这个问题的方法。我总是有一组我想同时打开/关闭的文件,以及打开 magit-status 窗口、dired 缓冲区等操作。我已经开始使用我自己的项目模式,称为 metaproject。它处于非常早期的阶段,但功能足够,我现在正在将它用于工作中的项目组。

在这里查看:http: //nafai77.github.com/metaproject/

git 中的内容非常稳定,尽管文档很少。我很快就会在这里重新开始工作。我目前有一个小型插件架构的基础知识,因此您可以注册可以在项目打开时执行的自定义操作。

于 2009-06-28T21:58:15.603 回答
2

我为自己使用以下“解决方案”:项目根目录由包含Makefile. 我已将 F12 绑定到特定于模式的 elisp 函数,该函数通过制作相应 Makefile 的第一个目标来“编译”项目。这是通过从当前文件的目录递归向上找到的。

这只是一点点设置,但您将永远不必重建您的.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))
)

然后,它会被 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")
    )
  ) 
于 2009-06-27T15:11:36.090 回答
2

eproject,但它的文档似乎很少。

于 2009-06-28T15:15:02.473 回答
1

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

于 2009-06-27T15:08:10.683 回答
1

请参阅http://www.emacswiki.org/emacs/CategoryProgrammerUtils#ProjectSupport。有几个包管理“项目”。我喜欢 mk-project,但话又说回来,我写了它。;-)

于 2010-01-20T23:13:46.087 回答
0

您可以使用桌面书签、Dired 书签或 Bookmark-List 书签来做您想做的事——请参阅Bookmark+。您甚至可以将代码和多个书签封装在一个书签中,以获得您想要的状态和设置。

另请参阅:Icicles 对项目的支持以获取更多选项。

于 2011-09-05T00:44:09.737 回答