diff options
| author | Chong Yidong | 2008-04-03 05:13:15 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-04-03 05:13:15 +0000 |
| commit | a086d081fae2a95d0c321b21cb4a1f05f634701b (patch) | |
| tree | 73134b05206cdd1cb19631258fbdf55f1e1f5f12 | |
| parent | 71082167594512e0f1500e6ebbe8f2544e57ac5a (diff) | |
| download | emacs-a086d081fae2a95d0c321b21cb4a1f05f634701b.tar.gz emacs-a086d081fae2a95d0c321b21cb4a1f05f634701b.zip | |
(shell-dynamic-complete-filename): New fun.
(shell-dynamic-complete-functions): Use it.
| -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.") | |||
| 186 | shell-dynamic-complete-environment-variable | 186 | shell-dynamic-complete-environment-variable |
| 187 | shell-dynamic-complete-command | 187 | shell-dynamic-complete-command |
| 188 | shell-replace-by-expanded-directory | 188 | shell-replace-by-expanded-directory |
| 189 | comint-dynamic-complete-filename) | 189 | shell-dynamic-complete-filename) |
| 190 | "List of functions called to perform completion. | 190 | "List of functions called to perform completion. |
| 191 | This variable is used to initialize `comint-dynamic-complete-functions' in the | 191 | This variable is used to initialize `comint-dynamic-complete-functions' in the |
| 192 | shell buffer. | 192 | shell buffer. |
| @@ -1010,6 +1010,19 @@ See `shell-dynamic-complete-filename'. Returns t if successful." | |||
| 1010 | (insert " ")) | 1010 | (insert " ")) |
| 1011 | success))) | 1011 | success))) |
| 1012 | 1012 | ||
| 1013 | (defun shell-dynamic-complete-filename () | ||
| 1014 | "Dynamically complete the filename at point. | ||
| 1015 | This completes only if point is at a suitable position for a | ||
| 1016 | filename argument." | ||
| 1017 | (interactive) | ||
| 1018 | (let ((opoint (point)) | ||
| 1019 | (beg (comint-line-beginning-position))) | ||
| 1020 | (when (save-excursion | ||
| 1021 | (goto-char (if (re-search-backward "[;|&]" beg t) | ||
| 1022 | (match-end 0) | ||
| 1023 | beg)) | ||
| 1024 | (re-search-forward "[^ \t][ \t]" opoint t)) | ||
| 1025 | (comint-dynamic-complete-as-filename)))) | ||
| 1013 | 1026 | ||
| 1014 | (defun shell-match-partial-variable () | 1027 | (defun shell-match-partial-variable () |
| 1015 | "Return the shell variable at point, or nil if none is found." | 1028 | "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." | |||
| 1023 | (re-search-forward "\\$?{?[A-Za-z0-9_]*}?" limit) | 1036 | (re-search-forward "\\$?{?[A-Za-z0-9_]*}?" limit) |
| 1024 | (buffer-substring (match-beginning 0) (match-end 0)))))) | 1037 | (buffer-substring (match-beginning 0) (match-end 0)))))) |
| 1025 | 1038 | ||
| 1026 | |||
| 1027 | (defun shell-dynamic-complete-environment-variable () | 1039 | (defun shell-dynamic-complete-environment-variable () |
| 1028 | "Dynamically complete the environment variable at point. | 1040 | "Dynamically complete the environment variable at point. |
| 1029 | Completes if after a variable, i.e., if it starts with a \"$\". | 1041 | Completes if after a variable, i.e., if it starts with a \"$\". |