-;;; pcomplete --- programmable completion
+;;; pcomplete.el --- programmable completion
-;; Copyright (C) 1999, 2000, 2001 Free Sofware Foundation
+;; Copyright (C) 1999, 2000, 2001, 2002 Free Sofware Foundation
;; Author: John Wiegley <johnw@gnu.org>
;; Keywords: processes abbrev
:type 'boolean
:group 'pcomplete)
+(defcustom pcomplete-termination-string " "
+ "*A string that is inserted after any completion or expansion.
+This is usually a space character, useful when completing lists of
+words separated by spaces. However, if your list uses a different
+separator character, or if the completion occurs in a word that is
+already terminated by a character, this variable should be locally
+modified to be an empty string, or the desired separation string."
+ :type 'string
+ :group 'pcomplete)
+
;;; Internal Variables:
;; for cycling completion support
(unless (pcomplete-insert-entry
"" (car pcomplete-current-completions) t
pcomplete-last-completion-raw)
- (insert-and-inherit " "))
+ (insert-and-inherit pcomplete-termination-string))
(setq pcomplete-current-completions
(cdr pcomplete-current-completions))))))
(symbol-value completef-sym))))
(if elem
(setcar elem 'pcomplete)
- (nconc (symbol-value completef-sym)
- (list 'pcomplete)))))
+ (add-to-list completef-sym 'pcomplete))))
;;;###autoload
(defun pcomplete-shell-setup ()
(defun pcomplete-entries (&optional regexp predicate)
"Complete against a list of directory candidates.
-This function always uses the last argument as the basis for
-completion.
If REGEXP is non-nil, it is a regular expression used to refine the
match (files not matching the REGEXP will be excluded).
If PREDICATE is non-nil, it will also be used to refine the match
\(files for which the PREDICATE returns nil will be excluded).
-If PATH is non-nil, it will be used for completion instead of
-consulting the last argument."
- (let* ((name pcomplete-stub)
+If no directory information can be extracted from the completed
+component, DEFAULT-DIRECTORY is used as the basis for completion."
+ (let* ((name (substitute-env-vars pcomplete-stub))
(default-directory (expand-file-name
(or (file-name-directory name)
default-directory)))
(string-match pcomplete-dir-ignore file))
(and pcomplete-file-ignore
(string-match pcomplete-file-ignore file))))))))
- (setq above-cutoff (> (length completions)
- pcomplete-cycle-cutoff-length))
+ (setq above-cutoff (and pcomplete-cycle-cutoff-length
+ (> (length completions)
+ pcomplete-cycle-cutoff-length)))
(sort completions
(function
(lambda (l r)
(let (space-added)
(when (and (not (memq (char-before) pcomplete-suffix-list))
addsuffix)
- (insert-and-inherit " ")
+ (insert-and-inherit pcomplete-termination-string)
(setq space-added t))
(setq pcomplete-last-completion-length (- (point) here)
pcomplete-last-completion-stub stub)