emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2f110132d73 1/3: ; Throw strings as the values for 'eshell-incomp


From: Jim Porter
Subject: master 2f110132d73 1/3: ; Throw strings as the values for 'eshell-incomplete'
Date: Thu, 23 Feb 2023 17:11:39 -0500 (EST)

branch: master
commit 2f110132d735b3a3db0c4ee29f2a7d49ff2525be
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

    ; 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.
---
 lisp/eshell/em-cmpl.el  |  4 ++--
 lisp/eshell/em-glob.el  |  2 +-
 lisp/eshell/em-pred.el  |  2 +-
 lisp/eshell/esh-arg.el  |  8 ++++----
 lisp/eshell/esh-cmd.el  |  4 ++--
 lisp/eshell/esh-mode.el |  2 +-
 lisp/eshell/esh-var.el  | 18 +++++++++++-------
 7 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index af8ac4278f1..5625c53dc9b 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -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))))
diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el
index c7360fb246e..8a2ba13b2ad 100644
--- a/lisp/eshell/em-glob.el
+++ b/lisp/eshell/em-glob.el
@@ -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))
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el
index 14fa27aba06..2ccca092b86 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -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)
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el
index 6c882471aee..cb0b2e0938c 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -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)
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index efc46f10c96..d609711402a 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -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)))
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index b3cde472713..0c381dbb86a 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -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)))
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 60aab92b33e..a5bfbf4254d 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]