Jef*_*mes 11 emacs elisp cedet
我想make-shells在emacs中有一个命令,它将打开一些emacs-shell缓冲区,每个缓冲区都有自己的工作目录.我的想法是,对于我正在处理的每个项目,我都有一个从该项目目录开始的shell,因此我可以轻松地在它们之间切换.
目前我有这个代码:
(defun shell-dir (name dir)
(interactive "sShell name: \nDDirectory: ")
(shell name)
(switch-to-buffer name)
(comint-send-string (current-buffer) (concat "cd " dir "\r"))
(sleep-for 0 10)
(dirs))
(defun make-shells ()
(interactive)
(shell-dir "project1" "~/proj/project1")
(shell-dir "project2" "~/proj/project2")
(shell-dir "project3" "~/proj/project3")
(delete-window))
Run Code Online (Sandbox Code Playgroud)
但这很丑陋,有一半的时间(dirs)没有找到正确的路径,因此标签完成会中断,直到我手动重新运行它.是否有内置方法来设置emacs shell的当前工作目录?或者像CEDET这样的东西(再加上对shell和emacs模式的依赖程度更低)是一个更好的解决方案吗?
Tre*_*son 10
我在Emacs提供的当前目录跟踪方面遇到了类似的问题,所以我写了一个解决问题的问题.
检查它在这里.
它的简短版本是你修改shell提示符以包含当前目录的完整路径(仅当在Emacs中运行时),并且Emacs shell缓冲区将使用它.
这意味着你永远不必再做M-x dirs了.
还有包装dirtrack(Emacs附带)也可以做同样的事情.
我更喜欢我的版本,因为它从提示中删除了路径.我不希望在我的提示中看到整个路径,因为我当前的目录通常很长.
使用上述两种解决方案之一后,您可以简化shell-dir日常工作:
(defun shell-dir (name dir)
(interactive "sShell name: \nDDirectory: ")
(let ((default-directory dir))
(shell name)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3198 次 |
| 最近记录: |