You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<li><code>$file-text</code>: The text of the current file edited</li>
2201
2219
<li><code>$ns</code>: The namespace used for evaluating the command</li>
2202
2220
<li><code>$editor-ns</code>: The namespace of the editor from which the command was run</li>
2221
+
<li><code>$ns-form</code>: The <code>ns</code> form which would be used if evaluating something from the current cursor position (often the <code>ns</code> form of the current file)</li>
2203
2222
<li><code>$selection</code>: The currently selected text</li>
2204
2223
<li><code>$current-form</code>: The text of the <ahref="../evaluation/#current-form">current form</a></li>
2205
2224
<li><code>$current-pair</code>: The text of the current pair if in a binding, otherwise empty string</li>
<li><code>$head</code>: The text between the start of the current list to the cursor</li>
2211
2230
<li><code>$tail</code>: The text between the cursor and the end of the current list</li>
2212
2231
</ul>
2232
+
<p>The substitution variables can also be referenced using a <code>${variable}</code> syntax. This is to facilitate modifiers. Speaking of which...</p>
<p>You can transform substitution values using modifiers. The syntax is: <code>${variable|modifier|arg1|arg2...}</code>. Multiple modifiers can be chained, separated by <code>|</code>.</p>
2235
+
<p>Available modifiers:</p>
2236
+
<ul>
2237
+
<li><code>pr-str</code>: Stringify the value</li>
2238
+
<li><code>replace</code>: Replace text using regex pattern and replacement string. Takes two arguments: pattern and replacement</li>
2239
+
<li><code>replace-first</code>: Replace first occurrence of pattern. Takes two arguments: pattern and replacement</li>
2240
+
</ul>
2241
+
<p>ClojureScript semantics apply. The modifications will happen client side, in Calva, and the modifiers will in fact be using the corresponding ClojureScript functions to perform the modification.</p>
2242
+
<p>The interpolation special characters (<code>|</code>, <code>{</code>, and <code>}</code>) in replacement strings need to be escaped with a backslash.</p>
2243
+
<p>Examples:</p>
2244
+
<divclass="highlight"><pre><span></span><code>// Stringify, then replace spaces
<spanclass="w"></span><spanclass="nt">"name"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"Call Current Form"</span><spanclass="p">,</span>
0 commit comments