]> git.eshelyaron.com Git - emacs.git/commitdiff
(shell-dynamic-complete-filename): New fun.
authorChong Yidong <cyd@stupidchicken.com>
Thu, 3 Apr 2008 05:15:02 +0000 (05:15 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Thu, 3 Apr 2008 05:15:02 +0000 (05:15 +0000)
(shell-dynamic-complete-functions): Use it.

lisp/shell.el

index 45ef23e98c393bf32f47c4a9c1dc75521d84557c..0ee30ae7e5b5b794a17a6a14d38b6aafbc5739a9 100644 (file)
@@ -191,7 +191,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.
@@ -1003,6 +1003,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."