1830ca2cbSMasatake YAMATO.. _readtags(1): 2830ca2cbSMasatake YAMATO 3830ca2cbSMasatake YAMATO============================================================== 4830ca2cbSMasatake YAMATOreadtags 5830ca2cbSMasatake YAMATO============================================================== 6830ca2cbSMasatake YAMATO-------------------------------------------------------------- 7830ca2cbSMasatake YAMATOFind tag file entries matching specified names 8830ca2cbSMasatake YAMATO-------------------------------------------------------------- 9830ca2cbSMasatake YAMATO:Version: @VERSION@ 10dccba5efSHiroo HAYASHI:Manual group: Universal Ctags 11830ca2cbSMasatake YAMATO:Manual section: 1 12830ca2cbSMasatake YAMATO 13830ca2cbSMasatake YAMATOSYNOPSIS 14830ca2cbSMasatake YAMATO-------- 15830ca2cbSMasatake YAMATO| **readtags** -h | --help 16*7ba043c2SMasatake YAMATO| **readtags** (-H | --help-expression) (filter|sorter|formatter) 17830ca2cbSMasatake YAMATO| **readtags** [OPTION]... ACTION 18830ca2cbSMasatake YAMATO 19830ca2cbSMasatake YAMATODESCRIPTION 20830ca2cbSMasatake YAMATO----------- 2105e44848SAmaiKinonoThe **readtags** program filters, sorts and prints tag entries in a tags file. 2205e44848SAmaiKinonoThe basic filtering is done using **actions**, by which you can list all 2305e44848SAmaiKinonoregular tags, pseudo tags or regular tags matching specific name. Then, further 24*7ba043c2SMasatake YAMATOfiltering, sorting, and formatting can be done using **post processors**, namely 25*7ba043c2SMasatake YAMATO**filter expressions**, **sorter expressions**, and **formatter expressions**. 26830ca2cbSMasatake YAMATO 27830ca2cbSMasatake YAMATOACTIONS 28830ca2cbSMasatake YAMATO------- 2905e44848SAmaiKinono``-l``, ``--list`` 30830ca2cbSMasatake YAMATO List regular tags. 31830ca2cbSMasatake YAMATO 32830ca2cbSMasatake YAMATO``[-] NAME`` 33830ca2cbSMasatake YAMATO List regular tags matching NAME. 34830ca2cbSMasatake YAMATO "-" as NAME indicates arguments after this as NAME even if they start with -. 35830ca2cbSMasatake YAMATO 3605e44848SAmaiKinono``-D``, ``--list-pseudo-tags`` 37830ca2cbSMasatake YAMATO Equivalent to ``--list-pseudo-tags``. 38830ca2cbSMasatake YAMATO 39830ca2cbSMasatake YAMATOOPTIONS 40830ca2cbSMasatake YAMATO------- 41830ca2cbSMasatake YAMATO 4205e44848SAmaiKinonoControlling the Tags Reading Behavior 4305e44848SAmaiKinono~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4405e44848SAmaiKinonoThe behavior of reading tags can be controlled using these options: 4505e44848SAmaiKinono 4605e44848SAmaiKinono``-t TAGFILE``, ``--tag-file TAGFILE`` 4705e44848SAmaiKinono Use specified tag file (default: "tags"). 48f75fdf3eSMasatake YAMATO Giving "-" as TAGFILE indicates reading the tags file content from the 49f75fdf3eSMasatake YAMATO standard input. "-" can make the command line simpler. However, 50f75fdf3eSMasatake YAMATO it doesn't mean efficient; readtags stores the data to a temorary 51f75fdf3eSMasatake YAMATO file and reads that file for taking the ACTION. 5205e44848SAmaiKinono 5305e44848SAmaiKinono``-s[0|1|2]``, ``--override-sort-detection METHOD`` 5405e44848SAmaiKinono Override sort detection of tag file. 5505e44848SAmaiKinono METHOD: unsorted|sorted|foldcase 5605e44848SAmaiKinono 5705e44848SAmaiKinonoThe NAME action will perform binary search on sorted (including "foldcase") 5805e44848SAmaiKinonotags files, which is much faster then on unsorted tags files. 5905e44848SAmaiKinono 6005e44848SAmaiKinonoControlling the NAME Action Behavior 6105e44848SAmaiKinono~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6205e44848SAmaiKinonoThe behavior of the NAME action can be controlled using these options: 6305e44848SAmaiKinono 6405e44848SAmaiKinono``-i``, ``--icase-match`` 6505e44848SAmaiKinono Perform case-insensitive matching in the NAME action. 6605e44848SAmaiKinono 6705e44848SAmaiKinono``-p``, ``--prefix-match`` 6805e44848SAmaiKinono Perform prefix matching in the NAME action. 6905e44848SAmaiKinono 7005e44848SAmaiKinonoControlling the Output 7105e44848SAmaiKinono~~~~~~~~~~~~~~~~~~~~~~ 7205e44848SAmaiKinonoBy default, the output of readtags contains only the name, input and pattern 7305e44848SAmaiKinonofield. The Output can be tweaked using these options: 7405e44848SAmaiKinono 7505e44848SAmaiKinono``-d``, ``--debug`` 7605e44848SAmaiKinono Turn on debugging output. 7705e44848SAmaiKinono 7805e44848SAmaiKinono``-E``, ``--escape-output`` 7905e44848SAmaiKinono Escape characters like tabs in output as described in tags(5). 8005e44848SAmaiKinono 8105e44848SAmaiKinono``-e``, ``--extension-fields`` 8205e44848SAmaiKinono Include extension fields in output. 8305e44848SAmaiKinono 8405e44848SAmaiKinono``-n``, ``--line-number`` 8505e44848SAmaiKinono Also include the line number field when ``-e`` option is give. 8605e44848SAmaiKinono 8705e44848SAmaiKinonoAbout the ``-E`` option: certain characters are escaped in a tags file, to make 8805e44848SAmaiKinonoit machine-readable. e.g., ensuring no tabs character appear in fields other 8905e44848SAmaiKinonothan the pattern field. By default, readtags translates them to make it 9005e44848SAmaiKinonohuman-readable, but when utilizing readtags output in a script or a client 9105e44848SAmaiKinonotool, ``-E`` option should be used. See ctags-client-tools(7) for more 9205e44848SAmaiKinonodiscussion on this. 9305e44848SAmaiKinono 94*7ba043c2SMasatake YAMATOFiltering, Sorting, and Formatting 95*7ba043c2SMasatake YAMATO~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 96*7ba043c2SMasatake YAMATOFurther filtering, sorting, and formatting on the tags listed by actions 97*7ba043c2SMasatake YAMATOare performed using: 9805e44848SAmaiKinono 9905e44848SAmaiKinono``-Q EXP``, ``--filter EXP`` 10005e44848SAmaiKinono Filter the tags listed by ACTION with EXP before printing. 10105e44848SAmaiKinono 10205e44848SAmaiKinono``-S EXP``, ``--sorter EXP`` 10305e44848SAmaiKinono Sort the tags listed by ACTION with EXP before printing. 10405e44848SAmaiKinono 105*7ba043c2SMasatake YAMATO``-F EXP``, ``--formatter EXP`` 106*7ba043c2SMasatake YAMATO Format the tags listed by ACTION with EXP when printing. 107*7ba043c2SMasatake YAMATO 10805e44848SAmaiKinonoThese are discussed in the `EXPRESSION`_ section. 10905e44848SAmaiKinono 11005e44848SAmaiKinonoExamples 11105e44848SAmaiKinono~~~~~~~~ 11205e44848SAmaiKinono* List all tags in "/path/to/tags": 11305e44848SAmaiKinono 11405e44848SAmaiKinono .. code-block:: console 11505e44848SAmaiKinono 11605e44848SAmaiKinono $ readtags -t /path/to/tags -l 11705e44848SAmaiKinono 118f9be059bSMasatake YAMATO* List all tags in "tags" that start with "mymethod": 11905e44848SAmaiKinono 12005e44848SAmaiKinono .. code-block:: console 12105e44848SAmaiKinono 1228d6b7698SMasatake YAMATO $ readtags -p - mymethod 12305e44848SAmaiKinono 1248d6b7698SMasatake YAMATO* List all tags matching "mymethod", case insensitively: 12505e44848SAmaiKinono 12605e44848SAmaiKinono .. code-block:: console 12705e44848SAmaiKinono 1288d6b7698SMasatake YAMATO $ readtags -i - mymethod 12905e44848SAmaiKinono 1308d6b7698SMasatake YAMATO* List all tags start with "myvar", and printing all fields (i.e., the whole line): 13105e44848SAmaiKinono 13205e44848SAmaiKinono .. code-block:: console 13305e44848SAmaiKinono 1348d6b7698SMasatake YAMATO $ readtags -p -ne - myvar 135830ca2cbSMasatake YAMATO 136830ca2cbSMasatake YAMATOEXPRESSION 137830ca2cbSMasatake YAMATO---------- 138*7ba043c2SMasatake YAMATOScheme-style expressions are used for the ``-Q``, ``-S``, and ``-F`` options. 139*7ba043c2SMasatake YAMATOFor those who doesn't know Scheme or Lisp, just remember: 140830ca2cbSMasatake YAMATO 14105e44848SAmaiKinono* A function call is wrapped in a pair of parenthesis. The first item in it is 14205e44848SAmaiKinono the function/operator name, the others are arguments. 14305e44848SAmaiKinono* Function calls can be nested. 14478621a0aSAmaiKinono* Missing values and boolean false are represented by ``#f``. ``#t`` and all 14578621a0aSAmaiKinono other values are considered to be true. 14605e44848SAmaiKinono 14705e44848SAmaiKinonoSo, ``(+ 1 (+ 2 3))`` means add 2 and 3 first, then add the result with 1. 14878621a0aSAmaiKinono``(and "string" 1 #t)`` means logical AND on ``"string"``, ``1`` and ``#t``, 14978621a0aSAmaiKinonoand the result is true since there is no ``#f``. 150830ca2cbSMasatake YAMATO 151830ca2cbSMasatake YAMATOFiltering 152830ca2cbSMasatake YAMATO~~~~~~~~~ 15378621a0aSAmaiKinonoThe tag entries that make the filter expression produces true value are printed 15478621a0aSAmaiKinonoby readtags. 155830ca2cbSMasatake YAMATO 15616cd3523SMasatake YAMATOThe basic operators for filtering are ``eq?``, ``prefix?``, ``suffix?``, 15716cd3523SMasatake YAMATO``substr?``, and ``#/PATTERN/``. Language common fields can be accessed using 15816cd3523SMasatake YAMATOvariables starting with ``$``, e.g., ``$language`` represents the language field. 15916cd3523SMasatake YAMATOFor example: 16005e44848SAmaiKinono 1618d6b7698SMasatake YAMATO* List all tags start with "myfunc" in Python code files: 16205e44848SAmaiKinono 16305e44848SAmaiKinono .. code-block:: console 16405e44848SAmaiKinono 1658d6b7698SMasatake YAMATO $ readtags -p -Q '(eq? $language "Python")' - myfunc 16605e44848SAmaiKinono 16705e44848SAmaiKinono``downcase`` or ``upcase`` operators can be used to perform case-insensitive 16805e44848SAmaiKinonomatching: 16905e44848SAmaiKinono 1708d6b7698SMasatake YAMATO* List all tags containing "my", case insensitively: 17105e44848SAmaiKinono 17205e44848SAmaiKinono .. code-block:: console 17305e44848SAmaiKinono 1748d6b7698SMasatake YAMATO $ readtags -Q '(substr? (downcase $name) "my")' -l 17505e44848SAmaiKinono 17605e44848SAmaiKinonoWe have logical operators like ``and``, ``or`` and ``not``. The value of a 17705e44848SAmaiKinonomissing field is #f, so we could deal with missing fields: 17805e44848SAmaiKinono 1798d6b7698SMasatake YAMATO* List all tags containing "impl" in Python code files, but allow the 18005e44848SAmaiKinono ``language:`` field to be missing: 18105e44848SAmaiKinono 18205e44848SAmaiKinono .. code-block:: console 18305e44848SAmaiKinono 1848d6b7698SMasatake YAMATO $ readtags -Q '(and (substr? $name "impl")\ 18578621a0aSAmaiKinono (or (not $language)\ 18678621a0aSAmaiKinono (eq? $language "Python")))' -l 18705e44848SAmaiKinono 18878621a0aSAmaiKinono``#/PATTERN/`` is for the case when string predicates (``prefix?``, ``suffix?``, 18934824c05SMasatake YAMATOand ``substr?``) are not enough. You can use "Posix extended regular expression" 19034824c05SMasatake YAMATOas PATTERN. 19105e44848SAmaiKinono 19205e44848SAmaiKinono* List all tags inherits from the class "A": 19305e44848SAmaiKinono 19405e44848SAmaiKinono .. code-block:: console 19505e44848SAmaiKinono 19678621a0aSAmaiKinono $ readtags -Q '(#/(^|,) ?A(,|$)/ $inherits)' -l 19705e44848SAmaiKinono 19878621a0aSAmaiKinonoHere ``$inherits`` is a comma-separated class list like "A,B,C", "P, A, Q", or 19978621a0aSAmaiKinonojust "A". Notice that this filter works on both situations where there's a 20078621a0aSAmaiKinonospace after each comma or there's not. 20178621a0aSAmaiKinono 20278621a0aSAmaiKinonoCase-insensitive matching can be performed by ``#/PATTERN/i``: 20378621a0aSAmaiKinono 20478621a0aSAmaiKinono* List all tags inherits from the class "A" or "a": 20578621a0aSAmaiKinono 20678621a0aSAmaiKinono .. code-block:: console 20778621a0aSAmaiKinono 20878621a0aSAmaiKinono $ readtags -Q '(#/(^|,) ?A(,|$)/i $inherits)' -l 20978621a0aSAmaiKinono 21078621a0aSAmaiKinonoTo include "/" in a pattern, prefix ``\`` to the "/". 21178621a0aSAmaiKinono 21278621a0aSAmaiKinonoNOTE: The above regular expression pattern for inspecting inheritances is just 21378621a0aSAmaiKinonoan example to show how to use ``#/PATTERN/`` expression. Tags file generators 21478621a0aSAmaiKinonohave no consensus about the format of ``inherits:``, e.g., whether there should 21578621a0aSAmaiKinonobe a space after a comma. Even parsers in ctags have no consensus. Noticing the 21678621a0aSAmaiKinonoformat of the ``inherits:`` field of specific languages is needed for such 21778621a0aSAmaiKinonoqueries. 21878621a0aSAmaiKinono 21978621a0aSAmaiKinonoThe expressions ``#/PATTERN/`` and ``#/PATTERN/i`` are for interactive use. 22078621a0aSAmaiKinonoReadtags also offers an alias ``string->regexp``, so ``#/PATTERN/`` is equal to 22178621a0aSAmaiKinono``(string->regexp "PATTERN")``, and ``#/PATTERN/i`` is equal to 22278621a0aSAmaiKinono``(string->regexp "PATTERN" :case-fold #t)``. ``string->regexp`` doesn't need 22378621a0aSAmaiKinonoto prefix ``\`` for including "/" in a pattern. ``string->regexp`` may simplify 22478621a0aSAmaiKinonoa client tool building an expression. See also ctags-client-tools(7) for 22578621a0aSAmaiKinonobuilding expressions in your tool. 22678621a0aSAmaiKinono 22778621a0aSAmaiKinonoLet's now consider missing fields. The tags file may have tag entries that has 22878621a0aSAmaiKinonono ``inherits:`` field. In that case ``$inherits`` is #f, and the regular 22978621a0aSAmaiKinonoexpression matching raises an error, since string operators only work for 23078621a0aSAmaiKinonostrings. To avoid this problem: 23116cd3523SMasatake YAMATO 23216cd3523SMasatake YAMATO* Safely list all tags inherits from the class "A": 23316cd3523SMasatake YAMATO 23416cd3523SMasatake YAMATO .. code-block:: console 23516cd3523SMasatake YAMATO 23678621a0aSAmaiKinono $ readtags -Q '(and $inherits (#/(^|,) ?A(,|$)/ $inherits))' -l 23716cd3523SMasatake YAMATO 23878621a0aSAmaiKinonoThis makes sure ``$inherits`` is not missing first, then match it by regexp. 23916cd3523SMasatake YAMATO 24078621a0aSAmaiKinonoSometimes you want to keep tags where the field *is* missing. For example, your 24178621a0aSAmaiKinonowant to exclude reference tags, which is marked by the ``extras:`` field, then 24278621a0aSAmaiKinonoyou want to keep tags who doesn't have ``extras:`` field since they are also 24378621a0aSAmaiKinononot reference tags. Here's how to do it: 24464f8aa85SMasatake YAMATO 24578621a0aSAmaiKinono* List all tags but the reference tags: 24616cd3523SMasatake YAMATO 24716cd3523SMasatake YAMATO .. code-block:: console 24816cd3523SMasatake YAMATO 24978621a0aSAmaiKinono $ readtags -Q '(or (not $extras) (#/(^|,) ?reference(,|$)/ $extras))' -l 25005e44848SAmaiKinono 25178621a0aSAmaiKinonoNotice that ``(not $extras)`` produces ``#t`` when ``$extras`` is missing, so 25278621a0aSAmaiKinonothe whole ``or`` expression produces ``#t``. 25364f8aa85SMasatake YAMATO 254f75fdf3eSMasatake YAMATO 255f75fdf3eSMasatake YAMATOThe combination of ``ctags -o -`` and ``readtags -t -`` is handy for inspecting 256f75fdf3eSMasatake YAMATOa source file as far as the source file is enough short. 257f75fdf3eSMasatake YAMATO 258f75fdf3eSMasatake YAMATO* List all the large (> 100 lines) functions in a file: 259f75fdf3eSMasatake YAMATO 260f75fdf3eSMasatake YAMATO .. code-block:: console 261f75fdf3eSMasatake YAMATO 262f75fdf3eSMasatake YAMATO $ ctags -o - --fields=+neKz input.c \ 263f75fdf3eSMasatake YAMATO | ./readtags -t - -en \ 264f75fdf3eSMasatake YAMATO -Q '(and (eq? $kind "function") $end $line (> (- $end $line) 100))' \ 265f75fdf3eSMasatake YAMATO -l 266f75fdf3eSMasatake YAMATO 267f75fdf3eSMasatake YAMATO* List all the tags including line 80 in a file: 268f75fdf3eSMasatake YAMATO 269f75fdf3eSMasatake YAMATO .. code-block:: console 270f75fdf3eSMasatake YAMATO 271f75fdf3eSMasatake YAMATO $ ctags -o - --fields=+neKz input.c \ 272f75fdf3eSMasatake YAMATO | readtags -t - -ne \ 273f75fdf3eSMasatake YAMATO -Q '(and $line 274f75fdf3eSMasatake YAMATO (or (eq? $line 80) 275f75fdf3eSMasatake YAMATO (and $end (< $line 80) (< 80 $end))))' \ 276f75fdf3eSMasatake YAMATO -l 277f75fdf3eSMasatake YAMATO 27864f8aa85SMasatake YAMATORun "readtags -H filter" to know about all valid functions and variables. 27964f8aa85SMasatake YAMATO 280830ca2cbSMasatake YAMATOSorting 281830ca2cbSMasatake YAMATO~~~~~~~ 28205e44848SAmaiKinonoWhen sorting, the sorter expression is evaluated on two tag entries to decide 28305e44848SAmaiKinonowhich should sort before the other one, until the order of all tag entries is 28405e44848SAmaiKinonodecided. 285830ca2cbSMasatake YAMATO 28605e44848SAmaiKinonoIn a sorter expression, ``$`` and ``&`` are used to access the fields in the 28705e44848SAmaiKinonotwo tag entries, and let's call them $-entry and &-entry. The sorter expression 28878621a0aSAmaiKinonoshould have a value of -1, 0 or 1. The value -1 means the $-entry should be put 28978621a0aSAmaiKinonoabove the &-entry, 1 means the contrary, and 0 makes their order in the output 29005e44848SAmaiKinonouncertain. 29105e44848SAmaiKinono 29205e44848SAmaiKinonoThe core operator of sorting is ``<>``. It's used to compare two strings or two 29305e44848SAmaiKinononumbers (numbers are for the ``line:`` or ``end:`` fields). In ``(<> a b)``, if 29405e44848SAmaiKinono``a`` < ``b``, the result is -1; ``a`` > ``b`` produces 1, and ``a`` = ``b`` 29505e44848SAmaiKinonoproduces 0. Strings are compared using the ``strcmp`` function, see strcmp(3). 29605e44848SAmaiKinono 29705e44848SAmaiKinonoFor example, sort by names, and make those shorter or alphabetically smaller 29805e44848SAmaiKinonoones appear before the others: 29905e44848SAmaiKinono 30005e44848SAmaiKinono.. code-block:: console 30105e44848SAmaiKinono 30205e44848SAmaiKinono $ readtags -S '(<> $name &name)' -l 30305e44848SAmaiKinono 30405e44848SAmaiKinonoThis reads "If the tag name in the $-entry is smaller, it goes before the 30505e44848SAmaiKinono&-entry". 30605e44848SAmaiKinono 30705e44848SAmaiKinonoThe ``<or>`` operator is used to chain multiple expressions until one returns 30878621a0aSAmaiKinono-1 or 1. For example, sort by input file names, then line numbers if in the 30978621a0aSAmaiKinonosame file: 31005e44848SAmaiKinono 31105e44848SAmaiKinono.. code-block:: console 31205e44848SAmaiKinono 31305e44848SAmaiKinono $ readtags -S '(<or> (<> $input &input) (<> $line &line))' -l 31405e44848SAmaiKinono 31505e44848SAmaiKinonoThe ``*-`` operator is used to flip the compare result. i.e., ``(*- (<> a b))`` 31605e44848SAmaiKinonois the same as ``(<> b a)``. 31705e44848SAmaiKinono 31878621a0aSAmaiKinonoFilter expressions can be used in sorter expressions. The technique is use 31978621a0aSAmaiKinono``if`` to produce integers that can be compared based on the filter, like: 32078621a0aSAmaiKinono 32178621a0aSAmaiKinono.. code-block:: lisp 32278621a0aSAmaiKinono 32378621a0aSAmaiKinono (<> (if filter-expr-on-$-entry -1 1) 32478621a0aSAmaiKinono (if filter-expr-on-&-entry -1 1)) 32578621a0aSAmaiKinono 32678621a0aSAmaiKinonoSo if $-entry satisfies the filter, while &-entry doesn't, it's the same as 32778621a0aSAmaiKinono``(<> -1 1)``, which produces ``-1``. 32878621a0aSAmaiKinono 32978621a0aSAmaiKinonoFor example, we want to put tags with "file" kind below other tags, then the 33078621a0aSAmaiKinonosorter would look like: 33178621a0aSAmaiKinono 33278621a0aSAmaiKinono.. code-block:: lisp 33378621a0aSAmaiKinono 33478621a0aSAmaiKinono (<> (if (eq? $kind "file") 1 -1) 33578621a0aSAmaiKinono (if (eq? &kind "file") 1 -1)) 33678621a0aSAmaiKinono 33778621a0aSAmaiKinonoA quick read tells us: If $-entry has "file" kind, and &-entry doesn't, the 33878621a0aSAmaiKinonosorter becomes ``(<> 1 -1)``, which produces ``1``, so the $-entry is put below 33978621a0aSAmaiKinonothe &-entry, exactly what we want. 34078621a0aSAmaiKinono 341*7ba043c2SMasatake YAMATOFormatting 342*7ba043c2SMasatake YAMATO~~~~~~~~~~ 343*7ba043c2SMasatake YAMATOA formatter expression defines how readtags prints tag entries. 344*7ba043c2SMasatake YAMATO 345*7ba043c2SMasatake YAMATOA formatter expression may produce a string, a boolean, an integer, 346*7ba043c2SMasatake YAMATOor a list. Readtags prints the produced string, and integer as is. 347*7ba043c2SMasatake YAMATOReadtags prints nothing for ``#f``, and a newline for ``#t``. 348*7ba043c2SMasatake YAMATO 349*7ba043c2SMasatake YAMATOA list could contain any number of strings, booleans, 350*7ba043c2SMasatake YAMATOintegers, and/or lists. Readtags prints the elements of a list 351*7ba043c2SMasatake YAMATOsequentially and recursively. 352*7ba043c2SMasatake YAMATO 353*7ba043c2SMasatake YAMATOAll the operators for filtering are also available in formatter 354*7ba043c2SMasatake YAMATOexpressions. In addition to the operators, ``list`` is available 355*7ba043c2SMasatake YAMATOin formatter expressions. As the name shows, ``list`` is for 356*7ba043c2SMasatake YAMATOmaking a list. ``list`` makes a list containing arguments passed to 357*7ba043c2SMasatake YAMATOthe operator. e.g., the following expression makes a list contains 358*7ba043c2SMasatake YAMATO``1``, ``#f``, and ``"hello"``: 359*7ba043c2SMasatake YAMATO 360*7ba043c2SMasatake YAMATO.. code-block:: lisp 361*7ba043c2SMasatake YAMATO 362*7ba043c2SMasatake YAMATO (list 1 #f "hello") 363*7ba043c2SMasatake YAMATO 364*7ba043c2SMasatake YAMATONOTE: Unlike real-Lisp, backquote constructs are not available. 365*7ba043c2SMasatake YAMATO 366*7ba043c2SMasatake YAMATOTo show some examples, the following tags file (``output.tags``) is assumed 367*7ba043c2SMasatake YAMATOas input for readtags: 368*7ba043c2SMasatake YAMATO 369*7ba043c2SMasatake YAMATO.. code-block:: tags 370*7ba043c2SMasatake YAMATO 371*7ba043c2SMasatake YAMATO M input.c 4;" macro file: 372*7ba043c2SMasatake YAMATO N input.c 3;" macro file: 373*7ba043c2SMasatake YAMATO bar input.c 11;" f typeref:typename:void file: signature:(char ** argv,int * r) 374*7ba043c2SMasatake YAMATO foo input.c 6;" f typeref:typename:int file: signature:(int v) 375*7ba043c2SMasatake YAMATO main input.c 16;" f typeref:typename:int signature:(int argc,char ** argv) 376*7ba043c2SMasatake YAMATO 377*7ba043c2SMasatake YAMATOAn exapmle for printing only function names: 378*7ba043c2SMasatake YAMATO 379*7ba043c2SMasatake YAMATO.. code-block:: console 380*7ba043c2SMasatake YAMATO 381*7ba043c2SMasatake YAMATO $ readtags -t output.tags -Q '(eq? $kind "function")' -F '(list $name #t)' -l 382*7ba043c2SMasatake YAMATO bar 383*7ba043c2SMasatake YAMATO foo 384*7ba043c2SMasatake YAMATO main 385*7ba043c2SMasatake YAMATO 386*7ba043c2SMasatake YAMATODoing the same only with a formatter expression: 387*7ba043c2SMasatake YAMATO 388*7ba043c2SMasatake YAMATO.. code-block:: console 389*7ba043c2SMasatake YAMATO 390*7ba043c2SMasatake YAMATO $ readtags -t output.tags -F '(if (eq? $kind "function") (list $name #t) #f)' -l 391*7ba043c2SMasatake YAMATO bar 392*7ba043c2SMasatake YAMATO foo 393*7ba043c2SMasatake YAMATO main 394*7ba043c2SMasatake YAMATO 395*7ba043c2SMasatake YAMATOGenerating declarations for the functions: 396*7ba043c2SMasatake YAMATO 397*7ba043c2SMasatake YAMATO.. code-block:: console 398*7ba043c2SMasatake YAMATO 399*7ba043c2SMasatake YAMATO $ readtags -t output.tags -F \ 400*7ba043c2SMasatake YAMATO '(if (eq? $kind "function") 401*7ba043c2SMasatake YAMATO (list (if $file "static " #f) $typeref-name " " $name $signature ";" #t) 402*7ba043c2SMasatake YAMATO #f)' -l 403*7ba043c2SMasatake YAMATO static void bar(char ** argv,int * r); 404*7ba043c2SMasatake YAMATO static int foo(int v); 405*7ba043c2SMasatake YAMATO int main(int argc,char ** argv); 406*7ba043c2SMasatake YAMATO 40705e44848SAmaiKinonoInspecting the Behavior of Expressions 40805e44848SAmaiKinono~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 40905e44848SAmaiKinonoThe `print` operator can be used to print the value of an expression. For 41005e44848SAmaiKinonoexample: 41105e44848SAmaiKinono 41205e44848SAmaiKinono.. code-block:: console 41305e44848SAmaiKinono 41405e44848SAmaiKinono $ readtags -Q '(print $name)' -l 41505e44848SAmaiKinono 41605e44848SAmaiKinonoprints the name of each tag entry before it. Since the return value of 41705e44848SAmaiKinono``print`` is not #f, all the tag entries are printed. We could control this 41805e44848SAmaiKinonousing the ``begin`` or ``begin0`` operator. ``begin`` returns the value of its 41905e44848SAmaiKinonolast argument, and ``begin0`` returns the value of its first argument. For 42005e44848SAmaiKinonoexample: 42105e44848SAmaiKinono 42205e44848SAmaiKinono.. code-block:: console 42305e44848SAmaiKinono 42405e44848SAmaiKinono $ readtags -Q '(begin0 #f (print (prefix? "ctags" "ct")))' -l 42505e44848SAmaiKinono 42605e44848SAmaiKinonoprints a bunch of "#t" (depending on how many lines are in the tags file), and 42705e44848SAmaiKinonothe actual tag entries are not printed. 428830ca2cbSMasatake YAMATO 429830ca2cbSMasatake YAMATOSEE ALSO 430830ca2cbSMasatake YAMATO-------- 431830ca2cbSMasatake YAMATOSee tags(5) for the details of tags file format. 432830ca2cbSMasatake YAMATO 433830ca2cbSMasatake YAMATOSee ctags-client-tools(7) for the tips writing a 434830ca2cbSMasatake YAMATOtool utilizing tags file. 435830ca2cbSMasatake YAMATO 436dccba5efSHiroo HAYASHIThe official Universal Ctags web site at: 437830ca2cbSMasatake YAMATO 438830ca2cbSMasatake YAMATOhttps://ctags.io/ 439830ca2cbSMasatake YAMATO 440830ca2cbSMasatake YAMATOThe git repository for the library used in readtags command: 441830ca2cbSMasatake YAMATO 442830ca2cbSMasatake YAMATOhttps://github.com/universal-ctags/libreadtags 443830ca2cbSMasatake YAMATO 444830ca2cbSMasatake YAMATOCREDITS 445830ca2cbSMasatake YAMATO------- 446dccba5efSHiroo HAYASHIUniversal Ctags project 447830ca2cbSMasatake YAMATOhttps://ctags.io/ 448830ca2cbSMasatake YAMATO 449830ca2cbSMasatake YAMATODarren Hiebert <dhiebert@users.sourceforge.net> 450830ca2cbSMasatake YAMATOhttp://DarrenHiebert.com/ 451830ca2cbSMasatake YAMATO 452dccba5efSHiroo HAYASHIThe readtags command and libreadtags maintained at Universal Ctags 453c71475d3SMasanari Iidaare derived from readtags.c and readtags.h developd at 454830ca2cbSMasatake YAMATOhttp://ctags.sourceforge.net. 455