Function: pcomplete-opt
pcomplete-opt is a byte-compiled function defined in pcomplete.el.gz.
Signature
(pcomplete-opt OPTIONS &optional PREFIX NO-GANGING ARGS-FOLLOW)
Documentation
Complete a set of OPTIONS, each beginning with PREFIX (?- by default).
PREFIX may be t, in which case no PREFIX character is necessary. If NO-GANGING is non-nil, each option is separate (-xy is not allowed). If ARGS-FOLLOW is non-nil, then options which take arguments may have the argument appear after a ganged set of options. This is how tar behaves, for example. Arguments NO-GANGING and ARGS-FOLLOW are currently ignored.
Source Code
;; Defined in /usr/src/emacs/lisp/pcomplete.el.gz
(defun pcomplete-opt (options &optional prefix _no-ganging _args-follow)
"Complete a set of OPTIONS, each beginning with PREFIX (?- by default).
PREFIX may be t, in which case no PREFIX character is necessary.
If NO-GANGING is non-nil, each option is separate (-xy is not allowed).
If ARGS-FOLLOW is non-nil, then options which take arguments may have
the argument appear after a ganged set of options. This is how tar
behaves, for example.
Arguments NO-GANGING and ARGS-FOLLOW are currently ignored."
(if (and (= pcomplete-index pcomplete-last)
(string= (pcomplete-arg) "-"))
(let ((len (length options))
(index 0)
char choices)
(while (< index len)
(setq char (aref options index))
(if (eq char ?\()
(let ((result (read-from-string options index)))
(setq index (cdr result)))
(unless (memq char '(?/ ?* ?? ?.))
(push (char-to-string char) choices))
(setq index (1+ index))))
(throw 'pcomplete-completions
(mapcar
(lambda (opt)
(concat "-" opt))
(pcomplete-uniquify-list choices))))
(let ((arg (pcomplete-arg)))
(when (and (> (length arg) 1)
(stringp arg)
(eq (aref arg 0) (or prefix ?-)))
(pcomplete-next-arg)
(let ((char (aref arg 1))
(len (length options))
(index 0)
opt-char arg-char result)
(while (< (1+ index) len)
(setq opt-char (aref options index)
arg-char (aref options (1+ index)))
(if (eq arg-char ?\()
(setq result
(read-from-string options (1+ index))
index (cdr result)
result (car result))
(setq result nil))
(when (and (eq char opt-char)
(memq arg-char '(?\( ?/ ?* ?? ?.)))
(if (< pcomplete-index pcomplete-last)
(pcomplete-next-arg)
(throw 'pcomplete-completions
(cond ((eq arg-char ?/) (pcomplete-dirs))
((eq arg-char ?*) (pcomplete-executables))
((eq arg-char ??) nil)
((eq arg-char ?.) (pcomplete-entries))
((eq arg-char ?\() (eval result t))))))
(setq index (1+ index))))))))