Tab completion for custom path
Emacs shell mode tab completion (comint-dynamic-complete
) is working 开发者_Python百科for commands that are built-in to linux, but it does not seem to detect my original commands whose path is specified in ~/.bashrc
. How can I make comint-dynamic-complete
look for such commands? I use emacs 23.3.
In the shell mode, it looks for directories specified in exec-path
, which is initialized based on the environment variable PATH
when Emacs is started. You can overwrite either or both of those in your .emacs
(ref). This page shows you how to override either of those two variables:
(setenv "PATH" (concat (getenv "PATH") ":/sw/bin"))
(setq exec-path (append exec-path '("/sw/bin")))
EDIT:
Powershell.el
might be a better alternative (haven't used it before) to comint.el
. In the source code comments, it claims to search the exec-path
for one of the functions, which IMHO should have been done in 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.
Have a read in the source code comments starting with "Notes on TAB for completion."
Have a look at shell-command
(require 'shell-command)
(shell-command-completion-mode)
精彩评论