Function: eshell-complete-parse-arguments
eshell-complete-parse-arguments is a byte-compiled function defined in
em-cmpl.el.gz.
Signature
(eshell-complete-parse-arguments)
Documentation
Parse the command line arguments for pcomplete-argument.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-cmpl.el.gz
(defun eshell-complete-parse-arguments ()
"Parse the command line arguments for `pcomplete-argument'."
(when (and eshell-no-completion-during-jobs
(eshell-interactive-process))
(insert-and-inherit "\t")
(throw 'pcompleted t))
(let ((end (point-marker))
(begin (save-excursion (eshell-bol) (point)))
(posns (list t))
args delim)
(when (memq this-command '(pcomplete-expand
pcomplete-expand-and-complete))
(run-hook-with-args 'eshell-expand-input-functions begin end)
(if (= begin end)
(end-of-line))
(setq end (point-marker)))
(if (setq delim
(catch 'eshell-incomplete
(ignore
(setq args (eshell-parse-arguments begin end)))))
(cond ((memq (car delim) '(?\{ ?\<))
(setq begin (1+ (cadr delim))
args (eshell-parse-arguments begin end)))
((eq (car delim) ?\()
(eshell-complete-lisp-symbol)
(throw 'pcompleted t))
(t
(insert-and-inherit "\t")
(throw 'pcompleted t))))
(when (get-text-property (1- end) 'comment)
(insert-and-inherit "\t")
(throw 'pcompleted t))
(let ((pos begin))
(while (< pos end)
(if (get-text-property pos 'arg-begin)
(nconc posns (list pos)))
(setq pos (1+ pos))))
(setq posns (cdr posns))
(cl-assert (= (length args) (length posns)))
(let ((a args)
(i 0)
l)
(while a
(if (and (consp (car a))
(eq (caar a) 'eshell-operator))
(setq l i))
(setq a (cdr a) i (1+ i)))
(and l
(setq args (nthcdr (1+ l) args)
posns (nthcdr (1+ l) posns))))
(cl-assert (= (length args) (length posns)))
(when (and args (eq (char-syntax (char-before end)) ? )
(not (eq (char-before (1- end)) ?\\)))
(nconc args (list ""))
(nconc posns (list (point))))
(cons (mapcar
(lambda (arg)
(let ((val
(if (listp arg)
(let ((result
(eshell-do-eval
(list 'eshell-commands arg) t)))
(cl-assert (eq (car result) 'quote))
(cadr result))
arg)))
(cond ((numberp val)
(setq val (number-to-string val)))
;; expand .../ etc that only eshell understands to
;; standard ../../
((and (stringp val)) (string-match "\\.\\.\\.+/" val)
(setq val (eshell-expand-multiple-dots val))))
(or val "")))
args)
posns)))