summaryrefslogtreecommitdiff
path: root/lisp/comint.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2011-10-02 00:08:50 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2011-10-02 00:08:50 -0400
commit32c1fffd728cfed8427d144bf7c622257aad859f (patch)
treed732c10ec70d78c49fdebc23b32c2ccf0a35ce66 /lisp/comint.el
parentb0e2675c7f28f729354abc1d471af9934899852d (diff)
downloademacs-32c1fffd728cfed8427d144bf7c622257aad859f.tar.gz
* lisp/pcomplete.el: Require comint.
(pcomplete--common-suffix): Remove. (pcomplete--common-quoted-suffix): Use comint--common-suffix instead. (pcomplete--table-subvert): Sync with comint--table-subvert. (pcomplete--entries): Use comint-completion-file-name-table. * lisp/comint.el (comint-unquote-filename): Simplify. (comint-completion-file-name-table): New function. (comint--complete-file-name-data): Use it. * src/dired.c (file_name_completion): Don't expand file name. (Ffile_name_completion, Ffile_name_all_completions): Expand file name before checking file name handler. Fixes: debbugs:9616
Diffstat (limited to 'lisp/comint.el')
-rw-r--r--lisp/comint.el27
1 files changed, 21 insertions, 6 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index 2349fc0edd9..59feab82e44 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -3005,11 +3005,7 @@ Magic characters are those in `comint-file-name-quote-list'."
(if (null comint-file-name-quote-list)
filename
(save-match-data
- (let ((i 0))
- (while (string-match "\\\\\\(.\\)" filename i)
- (setq filename (replace-match "\\1" nil nil filename))
- (setq i (+ 1 (match-beginning 0)))))
- filename)))
+ (replace-regexp-in-string "\\\\\\(.\\)" "\\1" filename t))))
(defun comint-completion-at-point ()
(run-hook-with-args-until-success 'comint-dynamic-complete-functions))
@@ -3057,6 +3053,7 @@ Returns t if successful."
(- (match-end 1) (match-beginning 1))))
(defun comint--common-quoted-suffix (s1 s2)
+ ;; FIXME: Copied in pcomplete.el.
"Find the common suffix between S1 and S2 where S1 is the expanded S2.
S1 is expected to be the unquoted and expanded version of S1.
Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
@@ -3117,6 +3114,24 @@ in the same way as TABLE completes strings of the form (concat S2 S)."
;; E.g. action=nil and it's the only completion.
(res)))))
+(defun comint-completion-file-name-table (string pred action)
+ (if (not (file-name-absolute-p string))
+ (completion-file-name-table string pred action)
+ (cond
+ ((memq action '(t lambda))
+ (completion-file-name-table
+ (concat comint-file-name-prefix string) pred action))
+ ((null action)
+ (let ((res (completion-file-name-table
+ (concat comint-file-name-prefix string) pred action)))
+ (if (and (stringp res)
+ (string-match
+ (concat "\\`" (regexp-quote comint-file-name-prefix))
+ res))
+ (substring res (match-end 0))
+ res)))
+ (t (completion-file-name-table string pred action)))))
+
(defun comint--complete-file-name-data ()
"Return the completion data for file name at point."
(let* ((filesuffix (cond ((not comint-completion-addsuffix) "")
@@ -3133,7 +3148,7 @@ in the same way as TABLE completes strings of the form (concat S2 S)."
unquoted filename)))
(apply-partially
#'comint--table-subvert
- #'completion-file-name-table
+ #'comint-completion-file-name-table
(cdr prefixes) (car prefixes)))))
(nconc
(list