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

发布于 2024-07-25 10:23:24 字数 305 浏览 12 评论 0原文

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

有什么办法可以做到这一点吗? 我绝对没有 elisp-fu。 :-(

I say "project file" in the loosest sense. I have a few python projects that I work on with ropemacs using emacs W32 for Windows. What would be ideal is if I could have an icon I could click on on my desktop to open up emacs, open up the rope project, and set the speed bar in the top-level directory of that project. Then I could also maybe have a way to open up the next project in its own emacs set up the same way (but for that project). Of course, it's also acceptable if there were an emacs command or a shell command I could use to achieve the same effect instead of an icon on my desktop.

Is there any way to do this? I have absolutely no elisp-fu. :-(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

-黛色若梦 2024-08-01 10:23:24

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

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

You could get everything set up the way you want for a project, then use the answer I posted about using desktop.el and named sessions:

What alternate session managers are available for Emacs?

摇划花蜜的午后 2024-08-01 10:23:24

我实际上正在研究解决这个问题的方法。 我总是有一组想要同时打开/关闭的文件,另外还要做一些事情,例如打开 Magit-status 窗口、dired 缓冲区等。我已经开始使用自己的项目模式,称为元项目。 它还处于早期阶段,但功能足够,我现在正在工作中的项目组中使用它。

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

git 中有什么相当稳定,尽管记录很少。 我很快就会在这里再次开始工作。 我目前已经掌握了小型插件架构的基础知识,因此您可以注册可以在项目打开时完成的自定义操作。

I'm actually working on a solution to this very problem. I always had a group of files I wanted to open/close at the same time, plus do things like open a magit-status window, a dired buffer, etc. I've started on my own project mode called metaproject. It's in the very early stages, but is functional enough that I'm using it for project groups at work now.

Check it out here: http://nafai77.github.com/metaproject/

What's in git is pretty stable, though sparsely documented. I'm going to start working on it again here soon. I currently have the basics of a small plug-in architecture, so you can register custom actions that can be done on project open.

瞳孔里扚悲伤 2024-08-01 10:23:24

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

这只是一点点设置,但您永远不需要像以前使用 Eclipse 时经常出现的情况那样重建 .metadata 目录。 设置完成后,您只需放置适当的 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")
    )
  ) 

I use the following "solution" for myself: A project root is defined by a directory that contains a Makefile. I've bound F12 to the mode specific elisp function that "compiles" the project by makeing the first target of the corresponding Makefile. This is found by recursively going upwards from the directory of the current file.

It is a little bit of setup, but you will never have to reconstruct your .metadata directory as was frequently the case with Eclipse before. And once set up, you just have to place the proper Makefiles around and you have your projects.

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

This is then used e.g. by the LaTeX and Python mode as follows:

(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")
    )
  ) 
夜司空 2024-08-01 10:23:24

eproject,但它的记录似乎非常稀疏。

There's eproject, but it seems to be very sparsely documented.

浪菊怪哟 2024-08-01 10:23:24

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

You can roll your own in bash/cmd.exe. The windows emacs distribution comes with a .bat file called runemacs.bat which accepts files to open as arguments. Write a small script and it should be able to open everything up from one icon.

昔梦 2024-08-01 10:23:24

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

See http://www.emacswiki.org/emacs/CategoryProgrammerUtils#ProjectSupport. There are several packages which manage "projects". I favor mk-project, but then again, I wrote it. ;-)

梦罢 2024-08-01 10:23:24

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

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

You can use Desktop bookmarks, Dired bookmarks, or Bookmark-List bookmarks to do what you want -- see Bookmark+. You can even encapsulate code and multiple bookmarks in a single bookmark to get just the state and setup you want.

See also: Icicles support for projects for more options.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文