aboutsummaryrefslogtreecommitdiff
path: root/ctags/docs/man/readtags.1.html
blob: 0a8e8672a17d10867f4516d956c4126cd85bde97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>readtags &#8212; Universal Ctags 0.3.0 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/classic.css" />
    
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Parsers" href="../parsers.html" />
    <link rel="prev" title="ctags-incompatibilities" href="ctags-incompatibilities.7.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../parsers.html" title="Parsers"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="ctags-incompatibilities.7.html" title="ctags-incompatibilities"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">Universal Ctags 0.3.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../man-pages.html" accesskey="U">Man pages</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">readtags</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="readtags">
<span id="readtags-1"></span><h1>readtags<a class="headerlink" href="#readtags" title="Permalink to this headline"></a></h1>
<p>Find tag file entries matching specified names</p>
<dl class="field-list simple">
<dt class="field-odd">Version</dt>
<dd class="field-odd"><p>5.9.0</p>
</dd>
<dt class="field-even">Manual group</dt>
<dd class="field-even"><p>Universal Ctags</p>
</dd>
<dt class="field-odd">Manual section</dt>
<dd class="field-odd"><p>1</p>
</dd>
</dl>
<section id="synopsis">
<h2>SYNOPSIS<a class="headerlink" href="#synopsis" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line"><strong>readtags</strong> -h | --help</div>
<div class="line"><strong>readtags</strong> (-H | --help-expression) (filter|sorter)</div>
<div class="line"><strong>readtags</strong> [OPTION]… ACTION</div>
</div>
</section>
<section id="description">
<h2>DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline"></a></h2>
<p>The <strong>readtags</strong> program filters, sorts and prints tag entries in a tags file.
The basic filtering is done using <strong>actions</strong>, by which you can list all
regular tags, pseudo tags or regular tags matching specific name. Then, further
filtering and sorting can be done using <strong>post processors</strong>, namely <strong>filter
expressions</strong> and <strong>sorter expressions</strong>.</p>
</section>
<section id="actions">
<h2>ACTIONS<a class="headerlink" href="#actions" title="Permalink to this headline"></a></h2>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">-l</span></code>, <code class="docutils literal notranslate"><span class="pre">--list</span></code></dt><dd><p>List regular tags.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">[-]</span> <span class="pre">NAME</span></code></dt><dd><p>List regular tags matching NAME.
“-” as NAME indicates arguments after this as NAME even if they start with -.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-D</span></code>, <code class="docutils literal notranslate"><span class="pre">--list-pseudo-tags</span></code></dt><dd><p>Equivalent to <code class="docutils literal notranslate"><span class="pre">--list-pseudo-tags</span></code>.</p>
</dd>
</dl>
</section>
<section id="options">
<h2>OPTIONS<a class="headerlink" href="#options" title="Permalink to this headline"></a></h2>
<section id="controlling-the-tags-reading-behavior">
<h3>Controlling the Tags Reading Behavior<a class="headerlink" href="#controlling-the-tags-reading-behavior" title="Permalink to this headline"></a></h3>
<p>The behavior of reading tags can be controlled using these options:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">-t</span> <span class="pre">TAGFILE</span></code>, <code class="docutils literal notranslate"><span class="pre">--tag-file</span> <span class="pre">TAGFILE</span></code></dt><dd><p>Use specified tag file (default: “tags”).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-s[0|1|2]</span></code>, <code class="docutils literal notranslate"><span class="pre">--override-sort-detection</span> <span class="pre">METHOD</span></code></dt><dd><p>Override sort detection of tag file.
METHOD: unsorted|sorted|foldcase</p>
</dd>
</dl>
<p>The NAME action will perform binary search on sorted (including “foldcase”)
tags files, which is much faster then on unsorted tags files.</p>
</section>
<section id="controlling-the-name-action-behavior">
<h3>Controlling the NAME Action Behavior<a class="headerlink" href="#controlling-the-name-action-behavior" title="Permalink to this headline"></a></h3>
<p>The behavior of the NAME action can be controlled using these options:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">-i</span></code>, <code class="docutils literal notranslate"><span class="pre">--icase-match</span></code></dt><dd><p>Perform case-insensitive matching in the NAME action.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-p</span></code>, <code class="docutils literal notranslate"><span class="pre">--prefix-match</span></code></dt><dd><p>Perform prefix matching in the NAME action.</p>
</dd>
</dl>
</section>
<section id="controlling-the-output">
<h3>Controlling the Output<a class="headerlink" href="#controlling-the-output" title="Permalink to this headline"></a></h3>
<p>By default, the output of readtags contains only the name, input and pattern
field. The Output can be tweaked using these options:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">-d</span></code>, <code class="docutils literal notranslate"><span class="pre">--debug</span></code></dt><dd><p>Turn on debugging output.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-E</span></code>, <code class="docutils literal notranslate"><span class="pre">--escape-output</span></code></dt><dd><p>Escape characters like tabs in output as described in <a class="reference internal" href="tags.5.html#tags-5"><span class="std std-ref">tags(5)</span></a>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-e</span></code>, <code class="docutils literal notranslate"><span class="pre">--extension-fields</span></code></dt><dd><p>Include extension fields in output.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-n</span></code>, <code class="docutils literal notranslate"><span class="pre">--line-number</span></code></dt><dd><p>Also include the line number field when <code class="docutils literal notranslate"><span class="pre">-e</span></code> option is give.</p>
</dd>
</dl>
<p>About the <code class="docutils literal notranslate"><span class="pre">-E</span></code> option: certain characters are escaped in a tags file, to make
it machine-readable. e.g., ensuring no tabs character appear in fields other
than the pattern field. By default, readtags translates them to make it
human-readable, but when utilizing readtags output in a script or a client
tool, <code class="docutils literal notranslate"><span class="pre">-E</span></code> option should be used. See <a class="reference internal" href="ctags-client-tools.7.html#ctags-client-tools-7"><span class="std std-ref">ctags-client-tools(7)</span></a> for more
discussion on this.</p>
</section>
<section id="filtering-and-sorting">
<h3>Filtering and Sorting<a class="headerlink" href="#filtering-and-sorting" title="Permalink to this headline"></a></h3>
<p>Further filtering and sorting on the tags listed by actions are performed using:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">-Q</span> <span class="pre">EXP</span></code>, <code class="docutils literal notranslate"><span class="pre">--filter</span> <span class="pre">EXP</span></code></dt><dd><p>Filter the tags listed by ACTION with EXP before printing.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-S</span> <span class="pre">EXP</span></code>, <code class="docutils literal notranslate"><span class="pre">--sorter</span> <span class="pre">EXP</span></code></dt><dd><p>Sort the tags listed by ACTION with EXP before printing.</p>
</dd>
</dl>
<p>These are discussed in the <a class="reference internal" href="#expression">EXPRESSION</a> section.</p>
</section>
<section id="examples">
<h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h3>
<ul>
<li><p>List all tags in “/path/to/tags”:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -t /path/to/tags -l
</pre></div>
</div>
</li>
<li><p>List all tags in “tags” that start with “mymethod”:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -p - mymethod
</pre></div>
</div>
</li>
<li><p>List all tags matching “mymethod”, case insensitively:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -i - mymethod
</pre></div>
</div>
</li>
<li><p>List all tags start with “myvar”, and printing all fields (i.e., the whole line):</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -p -ne - myvar
</pre></div>
</div>
</li>
</ul>
</section>
</section>
<section id="expression">
<h2>EXPRESSION<a class="headerlink" href="#expression" title="Permalink to this headline"></a></h2>
<p>Scheme-style expressions are used for the <code class="docutils literal notranslate"><span class="pre">-Q</span></code> and <code class="docutils literal notranslate"><span class="pre">-S</span></code> options. For those
who doesn’t know Scheme or Lisp, just remember:</p>
<ul class="simple">
<li><p>A function call is wrapped in a pair of parenthesis. The first item in it is
the function/operator name, the others are arguments.</p></li>
<li><p>Function calls can be nested.</p></li>
<li><p>Missing values and boolean false are represented by <code class="docutils literal notranslate"><span class="pre">#f</span></code>. <code class="docutils literal notranslate"><span class="pre">#t</span></code> and all
other values are considered to be true.</p></li>
</ul>
<p>So, <code class="docutils literal notranslate"><span class="pre">(+</span> <span class="pre">1</span> <span class="pre">(+</span> <span class="pre">2</span> <span class="pre">3))</span></code> means add 2 and 3 first, then add the result with 1.
<code class="docutils literal notranslate"><span class="pre">(and</span> <span class="pre">&quot;string&quot;</span> <span class="pre">1</span> <span class="pre">#t)</span></code> means logical AND on <code class="docutils literal notranslate"><span class="pre">&quot;string&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">1</span></code> and <code class="docutils literal notranslate"><span class="pre">#t</span></code>,
and the result is true since there is no <code class="docutils literal notranslate"><span class="pre">#f</span></code>.</p>
<section id="filtering">
<h3>Filtering<a class="headerlink" href="#filtering" title="Permalink to this headline"></a></h3>
<p>The tag entries that make the filter expression produces true value are printed
by readtags.</p>
<p>The basic operators for filtering are <code class="docutils literal notranslate"><span class="pre">eq?</span></code>, <code class="docutils literal notranslate"><span class="pre">prefix?</span></code>, <code class="docutils literal notranslate"><span class="pre">suffix?</span></code>,
<code class="docutils literal notranslate"><span class="pre">substr?</span></code>, and <code class="docutils literal notranslate"><span class="pre">#/PATTERN/</span></code>. Language common fields can be accessed using
variables starting with <code class="docutils literal notranslate"><span class="pre">$</span></code>, e.g., <code class="docutils literal notranslate"><span class="pre">$language</span></code> represents the language field.
For example:</p>
<ul>
<li><p>List all tags start with “myfunc” in Python code files:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -p -Q <span class="s1">&#39;(eq? $language &quot;Python&quot;)&#39;</span> - myfunc
</pre></div>
</div>
</li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">downcase</span></code> or <code class="docutils literal notranslate"><span class="pre">upcase</span></code> operators can be used to perform case-insensitive
matching:</p>
<ul>
<li><p>List all tags containing “my”, case insensitively:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -Q <span class="s1">&#39;(substr? (downcase $name) &quot;my&quot;)&#39;</span> -l
</pre></div>
</div>
</div></blockquote>
</li>
</ul>
<p>We have logical operators like <code class="docutils literal notranslate"><span class="pre">and</span></code>, <code class="docutils literal notranslate"><span class="pre">or</span></code> and <code class="docutils literal notranslate"><span class="pre">not</span></code>. The value of a
missing field is #f, so we could deal with missing fields:</p>
<ul>
<li><p>List all tags containing “impl” in Python code files, but allow the
<code class="docutils literal notranslate"><span class="pre">language:</span></code> field to be missing:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span>$ readtags -Q &#39;(and (substr? $name &quot;impl&quot;)\
                    (or (not $language)\
                        (eq? $language &quot;Python&quot;)))&#39; -l
</pre></div>
</div>
</li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">#/PATTERN/</span></code> is for the case when string predicates (<code class="docutils literal notranslate"><span class="pre">prefix?</span></code>, <code class="docutils literal notranslate"><span class="pre">suffix?</span></code>,
and <code class="docutils literal notranslate"><span class="pre">substr?</span></code>) are not enough. You can use “Posix extended regular expression”
as PATTERN.</p>
<ul>
<li><p>List all tags inherits from the class “A”:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -Q <span class="s1">&#39;(#/(^|,) ?A(,|$)/ $inherits)&#39;</span> -l
</pre></div>
</div>
</li>
</ul>
<p>Here <code class="docutils literal notranslate"><span class="pre">$inherits</span></code> is a comma-separated class list like “A,B,C”, “P, A, Q”, or
just “A”. Notice that this filter works on both situations where there’s a
space after each comma or there’s not.</p>
<p>Case-insensitive matching can be performed by <code class="docutils literal notranslate"><span class="pre">#/PATTERN/i</span></code>:</p>
<ul>
<li><p>List all tags inherits from the class “A” or “a”:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -Q <span class="s1">&#39;(#/(^|,) ?A(,|$)/i $inherits)&#39;</span> -l
</pre></div>
</div>
</li>
</ul>
<p>To include “/” in a pattern, prefix <code class="docutils literal notranslate"><span class="pre">\</span></code> to the “/”.</p>
<p>NOTE: The above regular expression pattern for inspecting inheritances is just
an example to show how to use <code class="docutils literal notranslate"><span class="pre">#/PATTERN/</span></code> expression. Tags file generators
have no consensus about the format of <code class="docutils literal notranslate"><span class="pre">inherits:</span></code>, e.g., whether there should
be a space after a comma. Even parsers in ctags have no consensus. Noticing the
format of the <code class="docutils literal notranslate"><span class="pre">inherits:</span></code> field of specific languages is needed for such
queries.</p>
<p>The expressions <code class="docutils literal notranslate"><span class="pre">#/PATTERN/</span></code> and <code class="docutils literal notranslate"><span class="pre">#/PATTERN/i</span></code> are for interactive use.
Readtags also offers an alias <code class="docutils literal notranslate"><span class="pre">string-&gt;regexp</span></code>, so <code class="docutils literal notranslate"><span class="pre">#/PATTERN/</span></code> is equal to
<code class="docutils literal notranslate"><span class="pre">(string-&gt;regexp</span> <span class="pre">&quot;PATTERN&quot;)</span></code>, and <code class="docutils literal notranslate"><span class="pre">#/PATTERN/i</span></code> is equal to
<code class="docutils literal notranslate"><span class="pre">(string-&gt;regexp</span> <span class="pre">&quot;PATTERN&quot;</span> <span class="pre">:case-fold</span> <span class="pre">#t)</span></code>. <code class="docutils literal notranslate"><span class="pre">string-&gt;regexp</span></code> doesn’t need
to prefix <code class="docutils literal notranslate"><span class="pre">\</span></code> for including “/” in a pattern. <code class="docutils literal notranslate"><span class="pre">string-&gt;regexp</span></code> may simplify
a client tool building an expression. See also <a class="reference internal" href="ctags-client-tools.7.html#ctags-client-tools-7"><span class="std std-ref">ctags-client-tools(7)</span></a> for
building expressions in your tool.</p>
<p>Let’s now consider missing fields. The tags file may have tag entries that has
no <code class="docutils literal notranslate"><span class="pre">inherits:</span></code> field. In that case <code class="docutils literal notranslate"><span class="pre">$inherits</span></code> is #f, and the regular
expression matching raises an error, since string operators only work for
strings. To avoid this problem:</p>
<ul>
<li><p>Safely list all tags inherits from the class “A”:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -Q <span class="s1">&#39;(and $inherits (#/(^|,) ?A(,|$)/ $inherits))&#39;</span> -l
</pre></div>
</div>
</li>
</ul>
<p>This makes sure <code class="docutils literal notranslate"><span class="pre">$inherits</span></code> is not missing first, then match it by regexp.</p>
<p>Sometimes you want to keep tags where the field <em>is</em> missing. For example, your
want to exclude reference tags, which is marked by the <code class="docutils literal notranslate"><span class="pre">extras:</span></code> field, then
you want to keep tags who doesn’t have <code class="docutils literal notranslate"><span class="pre">extras:</span></code> field since they are also
not reference tags. Here’s how to do it:</p>
<ul>
<li><p>List all tags but the reference tags:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -Q <span class="s1">&#39;(or (not $extras) (#/(^|,) ?reference(,|$)/ $extras))&#39;</span> -l
</pre></div>
</div>
</li>
</ul>
<p>Notice that <code class="docutils literal notranslate"><span class="pre">(not</span> <span class="pre">$extras)</span></code> produces <code class="docutils literal notranslate"><span class="pre">#t</span></code> when <code class="docutils literal notranslate"><span class="pre">$extras</span></code> is missing, so
the whole <code class="docutils literal notranslate"><span class="pre">or</span></code> expression produces <code class="docutils literal notranslate"><span class="pre">#t</span></code>.</p>
<p>Run “readtags -H filter” to know about all valid functions and variables.</p>
</section>
<section id="sorting">
<h3>Sorting<a class="headerlink" href="#sorting" title="Permalink to this headline"></a></h3>
<p>When sorting, the sorter expression is evaluated on two tag entries to decide
which should sort before the other one, until the order of all tag entries is
decided.</p>
<p>In a sorter expression, <code class="docutils literal notranslate"><span class="pre">$</span></code> and <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> are used to access the fields in the
two tag entries, and let’s call them $-entry and &amp;-entry. The sorter expression
should have a value of -1, 0 or 1. The value -1 means the $-entry should be put
above the &amp;-entry, 1 means the contrary, and 0 makes their order in the output
uncertain.</p>
<p>The core operator of sorting is <code class="docutils literal notranslate"><span class="pre">&lt;&gt;</span></code>. It’s used to compare two strings or two
numbers (numbers are for the <code class="docutils literal notranslate"><span class="pre">line:</span></code> or <code class="docutils literal notranslate"><span class="pre">end:</span></code> fields). In <code class="docutils literal notranslate"><span class="pre">(&lt;&gt;</span> <span class="pre">a</span> <span class="pre">b)</span></code>, if
<code class="docutils literal notranslate"><span class="pre">a</span></code> &lt; <code class="docutils literal notranslate"><span class="pre">b</span></code>, the result is -1; <code class="docutils literal notranslate"><span class="pre">a</span></code> &gt; <code class="docutils literal notranslate"><span class="pre">b</span></code> produces 1, and <code class="docutils literal notranslate"><span class="pre">a</span></code> = <code class="docutils literal notranslate"><span class="pre">b</span></code>
produces 0. Strings are compared using the <code class="docutils literal notranslate"><span class="pre">strcmp</span></code> function, see strcmp(3).</p>
<p>For example, sort by names, and make those shorter or alphabetically smaller
ones appear before the others:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -S <span class="s1">&#39;(&lt;&gt; $name &amp;name)&#39;</span> -l
</pre></div>
</div>
<p>This reads “If the tag name in the $-entry is smaller, it goes before the
&amp;-entry”.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">&lt;or&gt;</span></code> operator is used to chain multiple expressions until one returns
-1 or 1. For example, sort by input file names, then line numbers if in the
same file:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -S <span class="s1">&#39;(&lt;or&gt; (&lt;&gt; $input &amp;input) (&lt;&gt; $line &amp;line))&#39;</span> -l
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">*-</span></code> operator is used to flip the compare result. i.e., <code class="docutils literal notranslate"><span class="pre">(*-</span> <span class="pre">(&lt;&gt;</span> <span class="pre">a</span> <span class="pre">b))</span></code>
is the same as <code class="docutils literal notranslate"><span class="pre">(&lt;&gt;</span> <span class="pre">b</span> <span class="pre">a)</span></code>.</p>
<p>Filter expressions can be used in sorter expressions. The technique is use
<code class="docutils literal notranslate"><span class="pre">if</span></code> to produce integers that can be compared based on the filter, like:</p>
<div class="highlight-lisp notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="nv">&lt;&gt;</span> <span class="p">(</span><span class="k">if</span> <span class="nv">filter-expr-on-$-entry</span> <span class="mi">-1</span> <span class="mi">1</span><span class="p">)</span>
    <span class="p">(</span><span class="k">if</span> <span class="nv">filter-expr-on-&amp;-entry</span> <span class="mi">-1</span> <span class="mi">1</span><span class="p">))</span>
</pre></div>
</div>
<p>So if $-entry satisfies the filter, while &amp;-entry doesn’t, it’s the same as
<code class="docutils literal notranslate"><span class="pre">(&lt;&gt;</span> <span class="pre">-1</span> <span class="pre">1)</span></code>, which produces <code class="docutils literal notranslate"><span class="pre">-1</span></code>.</p>
<p>For example, we want to put tags with “file” kind below other tags, then the
sorter would look like:</p>
<div class="highlight-lisp notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="nv">&lt;&gt;</span> <span class="p">(</span><span class="k">if</span> <span class="p">(</span><span class="nv">eq?</span> <span class="nv">$kind</span> <span class="s">&quot;file&quot;</span><span class="p">)</span> <span class="mi">1</span> <span class="mi">-1</span><span class="p">)</span>
    <span class="p">(</span><span class="k">if</span> <span class="p">(</span><span class="nv">eq?</span> <span class="nv">&amp;kind</span> <span class="s">&quot;file&quot;</span><span class="p">)</span> <span class="mi">1</span> <span class="mi">-1</span><span class="p">))</span>
</pre></div>
</div>
<p>A quick read tells us: If $-entry has “file” kind, and &amp;-entry doesn’t, the
sorter becomes <code class="docutils literal notranslate"><span class="pre">(&lt;&gt;</span> <span class="pre">1</span> <span class="pre">-1)</span></code>, which produces <code class="docutils literal notranslate"><span class="pre">1</span></code>, so the $-entry is put below
the &amp;-entry, exactly what we want.</p>
</section>
<section id="inspecting-the-behavior-of-expressions">
<h3>Inspecting the Behavior of Expressions<a class="headerlink" href="#inspecting-the-behavior-of-expressions" title="Permalink to this headline"></a></h3>
<p>The <cite>print</cite> operator can be used to print the value of an expression. For
example:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -Q <span class="s1">&#39;(print $name)&#39;</span> -l
</pre></div>
</div>
<p>prints the name of each tag entry before it. Since the return value of
<code class="docutils literal notranslate"><span class="pre">print</span></code> is not #f, all the tag entries are printed. We could control this
using the <code class="docutils literal notranslate"><span class="pre">begin</span></code> or <code class="docutils literal notranslate"><span class="pre">begin0</span></code> operator. <code class="docutils literal notranslate"><span class="pre">begin</span></code> returns the value of its
last argument, and <code class="docutils literal notranslate"><span class="pre">begin0</span></code> returns the value of its first argument. For
example:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>readtags -Q <span class="s1">&#39;(begin0 #f (print (prefix? &quot;ctags&quot; &quot;ct&quot;)))&#39;</span> -l
</pre></div>
</div>
<p>prints a bunch of “#t” (depending on how many lines are in the tags file), and
the actual tag entries are not printed.</p>
</section>
</section>
<section id="see-also">
<h2>SEE ALSO<a class="headerlink" href="#see-also" title="Permalink to this headline"></a></h2>
<p>See <a class="reference internal" href="tags.5.html#tags-5"><span class="std std-ref">tags(5)</span></a> for the details of tags file format.</p>
<p>See <a class="reference internal" href="ctags-client-tools.7.html#ctags-client-tools-7"><span class="std std-ref">ctags-client-tools(7)</span></a> for the tips writing a
tool utilizing tags file.</p>
<p>The official Universal Ctags web site at:</p>
<p><a class="reference external" href="https://ctags.io/">https://ctags.io/</a></p>
<p>The git repository for the library used in readtags command:</p>
<p><a class="reference external" href="https://github.com/universal-ctags/libreadtags">https://github.com/universal-ctags/libreadtags</a></p>
</section>
<section id="credits">
<h2>CREDITS<a class="headerlink" href="#credits" title="Permalink to this headline"></a></h2>
<p>Universal Ctags project
<a class="reference external" href="https://ctags.io/">https://ctags.io/</a></p>
<p>Darren Hiebert &lt;<a class="reference external" href="mailto:dhiebert&#37;&#52;&#48;users&#46;sourceforge&#46;net">dhiebert<span>&#64;</span>users<span>&#46;</span>sourceforge<span>&#46;</span>net</a>&gt;
<a class="reference external" href="http://DarrenHiebert.com/">http://DarrenHiebert.com/</a></p>
<p>The readtags command and libreadtags maintained at Universal Ctags
are derived from readtags.c and readtags.h developd at
<a class="reference external" href="http://ctags.sourceforge.net">http://ctags.sourceforge.net</a>.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">readtags</a><ul>
<li><a class="reference internal" href="#synopsis">SYNOPSIS</a></li>
<li><a class="reference internal" href="#description">DESCRIPTION</a></li>
<li><a class="reference internal" href="#actions">ACTIONS</a></li>
<li><a class="reference internal" href="#options">OPTIONS</a><ul>
<li><a class="reference internal" href="#controlling-the-tags-reading-behavior">Controlling the Tags Reading Behavior</a></li>
<li><a class="reference internal" href="#controlling-the-name-action-behavior">Controlling the NAME Action Behavior</a></li>
<li><a class="reference internal" href="#controlling-the-output">Controlling the Output</a></li>
<li><a class="reference internal" href="#filtering-and-sorting">Filtering and Sorting</a></li>
<li><a class="reference internal" href="#examples">Examples</a></li>
</ul>
</li>
<li><a class="reference internal" href="#expression">EXPRESSION</a><ul>
<li><a class="reference internal" href="#filtering">Filtering</a></li>
<li><a class="reference internal" href="#sorting">Sorting</a></li>
<li><a class="reference internal" href="#inspecting-the-behavior-of-expressions">Inspecting the Behavior of Expressions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#see-also">SEE ALSO</a></li>
<li><a class="reference internal" href="#credits">CREDITS</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="ctags-incompatibilities.7.html"
                        title="previous chapter">ctags-incompatibilities</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../parsers.html"
                        title="next chapter">Parsers</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../parsers.html" title="Parsers"
             >next</a> |</li>
        <li class="right" >
          <a href="ctags-incompatibilities.7.html" title="ctags-incompatibilities"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">Universal Ctags 0.3.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../man-pages.html" >Man pages</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">readtags</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2015, Universal Ctags Team.
      Last updated on 11 Jun 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.0.2.
    </div>
  </body>
</html>