【问题标题】:Tab completion for custom path自定义路径的制表符完成
【发布时间】: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


    【解决方案1】:

    看看shell-command

    (require 'shell-command)
    (shell-command-completion-mode)
    

    【讨论】:

      【解决方案2】:

      在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 的注意事项”开头。

      【讨论】:

      • 我都试过了,但都不起作用。这些是否适用于选项卡完成,而不仅仅是命令执行?
      • @sawa,我只是看看这个方法是如何实现的,很惊讶它没有使用这两个变量中的任何一个......我猜Powershell.el 可能是一个更好的选择(见我的编辑)。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2017-01-01
      相关资源
      最近更新 更多