1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

; 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'.
This commit is contained in:
Jim Porter 2024-10-20 16:58:44 -07:00
parent 212cf31256
commit b573aaab76
2 changed files with 18 additions and 17 deletions

View File

@ -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.

View File

@ -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