【发布时间】:2011-09-23 11:25:17
【问题描述】:
Emacs shell 模式选项卡完成 (comint-dynamic-complete) 适用于 linux 内置的命令,但它似乎没有检测到我在~/.bashrc 中指定路径的原始命令。我怎样才能让comint-dynamic-complete 寻找这样的命令?我使用 emacs 23.3。
【问题讨论】:
标签: shell emacs path elisp tab-completion
Emacs shell 模式选项卡完成 (comint-dynamic-complete) 适用于 linux 内置的命令,但它似乎没有检测到我在~/.bashrc 中指定路径的原始命令。我怎样才能让comint-dynamic-complete 寻找这样的命令?我使用 emacs 23.3。
【问题讨论】:
标签: shell emacs path elisp tab-completion
(require 'shell-command)
(shell-command-completion-mode)
【讨论】:
在shell模式下,查找exec-path中指定的目录,该目录是在Emacs启动时根据环境变量PATH初始化的。您可以覆盖.emacs (ref) 中的一个或两个。 This page 向您展示了如何覆盖这两个变量中的任何一个:
(setenv "PATH" (concat (getenv "PATH") ":/sw/bin"))
(setq exec-path (append exec-path '("/sw/bin")))
编辑:
Powershell.el 可能是comint.el 的更好替代品(以前没有使用过)。在源代码 cmets 中,它声称在 exec-path 中搜索其中一个函数,恕我直言,应该在 comint.el 中完成:
;; (defun powershell-dynamic-complete-command ()
;; "Dynamically complete the command at point.
;; This function is similar to `comint-dynamic-complete-filename', except that it
;; searches the commands from powershell and then the `exec-path' (minus the
;; trailing Emacs library path) for completion
;; candidates.
阅读source code comments,以“完成TAB 的注意事项”开头。
【讨论】:
Powershell.el 可能是一个更好的选择(见我的编辑)。