diff options
Diffstat (limited to 'lisp/eshell/esh-var.el')
-rw-r--r-- | lisp/eshell/esh-var.el | 128 |
1 files changed, 63 insertions, 65 deletions
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 188b8165248..75c36a68544 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -395,12 +395,9 @@ process any indices that come after the variable reference." indices (and (not (eobp)) (eq (char-after) ?\[) (eshell-parse-indices)) - value (list 'let - (list (list 'indices - (list 'quote indices))) - value)) + value `(let ((indices ',indices)) ,value)) (if get-len - (list 'length value) + `(length ,value) value))) (defun eshell-parse-variable-ref () @@ -414,67 +411,68 @@ Possible options are: <LONG-NAME> disambiguates the length of the name {COMMAND} result of command is variable's value (LISP-FORM) result of Lisp form is variable's value" - (let (end) - (cond - ((eq (char-after) ?{) - (let ((end (eshell-find-delimiter ?\{ ?\}))) - (if (not end) - (throw 'eshell-incomplete ?\{) - (prog1 - (list 'eshell-convert - (list 'eshell-command-to-value - (list 'eshell-as-subcommand - (eshell-parse-command - (cons (1+ (point)) end))))) - (goto-char (1+ end)))))) - ((memq (char-after) '(?\' ?\")) - (let ((name (if (eq (char-after) ?\') - (eshell-parse-literal-quote) - (eshell-parse-double-quote)))) - (if name + (cond + ((eq (char-after) ?{) + (let ((end (eshell-find-delimiter ?\{ ?\}))) + (if (not end) + (throw 'eshell-incomplete ?\{) + (prog1 + (list 'eshell-convert + (list 'eshell-command-to-value + (list 'eshell-as-subcommand + (eshell-parse-command + (cons (1+ (point)) end))))) + (goto-char (1+ end)))))) + ((memq (char-after) '(?\' ?\")) + (let ((name (if (eq (char-after) ?\') + (eshell-parse-literal-quote) + (eshell-parse-double-quote)))) + (if name (list 'eshell-get-variable (eval name) 'indices)))) - ((eq (char-after) ?\<) - (let ((end (eshell-find-delimiter ?\< ?\>))) - (if (not end) - (throw 'eshell-incomplete ?\<) - (let* ((temp (make-temp-file temporary-file-directory)) - (cmd (concat (buffer-substring (1+ (point)) end) - " > " temp))) - (prog1 - (list - 'let (list (list 'eshell-current-handles - (list 'eshell-create-handles temp - (list 'quote 'overwrite)))) - (list - 'progn - (list 'eshell-as-subcommand - (eshell-parse-command cmd)) - (list 'ignore - (list 'nconc 'eshell-this-command-hook - (list 'list - (list 'function - (list 'lambda nil - (list 'delete-file temp)))))) - (list 'quote temp))) - (goto-char (1+ end))))))) - ((eq (char-after) ?\() - (condition-case err - (list 'eshell-command-to-value - (list 'eshell-lisp-command - (list 'quote (read (current-buffer))))) - (end-of-file - (throw 'eshell-incomplete ?\()))) - ((assoc (char-to-string (char-after)) - eshell-variable-aliases-list) - (forward-char) - (list 'eshell-get-variable - (char-to-string (char-before)) 'indices)) - ((looking-at eshell-variable-name-regexp) - (prog1 - (list 'eshell-get-variable (match-string 0) 'indices) - (goto-char (match-end 0)))) - (t - (error "Invalid variable reference"))))) + ((eq (char-after) ?\<) + (let ((end (eshell-find-delimiter ?\< ?\>))) + (if (not end) + (throw 'eshell-incomplete ?\<) + (let* ((temp (make-temp-file temporary-file-directory)) + (cmd (concat (buffer-substring (1+ (point)) end) + " > " temp))) + (prog1 + (list + 'let (list (list 'eshell-current-handles + (list 'eshell-create-handles temp + (list 'quote 'overwrite)))) + (list + 'progn + (list 'eshell-as-subcommand + (eshell-parse-command cmd)) + (list 'ignore + (list 'nconc 'eshell-this-command-hook + (list 'list + (list 'function + (list 'lambda nil + (list 'delete-file temp)))))) + (list 'quote temp))) + (goto-char (1+ end))))))) + ((eq (char-after) ?\() + (condition-case nil + (list 'eshell-command-to-value + (list 'eshell-lisp-command + (list 'quote (read (current-buffer))))) + (end-of-file + (throw 'eshell-incomplete ?\()))) + ((assoc (char-to-string (char-after)) + eshell-variable-aliases-list) + (forward-char) + (list 'eshell-get-variable + (char-to-string (char-before)) 'indices)) + ((looking-at eshell-variable-name-regexp) + (prog1 + (list 'eshell-get-variable (match-string 0) 'indices) + (goto-char (match-end 0)))) + (t + (error "Invalid variable reference")))) + +(defvar eshell-glob-function) (defun eshell-parse-indices () "Parse and return a list of list of indices." |