aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/pcomplete.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/pcomplete.el')
-rw-r--r--lisp/pcomplete.el45
1 files changed, 18 insertions, 27 deletions
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 213b68a4000..1260867f7c6 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -1,6 +1,6 @@
1;;; pcomplete.el --- programmable completion 1;;; pcomplete.el --- programmable completion
2 2
3;; Copyright (C) 1999, 2000, 2001, 2002 Free Sofware Foundation 3;; Copyright (C) 1999, 2000,01,02,03,04 Free Sofware Foundation
4 4
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6;; Keywords: processes abbrev 6;; Keywords: processes abbrev
@@ -505,7 +505,7 @@ See the documentation for `pcomplete-arg'."
505 505
506(defsubst pcomplete-actual-arg (&optional index offset) 506(defsubst pcomplete-actual-arg (&optional index offset)
507 "Return the actual text representation of the last argument. 507 "Return the actual text representation of the last argument.
508This different from `pcomplete-arg', which returns the textual value 508This is different from `pcomplete-arg', which returns the textual value
509that the last argument evaluated to. This function returns what the 509that the last argument evaluated to. This function returns what the
510user actually typed in." 510user actually typed in."
511 (buffer-substring (pcomplete-begin index offset) (point))) 511 (buffer-substring (pcomplete-begin index offset) (point)))
@@ -531,7 +531,7 @@ user actually typed in."
531 (throw 'pcompleted nil)))) 531 (throw 'pcompleted nil))))
532 532
533(defun pcomplete-match-string (which &optional index offset) 533(defun pcomplete-match-string (which &optional index offset)
534 "Like `string-match', but on the current completion argument." 534 "Like `match-string', but on the current completion argument."
535 (let ((arg (pcomplete-arg (or index 1) offset))) 535 (let ((arg (pcomplete-arg (or index 1) offset)))
536 (if arg 536 (if arg
537 (match-string which arg) 537 (match-string which arg)
@@ -583,8 +583,8 @@ user actually typed in."
583(defun pcomplete-comint-setup (completef-sym) 583(defun pcomplete-comint-setup (completef-sym)
584 "Setup a comint buffer to use pcomplete. 584 "Setup a comint buffer to use pcomplete.
585COMPLETEF-SYM should be the symbol where the 585COMPLETEF-SYM should be the symbol where the
586dynamic-complete-functions are kept. For comint mode itself, this is 586dynamic-complete-functions are kept. For comint mode itself,
587`comint-dynamic-complete-functions'." 587this is `comint-dynamic-complete-functions'."
588 (set (make-local-variable 'pcomplete-parse-arguments-function) 588 (set (make-local-variable 'pcomplete-parse-arguments-function)
589 'pcomplete-parse-comint-arguments) 589 'pcomplete-parse-comint-arguments)
590 (make-local-variable completef-sym) 590 (make-local-variable completef-sym)
@@ -709,7 +709,7 @@ match (files not matching the REGEXP will be excluded).
709If PREDICATE is non-nil, it will also be used to refine the match 709If PREDICATE is non-nil, it will also be used to refine the match
710\(files for which the PREDICATE returns nil will be excluded). 710\(files for which the PREDICATE returns nil will be excluded).
711If no directory information can be extracted from the completed 711If no directory information can be extracted from the completed
712component, DEFAULT-DIRECTORY is used as the basis for completion." 712component, `default-directory' is used as the basis for completion."
713 (let* ((name (substitute-env-vars pcomplete-stub)) 713 (let* ((name (substitute-env-vars pcomplete-stub))
714 (default-directory (expand-file-name 714 (default-directory (expand-file-name
715 (or (file-name-directory name) 715 (or (file-name-directory name)
@@ -809,11 +809,10 @@ component, DEFAULT-DIRECTORY is used as the basis for completion."
809(defun pcomplete-opt (options &optional prefix no-ganging args-follow) 809(defun pcomplete-opt (options &optional prefix no-ganging args-follow)
810 "Complete a set of OPTIONS, each beginning with PREFIX (?- by default). 810 "Complete a set of OPTIONS, each beginning with PREFIX (?- by default).
811PREFIX may be t, in which case no PREFIX character is necessary. 811PREFIX may be t, in which case no PREFIX character is necessary.
812If REQUIRED is non-nil, the options must be present. 812If NO-GANGING is non-nil, each option is separate (-xy is not allowed).
813If NO-GANGING is non-nil, each option is separate. -xy is not allowed. 813If ARGS-FOLLOW is non-nil, then options which take arguments may have
814If ARGS-FOLLOW is non-nil, then options which arguments which take may 814the argument appear after a ganged set of options. This is how tar
815have the argument appear after a ganged set of options. This is how 815behaves, for example."
816tar behaves, for example."
817 (if (and (= pcomplete-index pcomplete-last) 816 (if (and (= pcomplete-index pcomplete-last)
818 (string= (pcomplete-arg) "-")) 817 (string= (pcomplete-arg) "-"))
819 (let ((len (length options)) 818 (let ((len (length options))
@@ -864,7 +863,7 @@ tar behaves, for example."
864 (setq index (1+ index)))))))) 863 (setq index (1+ index))))))))
865 864
866(defun pcomplete--here (&optional form stub paring form-only) 865(defun pcomplete--here (&optional form stub paring form-only)
867 "Complete aganst the current argument, if at the end. 866 "Complete against the current argument, if at the end.
868See the documentation for `pcomplete-here'." 867See the documentation for `pcomplete-here'."
869 (if (< pcomplete-index pcomplete-last) 868 (if (< pcomplete-index pcomplete-last)
870 (progn 869 (progn
@@ -893,7 +892,7 @@ See the documentation for `pcomplete-here'."
893 (throw 'pcomplete-completions (eval form)))) 892 (throw 'pcomplete-completions (eval form))))
894 893
895(defmacro pcomplete-here (&optional form stub paring form-only) 894(defmacro pcomplete-here (&optional form stub paring form-only)
896 "Complete aganst the current argument, if at the end. 895 "Complete against the current argument, if at the end.
897If completion is to be done here, evaluate FORM to generate the list 896If completion is to be done here, evaluate FORM to generate the list
898of strings which will be used for completion purposes. If STUB is a 897of strings which will be used for completion purposes. If STUB is a
899string, use it as the completion stub instead of the default (which is 898string, use it as the completion stub instead of the default (which is
@@ -913,10 +912,11 @@ always for the sake of efficiency.
913 912
914If PARING is nil, this argument will be pared against previous 913If PARING is nil, this argument will be pared against previous
915arguments using the function `file-truename' to normalize them. 914arguments using the function `file-truename' to normalize them.
916PARING may be a function, in which case that function is for 915PARING may be a function, in which case that function is used for
917normalization. If PARING is the value t, the argument dealt with by 916normalization. If PARING is t, the argument dealt with by this
918this call will not participate in argument paring. If it the integer 917call will not participate in argument paring. If it is the
9190, all previous arguments that have been seen will be cleared. 918integer 0, all previous arguments that have been seen will be
919cleared.
920 920
921If FORM-ONLY is non-nil, only the result of FORM will be used to 921If FORM-ONLY is non-nil, only the result of FORM will be used to
922generate the completions list. This means that the hook 922generate the completions list. This means that the hook
@@ -1129,10 +1129,7 @@ See also `pcomplete-filename'."
1129 1129
1130(defun pcomplete--help () 1130(defun pcomplete--help ()
1131 "Produce context-sensitive help for the current argument. 1131 "Produce context-sensitive help for the current argument.
1132If specific documentation can't be given, be generic. 1132If specific documentation can't be given, be generic."
1133INFODOC specifies the Info node to goto. DOCUMENTATION is a sexp
1134which will produce documentation for the argument (it is responsible
1135for displaying in its own buffer)."
1136 (if (and pcomplete-help 1133 (if (and pcomplete-help
1137 (or (and (stringp pcomplete-help) 1134 (or (and (stringp pcomplete-help)
1138 (fboundp 'Info-goto-node)) 1135 (fboundp 'Info-goto-node))
@@ -1150,12 +1147,6 @@ for displaying in its own buffer)."
1150 1147
1151;; general utilities 1148;; general utilities
1152 1149
1153(defsubst pcomplete-time-less-p (t1 t2)
1154 "Say whether time T1 is less than time T2."
1155 (or (< (car t1) (car t2))
1156 (and (= (car t1) (car t2))
1157 (< (nth 1 t1) (nth 1 t2)))))
1158
1159(defun pcomplete-pare-list (l r &optional pred) 1150(defun pcomplete-pare-list (l r &optional pred)
1160 "Destructively remove from list L all elements matching any in list R. 1151 "Destructively remove from list L all elements matching any in list R.
1161Test is done using `equal'. 1152Test is done using `equal'.