aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-01-21 20:04:52 +0800
committerPo Lu2023-01-21 20:04:52 +0800
commit5f6971e5cbd168db8a2d1e17bc92f2deadcaeceb (patch)
treee11b451877c9938b6e83b24cff4fac00a41cc50a
parentaaacf24ca25fc284038ec9f17be358067309a8cf (diff)
parentf4a3e8f29f05f19263d3f600823cdbc0b1cfd3ef (diff)
downloademacs-5f6971e5cbd168db8a2d1e17bc92f2deadcaeceb.tar.gz
emacs-5f6971e5cbd168db8a2d1e17bc92f2deadcaeceb.zip
Merge remote-tracking branch 'origin/master' into feature/android
-rw-r--r--etc/NEWS14
-rw-r--r--lisp/files.el21
-rw-r--r--lisp/progmodes/c-ts-mode.el2
-rw-r--r--lisp/textmodes/html-ts-mode.el137
-rw-r--r--test/lisp/eshell/esh-var-tests.el142
5 files changed, 233 insertions, 83 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 678a5a70ca7..cfb1f82706f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -59,18 +59,23 @@ trash when deleting. Default is nil.
59 59
60* Editing Changes in Emacs 30.1 60* Editing Changes in Emacs 30.1
61 61
62+++
62** Emacs now has better support for touchscreen events. 63** Emacs now has better support for touchscreen events.
63Many touch screen gestures are now implemented, as is support for 64Many touch screen gestures are now implemented, as is support for
64tapping buttons and opening menus. 65tapping buttons and opening menus.
65 66
67
68---
66** New command 'kill-matching-buffers-no-ask'. 69** New command 'kill-matching-buffers-no-ask'.
67Kills buffers whose name matches a regexp without asking for 70This works like 'kill-matching-buffers', but without asking for
68confirmation. 71confirmation.
69 72
73+++
70** New helper variable 'transpose-sexps-function'. 74** New helper variable 'transpose-sexps-function'.
71Emacs now can set this variable to customize the behavior of the 75Emacs now can set this variable to customize the behavior of the
72'transpose-sexps' function. 76'transpose-sexps' function.
73 77
78+++
74** New function 'transpose-sexps-default-function'. 79** New function 'transpose-sexps-default-function'.
75The previous implementation is moved into its own function, to be 80The previous implementation is moved into its own function, to be
76bound by 'transpose-sexps-function'. 81bound by 'transpose-sexps-function'.
@@ -191,6 +196,13 @@ activate this behavior.
191 196
192* New Modes and Packages in Emacs 30.1 197* New Modes and Packages in Emacs 30.1
193 198
199** New major modes based on the tree-sitter library.
200
201+++
202*** New major mode 'html-ts-mode'.
203An optional major mode based on the tree-sitter library for editing
204HTML files.
205
194--- 206---
195** The highly accessible Modus themes collection has six items. 207** The highly accessible Modus themes collection has six items.
196The 'modus-operandi' and 'modus-vivendi' are the main themes that have 208The 'modus-operandi' and 'modus-vivendi' are the main themes that have
diff --git a/lisp/files.el b/lisp/files.el
index d308e99804d..9da82446112 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7100,10 +7100,11 @@ specifies the list of buffers to kill, asking for approval for each one."
7100 (setq list (cdr list)))) 7100 (setq list (cdr list))))
7101 7101
7102(defun kill-matching-buffers (regexp &optional internal-too no-ask) 7102(defun kill-matching-buffers (regexp &optional internal-too no-ask)
7103 "Kill buffers whose name matches the specified REGEXP. 7103 "Kill buffers whose names match the regular expression REGEXP.
7104Ignores buffers whose name starts with a space, unless optional 7104Interactively, prompt for REGEXP.
7105prefix argument INTERNAL-TOO is non-nil. Asks before killing 7105Ignores buffers whose names start with a space, unless optional
7106each buffer, unless NO-ASK is non-nil." 7106prefix argument INTERNAL-TOO(interactively, the prefix argument)
7107is non-nil. Asks before killing each buffer, unless NO-ASK is non-nil."
7107 (interactive "sKill buffers matching this regular expression: \nP") 7108 (interactive "sKill buffers matching this regular expression: \nP")
7108 (dolist (buffer (buffer-list)) 7109 (dolist (buffer (buffer-list))
7109 (let ((name (buffer-name buffer))) 7110 (let ((name (buffer-name buffer)))
@@ -7113,11 +7114,13 @@ each buffer, unless NO-ASK is non-nil."
7113 (funcall (if no-ask 'kill-buffer 'kill-buffer-ask) buffer))))) 7114 (funcall (if no-ask 'kill-buffer 'kill-buffer-ask) buffer)))))
7114 7115
7115(defun kill-matching-buffers-no-ask (regexp &optional internal-too) 7116(defun kill-matching-buffers-no-ask (regexp &optional internal-too)
7116 "Kill buffers whose name matches the specified REGEXP. 7117 "Kill buffers whose names match the regular expression REGEXP.
7117Ignores buffers whose name starts with a space, unless optional 7118Interactively, prompt for REGEXP.
7118prefix argument INTERNAL-TOO is non-nil. Equivalent to 7119Like `kill-matching-buffers', but doesn't ask for confirmation
7119`kill-matching-buffers' but never ask before killing each 7120before killing each buffer.
7120buffer." 7121Ignores buffers whose names start with a space, unless the
7122optional argument INTERNAL-TOO (interactively, the prefix argument)
7123is non-nil."
7121 (interactive "sKill buffers matching this regular expression: \nP") 7124 (interactive "sKill buffers matching this regular expression: \nP")
7122 (kill-matching-buffers regexp internal-too t)) 7125 (kill-matching-buffers regexp internal-too t))
7123 7126
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index b3d162cd3ab..348d027af19 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -228,7 +228,7 @@ NODE should be a labeled_statement."
228(defvar c-ts-mode-indent-block-type-regexp 228(defvar c-ts-mode-indent-block-type-regexp
229 (rx (or "compound_statement" 229 (rx (or "compound_statement"
230 "field_declaration_list" 230 "field_declaration_list"
231 "enumeratior_list")) 231 "enumerator_list"))
232 "Regexp matching types of block nodes (i.e., {} blocks).") 232 "Regexp matching types of block nodes (i.e., {} blocks).")
233 233
234(defun c-ts-mode--statement-offset (node parent &rest _) 234(defun c-ts-mode--statement-offset (node parent &rest _)
diff --git a/lisp/textmodes/html-ts-mode.el b/lisp/textmodes/html-ts-mode.el
new file mode 100644
index 00000000000..7e4360747a3
--- /dev/null
+++ b/lisp/textmodes/html-ts-mode.el
@@ -0,0 +1,137 @@
1;;; html-ts-mode.el --- tree-sitter support for HTML -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2023 Free Software Foundation, Inc.
4
5;; Author : Theodor Thornhill <theo@thornhill.no>
6;; Maintainer : Theodor Thornhill <theo@thornhill.no>
7;; Created : January 2023
8;; Keywords : html languages tree-sitter
9
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software: you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
24
25;;; Commentary:
26;;
27
28;;; Code:
29
30(require 'treesit)
31(require 'sgml-mode)
32
33(declare-function treesit-parser-create "treesit.c")
34(declare-function treesit-node-type "treesit.c")
35
36(defcustom html-ts-mode-indent-offset 2
37 "Number of spaces for each indentation step in `html-ts-mode'."
38 :version "29.1"
39 :type 'integer
40 :safe 'integerp
41 :group 'html)
42
43(defvar html-ts-mode--indent-rules
44 `((html
45 ((parent-is "fragment") point-min 0)
46 ((node-is "/>") parent-bol 0)
47 ((node-is ">") parent-bol 0)
48 ((node-is "end_tag") parent-bol 0)
49 ((parent-is "comment") prev-adaptive-prefix 0)
50 ((parent-is "element") parent-bol html-ts-mode-indent-offset)
51 ((parent-is "script_element") parent-bol html-ts-mode-indent-offset)
52 ((parent-is "style_element") parent-bol html-ts-mode-indent-offset)
53 ((parent-is "start_tag") parent-bol html-ts-mode-indent-offset)
54 ((parent-is "self_closing_tag") parent-bol html-ts-mode-indent-offset)))
55 "Tree-sitter indent rules.")
56
57(defvar html-ts-mode--font-lock-settings
58 (treesit-font-lock-rules
59 :language 'html
60 :override t
61 :feature 'comment
62 `((comment) @font-lock-comment-face)
63 :language 'html
64 :override t
65 :feature 'keyword
66 `("doctype" @font-lock-keyword-face)
67 :language 'html
68 :override t
69 :feature 'definition
70 `((tag_name) @font-lock-function-name-face)
71 :language 'html
72 :override t
73 :feature 'string
74 `((quoted_attribute_value) @font-lock-string-face)
75 :language 'html
76 :override t
77 :feature 'property
78 `((attribute_name) @font-lock-variable-name-face))
79 "Tree-sitter font-lock settings for `html-ts-mode'.")
80
81(defun html-ts-mode--defun-name (node)
82 "Return the defun name of NODE.
83Return nil if there is no name or if NODE is not a defun node."
84 (when (equal (treesit-node-type node) "tag_name")
85 (treesit-node-text node t)))
86
87;;;###autoload
88(define-derived-mode html-ts-mode html-mode "HTML"
89 "Major mode for editing Html, powered by tree-sitter."
90 :group 'html
91
92 (unless (treesit-ready-p 'html)
93 (error "Tree-sitter for HTML isn't available"))
94
95 (treesit-parser-create 'html)
96
97 ;; Comments.
98 (setq-local treesit-text-type-regexp
99 (regexp-opt '("comment" "text")))
100
101 ;; Indent.
102 (setq-local treesit-simple-indent-rules html-ts-mode--indent-rules)
103
104 ;; Navigation.
105 (setq-local treesit-defun-type-regexp "element")
106
107 (setq-local treesit-defun-name-function #'html-ts-mode--defun-name)
108
109 (setq-local treesit-sentence-type-regexp
110 (regexp-opt '("start_tag"
111 "self_closing_tag"
112 "end_tag")))
113
114 (setq-local treesit-sexp-type-regexp
115 (regexp-opt '("tag"
116 "text"
117 "attribute"
118 "value")))
119
120 ;; Font-lock.
121 (setq-local treesit-font-lock-settings html-ts-mode--font-lock-settings)
122 (setq-local treesit-font-lock-feature-list
123 '((comment keyword definition)
124 (property string)
125 () ()))
126
127 ;; Imenu.
128 (setq-local treesit-simple-imenu-settings
129 '(("Element" "\\`tag_name\\'" nil nil)))
130 (treesit-major-mode-setup))
131
132(if (treesit-ready-p 'html)
133 (add-to-list 'auto-mode-alist '("\\.html\\'" . html-ts-mode)))
134
135(provide 'html-ts-mode)
136
137;;; html-ts-mode.el ends here
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
index 82324d72163..12412d13640 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -83,7 +83,7 @@
83 '("zero" "two" "four")))) 83 '("zero" "two" "four"))))
84 84
85(ert-deftest esh-var-test/interp-var-indices-subcommand () 85(ert-deftest esh-var-test/interp-var-indices-subcommand ()
86 "Interpolate list variable with subcommand expansion for indices" 86 "Interpolate list variable with subcommand expansion for indices."
87 (skip-unless (executable-find "echo")) 87 (skip-unless (executable-find "echo"))
88 (let ((eshell-test-value '("zero" "one" "two" "three" "four"))) 88 (let ((eshell-test-value '("zero" "one" "two" "three" "four")))
89 (eshell-command-result-equal 89 (eshell-command-result-equal
@@ -94,7 +94,7 @@
94 '("zero" "two")))) 94 '("zero" "two"))))
95 95
96(ert-deftest esh-var-test/interp-var-split-indices () 96(ert-deftest esh-var-test/interp-var-split-indices ()
97 "Interpolate string variable with indices" 97 "Interpolate string variable with indices."
98 (let ((eshell-test-value "zero one two three four")) 98 (let ((eshell-test-value "zero one two three four"))
99 (eshell-command-result-equal "echo $eshell-test-value[0]" 99 (eshell-command-result-equal "echo $eshell-test-value[0]"
100 "zero") 100 "zero")
@@ -104,7 +104,7 @@
104 '("zero" "two" "four")))) 104 '("zero" "two" "four"))))
105 105
106(ert-deftest esh-var-test/interp-var-string-split-indices () 106(ert-deftest esh-var-test/interp-var-string-split-indices ()
107 "Interpolate string variable with string splitter and indices" 107 "Interpolate string variable with string splitter and indices."
108 (let ((eshell-test-value "zero:one:two:three:four")) 108 (let ((eshell-test-value "zero:one:two:three:four"))
109 (eshell-command-result-equal "echo $eshell-test-value[: 0]" 109 (eshell-command-result-equal "echo $eshell-test-value[: 0]"
110 "zero") 110 "zero")
@@ -117,7 +117,7 @@
117 '("zero" "two")))) 117 '("zero" "two"))))
118 118
119(ert-deftest esh-var-test/interp-var-regexp-split-indices () 119(ert-deftest esh-var-test/interp-var-regexp-split-indices ()
120 "Interpolate string variable with regexp splitter and indices" 120 "Interpolate string variable with regexp splitter and indices."
121 (let ((eshell-test-value "zero:one!two:three!four")) 121 (let ((eshell-test-value "zero:one!two:three!four"))
122 (eshell-command-result-equal "echo $eshell-test-value['[:!]' 0]" 122 (eshell-command-result-equal "echo $eshell-test-value['[:!]' 0]"
123 "zero") 123 "zero")
@@ -129,7 +129,7 @@
129 '("zero" "two")))) 129 '("zero" "two"))))
130 130
131(ert-deftest esh-var-test/interp-var-assoc () 131(ert-deftest esh-var-test/interp-var-assoc ()
132 "Interpolate alist variable with index" 132 "Interpolate alist variable with index."
133 (let ((eshell-test-value '(("foo" . 1) (bar . 2)))) 133 (let ((eshell-test-value '(("foo" . 1) (bar . 2))))
134 (eshell-command-result-equal "echo $eshell-test-value[foo]" 134 (eshell-command-result-equal "echo $eshell-test-value[foo]"
135 1) 135 1)
@@ -137,7 +137,7 @@
137 2))) 137 2)))
138 138
139(ert-deftest esh-var-test/interp-var-length-list () 139(ert-deftest esh-var-test/interp-var-length-list ()
140 "Interpolate length of list variable" 140 "Interpolate length of list variable."
141 (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9))))) 141 (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9)))))
142 (eshell-command-result-equal "echo $#eshell-test-value" 3) 142 (eshell-command-result-equal "echo $#eshell-test-value" 3)
143 (eshell-command-result-equal "echo $#eshell-test-value[1]" 1) 143 (eshell-command-result-equal "echo $#eshell-test-value[1]" 1)
@@ -149,19 +149,19 @@
149 (eshell-command-result-equal "echo $#eshell-test-value" 6))) 149 (eshell-command-result-equal "echo $#eshell-test-value" 6)))
150 150
151(ert-deftest esh-var-test/interp-var-length-alist () 151(ert-deftest esh-var-test/interp-var-length-alist ()
152 "Interpolate length of alist variable" 152 "Interpolate length of alist variable."
153 (let ((eshell-test-value '(("foo" . (1 2 3))))) 153 (let ((eshell-test-value '(("foo" . (1 2 3)))))
154 (eshell-command-result-equal "echo $#eshell-test-value" 1) 154 (eshell-command-result-equal "echo $#eshell-test-value" 1)
155 (eshell-command-result-equal "echo $#eshell-test-value[foo]" 3))) 155 (eshell-command-result-equal "echo $#eshell-test-value[foo]" 3)))
156 156
157(ert-deftest esh-var-test/interp-var-splice () 157(ert-deftest esh-var-test/interp-var-splice ()
158 "Splice-interpolate list variable" 158 "Splice-interpolate list variable."
159 (let ((eshell-test-value '(1 2 3))) 159 (let ((eshell-test-value '(1 2 3)))
160 (eshell-command-result-equal "echo a $@eshell-test-value z" 160 (eshell-command-result-equal "echo a $@eshell-test-value z"
161 '("a" 1 2 3 "z")))) 161 '("a" 1 2 3 "z"))))
162 162
163(ert-deftest esh-var-test/interp-var-splice-concat () 163(ert-deftest esh-var-test/interp-var-splice-concat ()
164 "Splice-interpolate and concat list variable" 164 "Splice-interpolate and concat list variable."
165 (let ((eshell-test-value '(1 2 3))) 165 (let ((eshell-test-value '(1 2 3)))
166 (eshell-command-result-equal "echo it is a$@'eshell-test-value'z" 166 (eshell-command-result-equal "echo it is a$@'eshell-test-value'z"
167 '("it" "is" "a1" 2 "3z")) 167 '("it" "is" "a1" 2 "3z"))
@@ -175,49 +175,49 @@
175 '("it" "is" 1 2 (31 2 3))))) 175 '("it" "is" 1 2 (31 2 3)))))
176 176
177(ert-deftest esh-var-test/interp-lisp () 177(ert-deftest esh-var-test/interp-lisp ()
178 "Interpolate Lisp form evaluation" 178 "Interpolate Lisp form evaluation."
179 (eshell-command-result-equal "+ $(+ 1 2) 3" 6)) 179 (eshell-command-result-equal "+ $(+ 1 2) 3" 6))
180 180
181(ert-deftest esh-var-test/interp-lisp-indices () 181(ert-deftest esh-var-test/interp-lisp-indices ()
182 "Interpolate Lisp form evaluation with index" 182 "Interpolate Lisp form evaluation with index."
183 (eshell-command-result-equal "+ $(list 1 2)[1] 3" 5)) 183 (eshell-command-result-equal "+ $(list 1 2)[1] 3" 5))
184 184
185(ert-deftest esh-var-test/interp-cmd () 185(ert-deftest esh-var-test/interp-cmd ()
186 "Interpolate command result" 186 "Interpolate command result."
187 (eshell-command-result-equal "+ ${+ 1 2} 3" 6)) 187 (eshell-command-result-equal "+ ${+ 1 2} 3" 6))
188 188
189(ert-deftest esh-var-test/interp-cmd-indices () 189(ert-deftest esh-var-test/interp-cmd-indices ()
190 "Interpolate command result with index" 190 "Interpolate command result with index."
191 (eshell-command-result-equal "+ ${listify 1 2}[1] 3" 5)) 191 (eshell-command-result-equal "+ ${listify 1 2}[1] 3" 5))
192 192
193(ert-deftest esh-var-test/interp-cmd-external () 193(ert-deftest esh-var-test/interp-cmd-external ()
194 "Interpolate command result from external command" 194 "Interpolate command result from external command."
195 (skip-unless (executable-find "echo")) 195 (skip-unless (executable-find "echo"))
196 (with-temp-eshell 196 (with-temp-eshell
197 (eshell-match-command-output "echo ${*echo hi}" 197 (eshell-match-command-output "echo ${*echo hi}"
198 "hi\n"))) 198 "hi\n")))
199 199
200(ert-deftest esh-var-test/interp-cmd-external-indices () 200(ert-deftest esh-var-test/interp-cmd-external-indices ()
201 "Interpolate command result from external command with index" 201 "Interpolate command result from external command with index."
202 (skip-unless (executable-find "echo")) 202 (skip-unless (executable-find "echo"))
203 (with-temp-eshell 203 (with-temp-eshell
204 (eshell-match-command-output "echo ${*echo \"hi\nbye\"}[1]" 204 (eshell-match-command-output "echo ${*echo \"hi\nbye\"}[1]"
205 "bye\n"))) 205 "bye\n")))
206 206
207(ert-deftest esh-var-test/interp-temp-cmd () 207(ert-deftest esh-var-test/interp-temp-cmd ()
208 "Interpolate command result redirected to temp file" 208 "Interpolate command result redirected to temp file."
209 (eshell-command-result-equal "cat $<echo hi>" "hi")) 209 (eshell-command-result-equal "cat $<echo hi>" "hi"))
210 210
211(ert-deftest esh-var-test/interp-concat-lisp () 211(ert-deftest esh-var-test/interp-concat-lisp ()
212 "Interpolate and concat Lisp form" 212 "Interpolate and concat Lisp form."
213 (eshell-command-result-equal "+ $(+ 1 2)3 3" 36)) 213 (eshell-command-result-equal "+ $(+ 1 2)3 3" 36))
214 214
215(ert-deftest esh-var-test/interp-concat-lisp2 () 215(ert-deftest esh-var-test/interp-concat-lisp2 ()
216 "Interpolate and concat two Lisp forms" 216 "Interpolate and concat two Lisp forms."
217 (eshell-command-result-equal "+ $(+ 1 2)$(+ 1 2) 3" 36)) 217 (eshell-command-result-equal "+ $(+ 1 2)$(+ 1 2) 3" 36))
218 218
219(ert-deftest esh-var-test/interp-concat-cmd () 219(ert-deftest esh-var-test/interp-concat-cmd ()
220 "Interpolate and concat command with literal" 220 "Interpolate and concat command with literal."
221 (eshell-command-result-equal "+ ${+ 1 2}3 3" 36) 221 (eshell-command-result-equal "+ ${+ 1 2}3 3" 36)
222 (eshell-command-result-equal "echo ${*echo \"foo\nbar\"}-baz" 222 (eshell-command-result-equal "echo ${*echo \"foo\nbar\"}-baz"
223 '("foo" "bar-baz")) 223 '("foo" "bar-baz"))
@@ -230,11 +230,11 @@
230 '("hi" "23"))) 230 '("hi" "23")))
231 231
232(ert-deftest esh-var-test/interp-concat-cmd2 () 232(ert-deftest esh-var-test/interp-concat-cmd2 ()
233 "Interpolate and concat two commands" 233 "Interpolate and concat two commands."
234 (eshell-command-result-equal "+ ${+ 1 2}${+ 1 2} 3" 36)) 234 (eshell-command-result-equal "+ ${+ 1 2}${+ 1 2} 3" 36))
235 235
236(ert-deftest esh-var-test/interp-concat-cmd-external () 236(ert-deftest esh-var-test/interp-concat-cmd-external ()
237 "Interpolate command result from external command with concatenation" 237 "Interpolate command result from external command with concatenation."
238 (skip-unless (executable-find "echo")) 238 (skip-unless (executable-find "echo"))
239 (with-temp-eshell 239 (with-temp-eshell
240 (eshell-match-command-output "echo ${echo hi}-${*echo there}" 240 (eshell-match-command-output "echo ${echo hi}-${*echo there}"
@@ -244,7 +244,7 @@
244;; Quoted variable interpolation 244;; Quoted variable interpolation
245 245
246(ert-deftest esh-var-test/quoted-interp-var () 246(ert-deftest esh-var-test/quoted-interp-var ()
247 "Interpolate variable inside double-quotes" 247 "Interpolate variable inside double-quotes."
248 (eshell-command-result-equal "echo \"$user-login-name\"" 248 (eshell-command-result-equal "echo \"$user-login-name\""
249 user-login-name)) 249 user-login-name))
250 250
@@ -256,7 +256,7 @@
256 (concat "hi, " user-login-name))) 256 (concat "hi, " user-login-name)))
257 257
258(ert-deftest esh-var-test/quoted-interp-list-var () 258(ert-deftest esh-var-test/quoted-interp-list-var ()
259 "Interpolate list variable inside double-quotes" 259 "Interpolate list variable inside double-quotes."
260 (let ((eshell-test-value '(1 2 3))) 260 (let ((eshell-test-value '(1 2 3)))
261 (eshell-command-result-equal "echo \"$eshell-test-value\"" 261 (eshell-command-result-equal "echo \"$eshell-test-value\""
262 "(1 2 3)"))) 262 "(1 2 3)")))
@@ -268,7 +268,7 @@
268 "a(1 2 3)z"))) 268 "a(1 2 3)z")))
269 269
270(ert-deftest esh-var-test/quoted-interp-var-indices () 270(ert-deftest esh-var-test/quoted-interp-var-indices ()
271 "Interpolate string variable with indices inside double-quotes" 271 "Interpolate string variable with indices inside double-quotes."
272 (let ((eshell-test-value '("zero" "one" "two" "three" "four"))) 272 (let ((eshell-test-value '("zero" "one" "two" "three" "four")))
273 (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" 273 (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
274 "zero") 274 "zero")
@@ -283,8 +283,7 @@
283 "(\"one\" \"two\" \"four\")"))) 283 "(\"one\" \"two\" \"four\")")))
284 284
285(ert-deftest esh-var-test/quote-interp-var-indices-subcommand () 285(ert-deftest esh-var-test/quote-interp-var-indices-subcommand ()
286 "Interpolate list variable with subcommand expansion for indices 286 "Interpolate list variable with subcommand expansion for indices inside double-quotes."
287inside double-quotes"
288 (skip-unless (executable-find "echo")) 287 (skip-unless (executable-find "echo"))
289 (let ((eshell-test-value '("zero" "one" "two" "three" "four"))) 288 (let ((eshell-test-value '("zero" "one" "two" "three" "four")))
290 (eshell-command-result-equal 289 (eshell-command-result-equal
@@ -297,7 +296,7 @@ inside double-quotes"
297 "(\"one\" \"two\")"))) 296 "(\"one\" \"two\")")))
298 297
299(ert-deftest esh-var-test/quoted-interp-var-split-indices () 298(ert-deftest esh-var-test/quoted-interp-var-split-indices ()
300 "Interpolate string variable with indices inside double-quotes" 299 "Interpolate string variable with indices inside double-quotes."
301 (let ((eshell-test-value "zero one two three four")) 300 (let ((eshell-test-value "zero one two three four"))
302 (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" 301 (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
303 "zero") 302 "zero")
@@ -305,8 +304,7 @@ inside double-quotes"
305 "(\"zero\" \"two\")"))) 304 "(\"zero\" \"two\")")))
306 305
307(ert-deftest esh-var-test/quoted-interp-var-string-split-indices () 306(ert-deftest esh-var-test/quoted-interp-var-string-split-indices ()
308 "Interpolate string variable with string splitter and indices 307 "Interpolate string variable with string splitter and indices inside double-quotes."
309inside double-quotes"
310 (let ((eshell-test-value "zero:one:two:three:four")) 308 (let ((eshell-test-value "zero:one:two:three:four"))
311 (eshell-command-result-equal "echo \"$eshell-test-value[: 0]\"" 309 (eshell-command-result-equal "echo \"$eshell-test-value[: 0]\""
312 "zero") 310 "zero")
@@ -319,7 +317,7 @@ inside double-quotes"
319 "(\"zero\" \"two\")"))) 317 "(\"zero\" \"two\")")))
320 318
321(ert-deftest esh-var-test/quoted-interp-var-regexp-split-indices () 319(ert-deftest esh-var-test/quoted-interp-var-regexp-split-indices ()
322 "Interpolate string variable with regexp splitter and indices" 320 "Interpolate string variable with regexp splitter and indices."
323 (let ((eshell-test-value "zero:one!two:three!four")) 321 (let ((eshell-test-value "zero:one!two:three!four"))
324 (eshell-command-result-equal "echo \"$eshell-test-value['[:!]' 0]\"" 322 (eshell-command-result-equal "echo \"$eshell-test-value['[:!]' 0]\""
325 "zero") 323 "zero")
@@ -332,7 +330,7 @@ inside double-quotes"
332 "(\"zero\" \"two\")"))) 330 "(\"zero\" \"two\")")))
333 331
334(ert-deftest esh-var-test/quoted-interp-var-assoc () 332(ert-deftest esh-var-test/quoted-interp-var-assoc ()
335 "Interpolate alist variable with index inside double-quotes" 333 "Interpolate alist variable with index inside double-quotes."
336 (let ((eshell-test-value '(("foo" . 1) (bar . 2)))) 334 (let ((eshell-test-value '(("foo" . 1) (bar . 2))))
337 (eshell-command-result-equal "echo \"$eshell-test-value[foo]\"" 335 (eshell-command-result-equal "echo \"$eshell-test-value[foo]\""
338 "1") 336 "1")
@@ -340,7 +338,7 @@ inside double-quotes"
340 "2"))) 338 "2")))
341 339
342(ert-deftest esh-var-test/quoted-interp-var-length-list () 340(ert-deftest esh-var-test/quoted-interp-var-length-list ()
343 "Interpolate length of list variable inside double-quotes" 341 "Interpolate length of list variable inside double-quotes."
344 (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9))))) 342 (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9)))))
345 (eshell-command-result-equal "echo \"$#eshell-test-value\"" 343 (eshell-command-result-equal "echo \"$#eshell-test-value\""
346 "3") 344 "3")
@@ -350,13 +348,13 @@ inside double-quotes"
350 "4"))) 348 "4")))
351 349
352(ert-deftest esh-var-test/quoted-interp-var-length-string () 350(ert-deftest esh-var-test/quoted-interp-var-length-string ()
353 "Interpolate length of string variable inside double-quotes" 351 "Interpolate length of string variable inside double-quotes."
354 (let ((eshell-test-value "foobar")) 352 (let ((eshell-test-value "foobar"))
355 (eshell-command-result-equal "echo \"$#eshell-test-value\"" 353 (eshell-command-result-equal "echo \"$#eshell-test-value\""
356 "6"))) 354 "6")))
357 355
358(ert-deftest esh-var-test/quoted-interp-var-length-alist () 356(ert-deftest esh-var-test/quoted-interp-var-length-alist ()
359 "Interpolate length of alist variable inside double-quotes" 357 "Interpolate length of alist variable inside double-quotes."
360 (let ((eshell-test-value '(("foo" . (1 2 3))))) 358 (let ((eshell-test-value '(("foo" . (1 2 3)))))
361 (eshell-command-result-equal "echo \"$#eshell-test-value\"" 359 (eshell-command-result-equal "echo \"$#eshell-test-value\""
362 "1") 360 "1")
@@ -364,7 +362,7 @@ inside double-quotes"
364 "3"))) 362 "3")))
365 363
366(ert-deftest esh-var-test/quoted-interp-var-splice () 364(ert-deftest esh-var-test/quoted-interp-var-splice ()
367 "Splice-interpolate list variable inside double-quotes" 365 "Splice-interpolate list variable inside double-quotes."
368 (let ((eshell-test-value '(1 2 3))) 366 (let ((eshell-test-value '(1 2 3)))
369 (eshell-command-result-equal "echo a \"$@eshell-test-value\" z" 367 (eshell-command-result-equal "echo a \"$@eshell-test-value\" z"
370 '("a" "1 2 3" "z")))) 368 '("a" "1 2 3" "z"))))
@@ -376,27 +374,27 @@ inside double-quotes"
376 "a1 2 3z"))) 374 "a1 2 3z")))
377 375
378(ert-deftest esh-var-test/quoted-interp-lisp () 376(ert-deftest esh-var-test/quoted-interp-lisp ()
379 "Interpolate Lisp form evaluation inside double-quotes" 377 "Interpolate Lisp form evaluation inside double-quotes."
380 (eshell-command-result-equal "echo \"hi $(concat \\\"the\\\" \\\"re\\\")\"" 378 (eshell-command-result-equal "echo \"hi $(concat \\\"the\\\" \\\"re\\\")\""
381 "hi there")) 379 "hi there"))
382 380
383(ert-deftest esh-var-test/quoted-interp-lisp-indices () 381(ert-deftest esh-var-test/quoted-interp-lisp-indices ()
384 "Interpolate Lisp form evaluation with index" 382 "Interpolate Lisp form evaluation with index."
385 (eshell-command-result-equal "concat \"$(list 1 2)[1]\" cool" 383 (eshell-command-result-equal "concat \"$(list 1 2)[1]\" cool"
386 "2cool")) 384 "2cool"))
387 385
388(ert-deftest esh-var-test/quoted-interp-cmd () 386(ert-deftest esh-var-test/quoted-interp-cmd ()
389 "Interpolate command result inside double-quotes" 387 "Interpolate command result inside double-quotes."
390 (eshell-command-result-equal "echo \"hi ${echo \\\"there\\\"}\"" 388 (eshell-command-result-equal "echo \"hi ${echo \\\"there\\\"}\""
391 "hi there")) 389 "hi there"))
392 390
393(ert-deftest esh-var-test/quoted-interp-cmd-indices () 391(ert-deftest esh-var-test/quoted-interp-cmd-indices ()
394 "Interpolate command result with index inside double-quotes" 392 "Interpolate command result with index inside double-quotes."
395 (eshell-command-result-equal "concat \"${listify 1 2}[1]\" cool" 393 (eshell-command-result-equal "concat \"${listify 1 2}[1]\" cool"
396 "2cool")) 394 "2cool"))
397 395
398(ert-deftest esh-var-test/quoted-interp-temp-cmd () 396(ert-deftest esh-var-test/quoted-interp-temp-cmd ()
399 "Interpolate command result redirected to temp file inside double-quotes" 397 "Interpolate command result redirected to temp file inside double-quotes."
400 (let ((temporary-file-directory 398 (let ((temporary-file-directory
401 (file-name-as-directory (make-temp-file "esh-vars-tests" t)))) 399 (file-name-as-directory (make-temp-file "esh-vars-tests" t))))
402 (unwind-protect 400 (unwind-protect
@@ -404,7 +402,7 @@ inside double-quotes"
404 (delete-directory temporary-file-directory t)))) 402 (delete-directory temporary-file-directory t))))
405 403
406(ert-deftest esh-var-test/quoted-interp-concat-cmd () 404(ert-deftest esh-var-test/quoted-interp-concat-cmd ()
407 "Interpolate and concat command with literal" 405 "Interpolate and concat command with literal."
408 (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"} baz\"" 406 (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"} baz\""
409 "foo\nbar baz")) 407 "foo\nbar baz"))
410 408
@@ -412,13 +410,13 @@ inside double-quotes"
412;; Interpolating commands 410;; Interpolating commands
413 411
414(ert-deftest esh-var-test/command-interp () 412(ert-deftest esh-var-test/command-interp ()
415 "Interpolate a variable as a command name" 413 "Interpolate a variable as a command name."
416 (let ((eshell-test-value "printnl")) 414 (let ((eshell-test-value "printnl"))
417 (eshell-command-result-equal "$eshell-test-value hello there" 415 (eshell-command-result-equal "$eshell-test-value hello there"
418 "hello\nthere\n"))) 416 "hello\nthere\n")))
419 417
420(ert-deftest esh-var-test/command-interp-splice () 418(ert-deftest esh-var-test/command-interp-splice ()
421 "Interpolate a splice variable as a command name with arguments" 419 "Interpolate a splice variable as a command name with arguments."
422 (let ((eshell-test-value '("printnl" "hello" "there"))) 420 (let ((eshell-test-value '("printnl" "hello" "there")))
423 (eshell-command-result-equal "$@eshell-test-value" 421 (eshell-command-result-equal "$@eshell-test-value"
424 "hello\nthere\n"))) 422 "hello\nthere\n")))
@@ -427,13 +425,13 @@ inside double-quotes"
427;; Interpolated variable conversion 425;; Interpolated variable conversion
428 426
429(ert-deftest esh-var-test/interp-convert-var-number () 427(ert-deftest esh-var-test/interp-convert-var-number ()
430 "Interpolate numeric variable" 428 "Interpolate numeric variable."
431 (let ((eshell-test-value 123)) 429 (let ((eshell-test-value 123))
432 (eshell-command-result-equal "type-of $eshell-test-value" 430 (eshell-command-result-equal "type-of $eshell-test-value"
433 'integer))) 431 'integer)))
434 432
435(ert-deftest esh-var-test/interp-convert-var-split-indices () 433(ert-deftest esh-var-test/interp-convert-var-split-indices ()
436 "Interpolate and convert string variable with indices" 434 "Interpolate and convert string variable with indices."
437 ;; Check that numeric forms are converted to numbers. 435 ;; Check that numeric forms are converted to numbers.
438 (let ((eshell-test-value "000 010 020 030 040")) 436 (let ((eshell-test-value "000 010 020 030 040"))
439 (eshell-command-result-equal "echo $eshell-test-value[0]" 437 (eshell-command-result-equal "echo $eshell-test-value[0]"
@@ -448,7 +446,7 @@ inside double-quotes"
448 "baz\n"))) 446 "baz\n")))
449 447
450(ert-deftest esh-var-test/interp-convert-quoted-var-number () 448(ert-deftest esh-var-test/interp-convert-quoted-var-number ()
451 "Interpolate numeric quoted numeric variable" 449 "Interpolate numeric quoted numeric variable."
452 (let ((eshell-test-value 123)) 450 (let ((eshell-test-value 123))
453 (eshell-command-result-equal "type-of $'eshell-test-value'" 451 (eshell-command-result-equal "type-of $'eshell-test-value'"
454 'integer) 452 'integer)
@@ -456,7 +454,7 @@ inside double-quotes"
456 'integer))) 454 'integer)))
457 455
458(ert-deftest esh-var-test/interp-convert-quoted-var-split-indices () 456(ert-deftest esh-var-test/interp-convert-quoted-var-split-indices ()
459 "Interpolate and convert quoted string variable with indices" 457 "Interpolate and convert quoted string variable with indices."
460 (let ((eshell-test-value "000 010 020 030 040")) 458 (let ((eshell-test-value "000 010 020 030 040"))
461 (eshell-command-result-equal "echo $'eshell-test-value'[0]" 459 (eshell-command-result-equal "echo $'eshell-test-value'[0]"
462 0) 460 0)
@@ -464,11 +462,11 @@ inside double-quotes"
464 '(0 20)))) 462 '(0 20))))
465 463
466(ert-deftest esh-var-test/interp-convert-cmd-string-newline () 464(ert-deftest esh-var-test/interp-convert-cmd-string-newline ()
467 "Interpolate trailing-newline command result" 465 "Interpolate trailing-newline command result."
468 (eshell-command-result-equal "echo ${echo \"foo\n\"}" "foo")) 466 (eshell-command-result-equal "echo ${echo \"foo\n\"}" "foo"))
469 467
470(ert-deftest esh-var-test/interp-convert-cmd-multiline () 468(ert-deftest esh-var-test/interp-convert-cmd-multiline ()
471 "Interpolate multi-line command result" 469 "Interpolate multi-line command result."
472 (eshell-command-result-equal "echo ${echo \"foo\nbar\"}" 470 (eshell-command-result-equal "echo ${echo \"foo\nbar\"}"
473 '("foo" "bar")) 471 '("foo" "bar"))
474 ;; Numeric output should be converted to numbers... 472 ;; Numeric output should be converted to numbers...
@@ -479,24 +477,24 @@ inside double-quotes"
479 '("01" "02" "hi"))) 477 '("01" "02" "hi")))
480 478
481(ert-deftest esh-var-test/interp-convert-cmd-number () 479(ert-deftest esh-var-test/interp-convert-cmd-number ()
482 "Interpolate numeric command result" 480 "Interpolate numeric command result."
483 (eshell-command-result-equal "echo ${echo \"1\"}" 1)) 481 (eshell-command-result-equal "echo ${echo \"1\"}" 1))
484 482
485(ert-deftest esh-var-test/interp-convert-cmd-split-indices () 483(ert-deftest esh-var-test/interp-convert-cmd-split-indices ()
486 "Interpolate command result with indices" 484 "Interpolate command result with indices."
487 (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0]" 485 (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0]"
488 0) 486 0)
489 (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0 2]" 487 (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0 2]"
490 '(0 20))) 488 '(0 20)))
491 489
492(ert-deftest esh-var-test/quoted-interp-convert-var-number () 490(ert-deftest esh-var-test/quoted-interp-convert-var-number ()
493 "Interpolate numeric variable inside double-quotes" 491 "Interpolate numeric variable inside double-quotes."
494 (let ((eshell-test-value 123)) 492 (let ((eshell-test-value 123))
495 (eshell-command-result-equal "type-of \"$eshell-test-value\"" 493 (eshell-command-result-equal "type-of \"$eshell-test-value\""
496 'string))) 494 'string)))
497 495
498(ert-deftest esh-var-test/quoted-interp-convert-var-split-indices () 496(ert-deftest esh-var-test/quoted-interp-convert-var-split-indices ()
499 "Interpolate string variable with indices inside double-quotes" 497 "Interpolate string variable with indices inside double-quotes."
500 (let ((eshell-test-value "000 010 020 030 040")) 498 (let ((eshell-test-value "000 010 020 030 040"))
501 (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" 499 (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
502 "000") 500 "000")
@@ -504,7 +502,7 @@ inside double-quotes"
504 "(\"000\" \"020\")"))) 502 "(\"000\" \"020\")")))
505 503
506(ert-deftest esh-var-test/quoted-interp-convert-quoted-var-number () 504(ert-deftest esh-var-test/quoted-interp-convert-quoted-var-number ()
507 "Interpolate numeric quoted variable inside double-quotes" 505 "Interpolate numeric quoted variable inside double-quotes."
508 (let ((eshell-test-value 123)) 506 (let ((eshell-test-value 123))
509 (eshell-command-result-equal "type-of \"$'eshell-test-value'\"" 507 (eshell-command-result-equal "type-of \"$'eshell-test-value'\""
510 'string) 508 'string)
@@ -512,7 +510,7 @@ inside double-quotes"
512 'string))) 510 'string)))
513 511
514(ert-deftest esh-var-test/quoted-interp-convert-quoted-var-split-indices () 512(ert-deftest esh-var-test/quoted-interp-convert-quoted-var-split-indices ()
515 "Interpolate quoted string variable with indices inside double-quotes" 513 "Interpolate quoted string variable with indices inside double-quotes."
516 (let ((eshell-test-value "000 010 020 030 040")) 514 (let ((eshell-test-value "000 010 020 030 040"))
517 (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" 515 (eshell-command-result-equal "echo \"$eshell-test-value[0]\""
518 "000") 516 "000")
@@ -520,23 +518,23 @@ inside double-quotes"
520 "(\"000\" \"020\")"))) 518 "(\"000\" \"020\")")))
521 519
522(ert-deftest esh-var-test/quoted-interp-convert-cmd-string-newline () 520(ert-deftest esh-var-test/quoted-interp-convert-cmd-string-newline ()
523 "Interpolate trailing-newline command result inside double-quotes" 521 "Interpolate trailing-newline command result inside double-quotes."
524 (eshell-command-result-equal "echo \"${echo \\\"foo\n\\\"}\"" 522 (eshell-command-result-equal "echo \"${echo \\\"foo\n\\\"}\""
525 "foo") 523 "foo")
526 (eshell-command-result-equal "echo \"${echo \\\"foo\n\n\\\"}\"" 524 (eshell-command-result-equal "echo \"${echo \\\"foo\n\n\\\"}\""
527 "foo")) 525 "foo"))
528 526
529(ert-deftest esh-var-test/quoted-interp-convert-cmd-multiline () 527(ert-deftest esh-var-test/quoted-interp-convert-cmd-multiline ()
530 "Interpolate multi-line command result inside double-quotes" 528 "Interpolate multi-line command result inside double-quotes."
531 (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"}\"" 529 (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"}\""
532 "foo\nbar")) 530 "foo\nbar"))
533 531
534(ert-deftest esh-var-test/quoted-interp-convert-cmd-number () 532(ert-deftest esh-var-test/quoted-interp-convert-cmd-number ()
535 "Interpolate numeric command result inside double-quotes" 533 "Interpolate numeric command result inside double-quotes."
536 (eshell-command-result-equal "echo \"${echo \\\"1\\\"}\"" "1")) 534 (eshell-command-result-equal "echo \"${echo \\\"1\\\"}\"" "1"))
537 535
538(ert-deftest esh-var-test/quoted-interp-convert-cmd-split-indices () 536(ert-deftest esh-var-test/quoted-interp-convert-cmd-split-indices ()
539 "Interpolate command result with indices inside double-quotes" 537 "Interpolate command result with indices inside double-quotes."
540 (eshell-command-result-equal "echo \"${echo \\\"000 010 020\\\"}[0]\"" 538 (eshell-command-result-equal "echo \"${echo \\\"000 010 020\\\"}[0]\""
541 "000")) 539 "000"))
542 540
@@ -695,19 +693,19 @@ it, since the setter is nil."
695 (window-body-height nil 'remap))) 693 (window-body-height nil 'remap)))
696 694
697(ert-deftest esh-var-test/columns-var () 695(ert-deftest esh-var-test/columns-var ()
698 "$COLUMNS should equal (window-body-width nil 'remap)" 696 "$COLUMNS should equal (window-body-width nil 'remap)."
699 (eshell-command-result-equal "echo $COLUMNS" 697 (eshell-command-result-equal "echo $COLUMNS"
700 (window-body-width nil 'remap))) 698 (window-body-width nil 'remap)))
701 699
702(ert-deftest esh-var-test/inside-emacs-var () 700(ert-deftest esh-var-test/inside-emacs-var ()
703 "Test presence of \"INSIDE_EMACS\" in subprocesses" 701 "Test presence of \"INSIDE_EMACS\" in subprocesses."
704 (with-temp-eshell 702 (with-temp-eshell
705 (eshell-match-command-output "env" 703 (eshell-match-command-output "env"
706 (format "INSIDE_EMACS=%s,eshell" 704 (format "INSIDE_EMACS=%s,eshell"
707 emacs-version)))) 705 emacs-version))))
708 706
709(ert-deftest esh-var-test/inside-emacs-var-split-indices () 707(ert-deftest esh-var-test/inside-emacs-var-split-indices ()
710 "Test using \"INSIDE_EMACS\" with split indices" 708 "Test using \"INSIDE_EMACS\" with split indices."
711 (with-temp-eshell 709 (with-temp-eshell
712 (eshell-match-command-output "echo $INSIDE_EMACS[, 1]" 710 (eshell-match-command-output "echo $INSIDE_EMACS[, 1]"
713 "eshell"))) 711 "eshell")))
@@ -776,7 +774,7 @@ it, since the setter is nil."
776 (eshell-command-result-equal "echo $UID" (user-uid))) 774 (eshell-command-result-equal "echo $UID" (user-uid)))
777 775
778(ert-deftest esh-var-test/last-status-var-lisp-command () 776(ert-deftest esh-var-test/last-status-var-lisp-command ()
779 "Test using the \"last exit status\" ($?) variable with a Lisp command" 777 "Test using the \"last exit status\" ($?) variable with a Lisp command."
780 (with-temp-eshell 778 (with-temp-eshell
781 (eshell-match-command-output "zerop 0; echo $?" 779 (eshell-match-command-output "zerop 0; echo $?"
782 "t\n0\n") 780 "t\n0\n")
@@ -786,7 +784,7 @@ it, since the setter is nil."
786 "1\n" nil t))) 784 "1\n" nil t)))
787 785
788(ert-deftest esh-var-test/last-status-var-lisp-form () 786(ert-deftest esh-var-test/last-status-var-lisp-form ()
789 "Test using the \"last exit status\" ($?) variable with a Lisp form" 787 "Test using the \"last exit status\" ($?) variable with a Lisp form."
790 (let ((eshell-lisp-form-nil-is-failure t)) 788 (let ((eshell-lisp-form-nil-is-failure t))
791 (with-temp-eshell 789 (with-temp-eshell
792 (eshell-match-command-output "(zerop 0); echo $?" 790 (eshell-match-command-output "(zerop 0); echo $?"
@@ -809,7 +807,7 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil."
809 "1\n" nil t)))) 807 "1\n" nil t))))
810 808
811(ert-deftest esh-var-test/last-status-var-ext-cmd () 809(ert-deftest esh-var-test/last-status-var-ext-cmd ()
812 "Test using the \"last exit status\" ($?) variable with an external command" 810 "Test using the \"last exit status\" ($?) variable with an external command."
813 (skip-unless (executable-find "[")) 811 (skip-unless (executable-find "["))
814 (with-temp-eshell 812 (with-temp-eshell
815 (eshell-match-command-output "[ foo = foo ]; echo $?" 813 (eshell-match-command-output "[ foo = foo ]; echo $?"
@@ -818,19 +816,19 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil."
818 "1\n"))) 816 "1\n")))
819 817
820(ert-deftest esh-var-test/last-result-var () 818(ert-deftest esh-var-test/last-result-var ()
821 "Test using the \"last result\" ($$) variable" 819 "Test using the \"last result\" ($$) variable."
822 (with-temp-eshell 820 (with-temp-eshell
823 (eshell-match-command-output "+ 1 2; + $$ 2" 821 (eshell-match-command-output "+ 1 2; + $$ 2"
824 "3\n5\n"))) 822 "3\n5\n")))
825 823
826(ert-deftest esh-var-test/last-result-var-twice () 824(ert-deftest esh-var-test/last-result-var-twice ()
827 "Test using the \"last result\" ($$) variable twice" 825 "Test using the \"last result\" ($$) variable twice."
828 (with-temp-eshell 826 (with-temp-eshell
829 (eshell-match-command-output "+ 1 2; + $$ $$" 827 (eshell-match-command-output "+ 1 2; + $$ $$"
830 "3\n6\n"))) 828 "3\n6\n")))
831 829
832(ert-deftest esh-var-test/last-result-var-ext-cmd () 830(ert-deftest esh-var-test/last-result-var-ext-cmd ()
833 "Test using the \"last result\" ($$) variable with an external command" 831 "Test using the \"last result\" ($$) variable with an external command."
834 (skip-unless (executable-find "[")) 832 (skip-unless (executable-find "["))
835 (with-temp-eshell 833 (with-temp-eshell
836 ;; MS-DOS/MS-Windows have an external command 'format', which we 834 ;; MS-DOS/MS-Windows have an external command 'format', which we
@@ -842,7 +840,7 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil."
842 "nil\n")))) 840 "nil\n"))))
843 841
844(ert-deftest esh-var-test/last-result-var-split-indices () 842(ert-deftest esh-var-test/last-result-var-split-indices ()
845 "Test using the \"last result\" ($$) variable with split indices" 843 "Test using the \"last result\" ($$) variable with split indices."
846 (with-temp-eshell 844 (with-temp-eshell
847 (eshell-match-command-output 845 (eshell-match-command-output
848 "string-join (list \"01\" \"02\") :; + $$[: 1] 3" 846 "string-join (list \"01\" \"02\") :; + $$[: 1] 3"
@@ -852,13 +850,13 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil."
852 "01:02\n02\n"))) 850 "01:02\n02\n")))
853 851
854(ert-deftest esh-var-test/last-arg-var () 852(ert-deftest esh-var-test/last-arg-var ()
855 "Test using the \"last arg\" ($_) variable" 853 "Test using the \"last arg\" ($_) variable."
856 (with-temp-eshell 854 (with-temp-eshell
857 (eshell-match-command-output "+ 1 2; + $_ 4" 855 (eshell-match-command-output "+ 1 2; + $_ 4"
858 "3\n6\n"))) 856 "3\n6\n")))
859 857
860(ert-deftest esh-var-test/last-arg-var-indices () 858(ert-deftest esh-var-test/last-arg-var-indices ()
861 "Test using the \"last arg\" ($_) variable with indices" 859 "Test using the \"last arg\" ($_) variable with indices."
862 (with-temp-eshell 860 (with-temp-eshell
863 (eshell-match-command-output "+ 1 2; + $_[0] 4" 861 (eshell-match-command-output "+ 1 2; + $_[0] 4"
864 "3\n5\n") 862 "3\n5\n")
@@ -866,7 +864,7 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil."
866 "3\n6\n"))) 864 "3\n6\n")))
867 865
868(ert-deftest esh-var-test/last-arg-var-split-indices () 866(ert-deftest esh-var-test/last-arg-var-split-indices ()
869 "Test using the \"last arg\" ($_) variable with split indices" 867 "Test using the \"last arg\" ($_) variable with split indices."
870 (with-temp-eshell 868 (with-temp-eshell
871 (eshell-match-command-output "concat 01:02 03:04; + $_[0][: 1] 5" 869 (eshell-match-command-output "concat 01:02 03:04; + $_[0][: 1] 5"
872 "01:0203:04\n7\n") 870 "01:0203:04\n7\n")