]> git.eshelyaron.com Git - emacs.git/commitdiff
; Throw strings as the values for 'eshell-incomplete'
authorJim Porter <jporterbugs@gmail.com>
Thu, 2 Feb 2023 01:48:37 +0000 (17:48 -0800)
committerJim Porter <jporterbugs@gmail.com>
Thu, 23 Feb 2023 22:09:36 +0000 (14:09 -0800)
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.

lisp/eshell/em-cmpl.el
lisp/eshell/em-glob.el
lisp/eshell/em-pred.el
lisp/eshell/esh-arg.el
lisp/eshell/esh-cmd.el
lisp/eshell/esh-mode.el
lisp/eshell/esh-var.el

index af8ac4278f1abfbb0a99dbfff43f394f9b9577d4..5625c53dc9bacc6262ec0b85cc06f4a928cfc043 100644 (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))))
index c7360fb246ee5c70320bf337aa1c303fa3eb5c72..8a2ba13b2adb6597e57bcbfd4b569e88d82d1b26 100644 (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))
index 14fa27aba063b39f03c6638e249e481c2288facc..2ccca092b866d271ab32243d4b85f0d06ef03cf9 100644 (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)
index 6c882471aee7e01ed4e57af033659205c7bee823..cb0b2e0938c339627c06248736d75c9682d2adbe 100644 (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)
index efc46f10c96e3be98bae11292b07bc8c060b8a07..d609711402a0ad848296874fdba70419bf3a4d0f 100644 (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)))
index b3cde47271395986ecdc0a43cfdc9dd3b16df93b..0c381dbb86a8eca059c50c6628ac5d40a77352fc 100644 (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)))
index 60aab92b33eca0670e5a9ce4d959691e291b4ce0..a5bfbf4254d9f150d22a642b052e91090258f4b8 100644 (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))