1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

; Throw strings as the values for 'eshell-incomplete'

This lets us distinguish between cases like "'foo" and "$'foo".

* lisp/eshell/em-cmpl.el (eshell-complete-parse-arguments): Use
strings when checking the delimiter.

* lisp/eshell/em-glob.el (eshell-parse-glob-chars):
* lisp/eshell/em-pred.el (eshell-parse-arg-modifier):
* lisp/eshell/esh-arg.el (eshell-parse-backslash)
(eshell-parse-literal-quote, eshell-parse-double-quote)
(eshell-parse-special-reference):
* lisp/eshell/esh-cmd.el (eshell-parse-subcommand-argument)
(eshell-parse-lisp-argument):
* lisp/eshell/esh-var (eshell-parse-variable-ref)
(eshell-parse-indices): Throw strings instead of characters.

* lisp/eshell/esh-mode.el (eshell-parse-command-input): Print
delimiter as a string.
This commit is contained in:
Jim Porter 2023-02-01 17:48:37 -08:00
parent 6411a9af03
commit 2f110132d7
7 changed files with 22 additions and 18 deletions

View file

@ -330,10 +330,10 @@ to writing a completion function."
(catch 'eshell-incomplete
(ignore
(setq args (eshell-parse-arguments begin end)))))
(cond ((memq (car delim) '(?\{ ?\<))
(cond ((member (car delim) '("{" "${" "$<"))
(setq begin (1+ (cadr delim))
args (eshell-parse-arguments begin end)))
((eq (car delim) ?\()
((member (car delim) '("(" "$("))
(throw 'pcompleted (elisp-completion-at-point)))
(t
(eshell--pcomplete-insert-tab))))

View file

@ -171,7 +171,7 @@ interpretation."
(end (eshell-find-delimiter
delim (if (eq delim ?\[) ?\] ?\)))))
(if (not end)
(throw 'eshell-incomplete delim)
(throw 'eshell-incomplete (char-to-string delim))
(if (and (eshell-using-module 'eshell-pred)
(eshell-arg-delimiter (1+ end)))
(ignore (goto-char here))

View file

@ -293,7 +293,7 @@ This function is specially for adding onto `eshell-parse-argument-hook'."
(forward-char)
(let ((end (eshell-find-delimiter ?\( ?\))))
(if (not end)
(throw 'eshell-incomplete ?\()
(throw 'eshell-incomplete "(")
(when (eshell-arg-delimiter (1+ end))
(save-restriction
(narrow-to-region (point) end)

View file

@ -421,7 +421,7 @@ backslash is in a quoted string, the backslash and the character
after are both returned."
(when (eq (char-after) ?\\)
(when (eshell-looking-at-backslash-return (point))
(throw 'eshell-incomplete ?\\))
(throw 'eshell-incomplete "\\"))
(forward-char 2) ; Move one char past the backslash.
(let ((special-chars (if eshell-current-quoted
eshell-special-chars-inside-quoting
@ -447,7 +447,7 @@ after are both returned."
(if (eq (char-after) ?\')
(let ((end (eshell-find-delimiter ?\' ?\')))
(if (not end)
(throw 'eshell-incomplete ?\')
(throw 'eshell-incomplete "'")
(let ((string (buffer-substring-no-properties (1+ (point)) end)))
(goto-char (1+ end))
(while (string-match "''" string)
@ -460,7 +460,7 @@ after are both returned."
(let* ((end (eshell-find-delimiter ?\" ?\" nil nil t))
(eshell-current-quoted t))
(if (not end)
(throw 'eshell-incomplete ?\")
(throw 'eshell-incomplete "\"")
(prog1
(save-restriction
(forward-char)
@ -514,7 +514,7 @@ If the form has no `type', the syntax is parsed as if `type' were
t)) ;; buffer-p is non-nil by default.
(end (eshell-find-delimiter ?\< ?\>)))
(when (not end)
(throw 'eshell-incomplete ?\<))
(throw 'eshell-incomplete "#<"))
(if (eshell-arg-delimiter (1+ end))
(prog1
(list (if buffer-p 'get-buffer-create 'get-process)

View file

@ -681,7 +681,7 @@ This means an exit code of 0."
(not (eq (char-after (1+ (point))) ?\}))))
(let ((end (eshell-find-delimiter ?\{ ?\})))
(if (not end)
(throw 'eshell-incomplete ?\{)
(throw 'eshell-incomplete "{")
(when (eshell-arg-delimiter (1+ end))
(prog1
`(eshell-as-subcommand
@ -698,7 +698,7 @@ This means an exit code of 0."
(condition-case nil
(read (current-buffer))
(end-of-file
(throw 'eshell-incomplete ?\()))))
(throw 'eshell-incomplete "(")))))
(if (eshell-arg-delimiter)
`(eshell-command-to-value
(eshell-lisp-command (quote ,obj)))

View file

@ -580,7 +580,7 @@ will return the parsed command."
(setq command (eshell-parse-command (cons beg end)
args t)))))
(ignore
(message "Expecting completion of delimiter %c ..."
(message "Expecting completion of delimiter %s ..."
(if (listp delim)
(car delim)
delim)))

View file

@ -503,7 +503,7 @@ Possible variable references are:
((eq (char-after) ?{)
(let ((end (eshell-find-delimiter ?\{ ?\})))
(if (not end)
(throw 'eshell-incomplete ?\{)
(throw 'eshell-incomplete "${")
(forward-char)
(prog1
`(eshell-apply-indices
@ -527,7 +527,7 @@ Possible variable references are:
((eq (char-after) ?\<)
(let ((end (eshell-find-delimiter ?\< ?\>)))
(if (not end)
(throw 'eshell-incomplete ?\<)
(throw 'eshell-incomplete "$<")
(let* ((temp (make-temp-file temporary-file-directory))
(cmd (concat (buffer-substring (1+ (point)) end)
" > " temp)))
@ -560,15 +560,19 @@ Possible variable references are:
(current-buffer)))))
indices ,eshell-current-quoted)
(end-of-file
(throw 'eshell-incomplete ?\())))
(throw 'eshell-incomplete "$("))))
((looking-at (rx-to-string
`(or "'" ,(if eshell-current-quoted "\\\"" "\""))))
(eshell-with-temp-command
(or (eshell-unescape-inner-double-quote (point-max))
(cons (point) (point-max)))
(let ((name (if (eq (char-after) ?\')
(eshell-parse-literal-quote)
(eshell-parse-double-quote))))
(let (name)
(when-let ((delim
(catch 'eshell-incomplete
(ignore (setq name (if (eq (char-after) ?\')
(eshell-parse-literal-quote)
(eshell-parse-double-quote)))))))
(throw 'eshell-incomplete (concat "$" delim)))
(when name
`(eshell-get-variable ,(eval name) indices ,eshell-current-quoted)))))
((assoc (char-to-string (char-after))
@ -597,7 +601,7 @@ For example, \"[0 1][2]\" becomes:
(while (eq (char-after) ?\[)
(let ((end (eshell-find-delimiter ?\[ ?\])))
(if (not end)
(throw 'eshell-incomplete ?\[)
(throw 'eshell-incomplete "[")
(forward-char)
(eshell-with-temp-command (or (eshell-unescape-inner-double-quote end)
(cons (point) end))