diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2008-04-03 05:13:15 +0000 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2008-04-03 05:13:15 +0000 |
commit | a086d081fae2a95d0c321b21cb4a1f05f634701b (patch) | |
tree | 73134b05206cdd1cb19631258fbdf55f1e1f5f12 /lisp/shell.el | |
parent | 71082167594512e0f1500e6ebbe8f2544e57ac5a (diff) | |
download | emacs-a086d081fae2a95d0c321b21cb4a1f05f634701b.tar.gz |
(shell-dynamic-complete-filename): New fun.
(shell-dynamic-complete-functions): Use it.
Diffstat (limited to 'lisp/shell.el')
-rw-r--r-- | lisp/shell.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index 7d20a877811..67050c97a88 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -186,7 +186,7 @@ This is a fine thing to set in your `.emacs' file.") shell-dynamic-complete-environment-variable shell-dynamic-complete-command shell-replace-by-expanded-directory - comint-dynamic-complete-filename) + shell-dynamic-complete-filename) "List of functions called to perform completion. This variable is used to initialize `comint-dynamic-complete-functions' in the shell buffer. @@ -1010,6 +1010,19 @@ See `shell-dynamic-complete-filename'. Returns t if successful." (insert " ")) success))) +(defun shell-dynamic-complete-filename () + "Dynamically complete the filename at point. +This completes only if point is at a suitable position for a +filename argument." + (interactive) + (let ((opoint (point)) + (beg (comint-line-beginning-position))) + (when (save-excursion + (goto-char (if (re-search-backward "[;|&]" beg t) + (match-end 0) + beg)) + (re-search-forward "[^ \t][ \t]" opoint t)) + (comint-dynamic-complete-as-filename)))) (defun shell-match-partial-variable () "Return the shell variable at point, or nil if none is found." @@ -1023,7 +1036,6 @@ See `shell-dynamic-complete-filename'. Returns t if successful." (re-search-forward "\\$?{?[A-Za-z0-9_]*}?" limit) (buffer-substring (match-beginning 0) (match-end 0)))))) - (defun shell-dynamic-complete-environment-variable () "Dynamically complete the environment variable at point. Completes if after a variable, i.e., if it starts with a \"$\". |