emacs-diffs
[Top][All Lists]
Advanced

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

master b573aaab76b 2/2: ; Make utility functions for getting the Eshell


From: Jim Porter
Subject: master b573aaab76b 2/2: ; Make utility functions for getting the Eshell non-special regexps
Date: Sun, 20 Oct 2024 23:15:57 -0400 (EDT)

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

    ; Make utility functions for getting the Eshell non-special regexps
    
    * lisp/eshell/esh-arg.el (eshell-inside-quote-regexp)
    (eshell-outside-quote-regexp): Rename to...
    (eshell--non-special-inside-quote-regexp)
    (eshell--non-special-outside-quote-regexp): ... these, and add
    defsubsts.
    (eshell-arg-initialize): Don't initialize regexp variables.
    (eshell-parse-non-special): ... use them.
    
    * lisp/eshell/em-glob.el (eshell-glob-chars-regexp): Use 'rx-to-string'.
---
 lisp/eshell/em-glob.el |  4 ++--
 lisp/eshell/esh-arg.el | 31 ++++++++++++++++---------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el
index 36e4f90aed2..b95204c7e1e 100644
--- a/lisp/eshell/em-glob.el
+++ b/lisp/eshell/em-glob.el
@@ -182,7 +182,6 @@ interpretation."
                  (buffer-substring-no-properties (1- (point)) (1+ end))
                (goto-char (1+ end))))))))))
 
-(defvar eshell-glob-chars-regexp nil)
 (defvar eshell-glob-matches)
 (defvar message-shown)
 
@@ -190,11 +189,12 @@ interpretation."
   '(("**/" . recurse)
     ("***/" . recurse-symlink)))
 
+(defvar eshell-glob-chars-regexp nil)
 (defsubst eshell-glob-chars-regexp ()
   "Return the lazily-created value for `eshell-glob-chars-regexp'."
   (or eshell-glob-chars-regexp
       (setq-local eshell-glob-chars-regexp
-                 (format "[%s]+" (apply 'string eshell-glob-chars-list)))))
+                  (rx-to-string `(+ (any ,@eshell-glob-chars-list)) t))))
 
 (defun eshell-glob-regexp (pattern)
   "Convert glob-pattern PATTERN to a regular expression.
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el
index 8785f5216fd..4ea25f7f202 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -53,8 +53,6 @@ yield the values intended."
 (defvar eshell-current-quoted nil)
 (defvar eshell-current-argument-plain nil
   "If non-nil, the current argument is \"plain\", and not part of a command.")
-(defvar eshell-inside-quote-regexp nil)
-(defvar eshell-outside-quote-regexp nil)
 
 ;;; User Variables:
 
@@ -177,13 +175,24 @@ Eshell will expand special refs like \"#<ARG...>\" into
 (defun eshell-arg-initialize ()     ;Called from `eshell-mode' via intern-soft!
   "Initialize the argument parsing code."
   (eshell-arg-mode)
-  (setq-local eshell-inside-quote-regexp nil)
-  (setq-local eshell-outside-quote-regexp nil)
-
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
               #'eshell-complete-special-reference nil t)))
 
+(defvar eshell--non-special-inside-quote-regexp nil)
+(defsubst eshell--non-special-inside-quote-regexp ()
+  (or eshell--non-special-inside-quote-regexp
+      (setq-local eshell--non-special-inside-quote-regexp
+                  (rx-to-string
+                   `(+ (not (any ,@eshell-special-chars-inside-quoting))) t))))
+
+(defvar eshell--non-special-outside-quote-regexp nil)
+(defsubst eshell--non-special-outside-quote-regexp ()
+  (or eshell--non-special-outside-quote-regexp
+      (setq-local eshell--non-special-outside-quote-regexp
+                  (rx-to-string
+                   `(+ (not (any ,@eshell-special-chars-outside-quoting))) 
t))))
+
 (defsubst eshell-escape-arg (string)
   "Return STRING with the `escaped' property on it."
   (if (stringp string)
@@ -422,17 +431,9 @@ their numeric values."
 
 (defun eshell-parse-non-special ()
   "Parse any non-special characters, depending on the current context."
-  (unless eshell-inside-quote-regexp
-    (setq eshell-inside-quote-regexp
-          (format "[^%s]+"
-                  (apply 'string eshell-special-chars-inside-quoting))))
-  (unless eshell-outside-quote-regexp
-    (setq eshell-outside-quote-regexp
-          (format "[^%s]+"
-                  (apply 'string eshell-special-chars-outside-quoting))))
   (when (looking-at (if eshell-current-quoted
-                        eshell-inside-quote-regexp
-                      eshell-outside-quote-regexp))
+                        (eshell--non-special-inside-quote-regexp)
+                      (eshell--non-special-outside-quote-regexp)))
     (goto-char (match-end 0))
     (let ((str (match-string 0)))
       (when str



reply via email to

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