diff options
| author | Jim Porter | 2023-08-22 13:13:45 -0700 |
|---|---|---|
| committer | Jim Porter | 2023-10-24 11:36:27 -0700 |
| commit | 1c2cb9cd6192e97a29fbe338fd1a639f6dfae2d2 (patch) | |
| tree | 8ffa80dc0de1013094e9e33e052693b7a19d83a7 /test | |
| parent | f7d88f4a0478d89f70243456af8c4d4817d6b251 (diff) | |
| download | emacs-1c2cb9cd6192e97a29fbe338fd1a639f6dfae2d2.tar.gz emacs-1c2cb9cd6192e97a29fbe338fd1a639f6dfae2d2.zip | |
Support arbitrary Eshell arguments inside special references
* lisp/eshell/esh-arg.el (eshell-current-argument-plain): New variable.
(eshell-parse-special-reference): Use 'eshell-parse-arguments'.
(eshell-get-buffer): New function.
(eshell-insert-buffer-name): Properly quote the buffer name.
* lisp/eshell/esh-proc.el (eshell-read-process-name): Move to "Special
references" section.
(eshell-insert-process): Properly quote the process name.
* lisp/eshell/em-extpipe.el (eshell-parse-external-pipeline):
* lisp/eshell/esh-io.el (eshell-parse-redirection): Don't do anything
when 'eshell-argument-plain' is non-nil.
* test/lisp/eshell/esh-arg-tests.el
(esh-arg-test/special-reference/quoted)
(esh-arg-test/special-reference/var-expansion): New tests.
(esh-arg-test/special-reference/special): Rename to...
(esh-arg-test/special-reference/special-characters): ... this.
* test/lisp/eshell/em-extpipe-tests.el (em-extpipe-tests--deftest):
Properly quote the buffer name.
(em-extpipe-test-4, em-extpipe-test-7): Use 'eshell-get-buffer'.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/em-extpipe-tests.el | 8 | ||||
| -rw-r--r-- | test/lisp/eshell/esh-arg-tests.el | 25 |
2 files changed, 29 insertions, 4 deletions
diff --git a/test/lisp/eshell/em-extpipe-tests.el b/test/lisp/eshell/em-extpipe-tests.el index bdffcd9b320..6984ec2de59 100644 --- a/test/lisp/eshell/em-extpipe-tests.el +++ b/test/lisp/eshell/em-extpipe-tests.el | |||
| @@ -55,7 +55,9 @@ | |||
| 55 | "temp\\([^>]\\|\\'\\)" temp | 55 | "temp\\([^>]\\|\\'\\)" temp |
| 56 | (string-replace | 56 | (string-replace |
| 57 | "#<buffer temp>" | 57 | "#<buffer temp>" |
| 58 | (concat "#<buffer " (buffer-name temp-buffer) ">") | 58 | (format "#<buffer %s>" |
| 59 | (eshell-quote-argument | ||
| 60 | (buffer-name temp-buffer))) | ||
| 59 | input)))) | 61 | input)))) |
| 60 | ,@body) | 62 | ,@body) |
| 61 | (when (buffer-name temp-buffer) | 63 | (when (buffer-name temp-buffer) |
| @@ -110,7 +112,7 @@ | |||
| 110 | '(progn | 112 | '(progn |
| 111 | (ignore | 113 | (ignore |
| 112 | (eshell-set-output-handle 1 'overwrite | 114 | (eshell-set-output-handle 1 'overwrite |
| 113 | (get-buffer-create "temp"))) | 115 | (eshell-get-buffer "temp"))) |
| 114 | (eshell-named-command "sh" | 116 | (eshell-named-command "sh" |
| 115 | (list "-c" "echo \"bar\" | rev")))) | 117 | (list "-c" "echo \"bar\" | rev")))) |
| 116 | (with-substitute-for-temp | 118 | (with-substitute-for-temp |
| @@ -133,7 +135,7 @@ | |||
| 133 | '(progn | 135 | '(progn |
| 134 | (ignore | 136 | (ignore |
| 135 | (eshell-set-output-handle 1 'overwrite | 137 | (eshell-set-output-handle 1 'overwrite |
| 136 | (get-buffer-create "quux"))) | 138 | (eshell-get-buffer "quux"))) |
| 137 | (ignore | 139 | (ignore |
| 138 | (eshell-set-output-handle 1 'append | 140 | (eshell-set-output-handle 1 'append |
| 139 | (get-process "other"))) | 141 | (get-process "other"))) |
diff --git a/test/lisp/eshell/esh-arg-tests.el b/test/lisp/eshell/esh-arg-tests.el index c883db3907f..0e07d107562 100644 --- a/test/lisp/eshell/esh-arg-tests.el +++ b/test/lisp/eshell/esh-arg-tests.el | |||
| @@ -118,7 +118,30 @@ treated literally, as a backslash and a newline." | |||
| 118 | (format "echo #<buffer %s>" (buffer-name)) | 118 | (format "echo #<buffer %s>" (buffer-name)) |
| 119 | (current-buffer)))) | 119 | (current-buffer)))) |
| 120 | 120 | ||
| 121 | (ert-deftest esh-arg-test/special-reference/special () | 121 | (ert-deftest esh-arg-test/special-reference/quoted () |
| 122 | "Test that '#<buffer \"foo bar\">' refers to the buffer \"foo bar\"." | ||
| 123 | (with-temp-buffer | ||
| 124 | (rename-buffer "foo bar" t) | ||
| 125 | (eshell-command-result-equal | ||
| 126 | (format "echo #<buffer \"%s\">" (buffer-name)) | ||
| 127 | (current-buffer)) | ||
| 128 | (eshell-command-result-equal | ||
| 129 | (format "echo #<buffer '%s'>" (buffer-name)) | ||
| 130 | (current-buffer)))) | ||
| 131 | |||
| 132 | (ert-deftest esh-arg-test/special-reference/var-expansion () | ||
| 133 | "Test that variable expansion inside special references works." | ||
| 134 | (with-temp-buffer | ||
| 135 | (rename-buffer "my-buffer" t) | ||
| 136 | (let ((eshell-test-value (buffer-name))) | ||
| 137 | (eshell-command-result-equal | ||
| 138 | "echo #<buffer $eshell-test-value>" | ||
| 139 | (current-buffer)) | ||
| 140 | (eshell-command-result-equal | ||
| 141 | "echo #<buffer \"$eshell-test-value\">" | ||
| 142 | (current-buffer))))) | ||
| 143 | |||
| 144 | (ert-deftest esh-arg-test/special-reference/special-characters () | ||
| 122 | "Test that \"#<...>\" works correctly when escaping special characters." | 145 | "Test that \"#<...>\" works correctly when escaping special characters." |
| 123 | (with-temp-buffer | 146 | (with-temp-buffer |
| 124 | (rename-buffer "<my buffer>" t) | 147 | (rename-buffer "<my buffer>" t) |