1d66e81edSHiroo HAYASHI.. _option_files: 2d66e81edSHiroo HAYASHI 3d66e81edSHiroo HAYASHIOption files 4d66e81edSHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5d66e81edSHiroo HAYASHI.. Q: shouldn't the section about option files (preload especially) go in 6d66e81edSHiroo HAYASHI their own section somewhere else in the docs? They're not specifically 7d66e81edSHiroo HAYASHI for "Extending ctags" - they can be used for any command options that 8d66e81edSHiroo HAYASHI you want to use permanently. It's really the new language parsers using 9d66e81edSHiroo HAYASHI --regex-<LANG> and such that are about "Extending ctags", no? 10d66e81edSHiroo HAYASHI 11d66e81edSHiroo HAYASHIAn "option file" is a file in which command line options are written line 12d66e81edSHiroo HAYASHIby line. ``ctags`` loads it and runs as if the options in the file were 13d66e81edSHiroo HAYASHIpassed through command line. 14d66e81edSHiroo HAYASHI 15d66e81edSHiroo HAYASHIThe following file is an example of an option file: 16d66e81edSHiroo HAYASHI 17*d14dd918SMasatake YAMATO.. code-block:: ctags 18d66e81edSHiroo HAYASHI 19d66e81edSHiroo HAYASHI # Exclude directories that don't contain real code 20d66e81edSHiroo HAYASHI --exclude=Units 21d66e81edSHiroo HAYASHI # indentation is ignored 22d66e81edSHiroo HAYASHI --exclude=tinst-root 23d66e81edSHiroo HAYASHI --exclude=Tmain 24d66e81edSHiroo HAYASHI 25d66e81edSHiroo HAYASHIThe character `#` can be used as a start marker of a line comment. 26d66e81edSHiroo HAYASHIWhitespaces at the start of lines are ignored during loading. 27d66e81edSHiroo HAYASHI 28d66e81edSHiroo HAYASHIAnd it works exactly as if we had called: 29d66e81edSHiroo HAYASHI 30d66e81edSHiroo HAYASHI.. code-block:: sh 31d66e81edSHiroo HAYASHI 32d66e81edSHiroo HAYASHI ctags --exclude=Units --exclude=tinst-root --exclude=Tmain 33d66e81edSHiroo HAYASHI 34fbd3e0daSHiroo HAYASHIOrder of loading option files 35d66e81edSHiroo HAYASHI...................................................................... 36d66e81edSHiroo HAYASHI 37fbd3e0daSHiroo HAYASHIOption files are loaded by ``ctags`` automatically at start-up time. 38fbd3e0daSHiroo HAYASHI 39fbd3e0daSHiroo HAYASHIWhich files are loaded at start-up time are very different from Exuberant Ctags. 406be65883SHiroo HAYASHISee :ref:`option-file_difference` for the differences and their intentions. 41d66e81edSHiroo HAYASHI 42fbd3e0daSHiroo HAYASHIAt start-up time, ``ctags`` loads files having :file:`.ctags` as a 43d66e81edSHiroo HAYASHIfile extension under the following statically defined directories: 44d66e81edSHiroo HAYASHI 45fbd3e0daSHiroo HAYASHI#. :file:`$XDG_CONFIG_HOME/ctags/`, or :file:`$HOME/.config/ctags/` if :file:`$XDG_CONFIG_HOME` is not defined (on other than Windows) 46d66e81edSHiroo HAYASHI#. :file:`$HOME/.ctags.d/` 47fbd3e0daSHiroo HAYASHI#. :file:`$HOMEDRIVE$HOMEPATH/ctags.d/` (on Windows) 48d66e81edSHiroo HAYASHI#. :file:`./.ctags.d/` 49d66e81edSHiroo HAYASHI#. :file:`./ctags.d/` 50d66e81edSHiroo HAYASHI 51d66e81edSHiroo HAYASHI``ctags`` visits the directories in the order listed above for preloading files. 52d66e81edSHiroo HAYASHI``ctags`` loads files having :file:`.ctags` as file extension in alphabetical 53fbd3e0daSHiroo HAYASHIorder (``strcmp(3)`` is used for comparing, so for example 54d66e81edSHiroo HAYASHI:file:`.ctags.d/ZZZ.ctags` will be loaded *before* :file:`.ctags.d/aaa.ctags` in an ordinary locale). 55d66e81edSHiroo HAYASHI 56fbd3e0daSHiroo HAYASHIIf a option file includes ``--options=PATHNAME`` option, specified files are 57fbd3e0daSHiroo HAYASHIloaded immediately as described in the next section. ``ctags`` load a option 58fbd3e0daSHiroo HAYASHIfile only once if it is specified multiple times. 59fbd3e0daSHiroo HAYASHI 60fbd3e0daSHiroo HAYASHIFinally if ``--options=PATHNAME`` option is specified on ``ctags`` command line, 61fbd3e0daSHiroo HAYASHIoption files specified are load. 62fbd3e0daSHiroo HAYASHI 63fbd3e0daSHiroo HAYASHI``--options=PATHNAME`` option 646be65883SHiroo HAYASHI...................................................................... 65fbd3e0daSHiroo HAYASHIExuberant Ctags also has the ``--options`` option, but you can only specify a 666be65883SHiroo HAYASHIsingle file to load. Universal Ctags extends the option in two aspects: 676be65883SHiroo HAYASHI 686be65883SHiroo HAYASHI- You can specify a directory, to load all the files in that directory. 696be65883SHiroo HAYASHI- You can specify a PATH list to look in. See next section for details. 706be65883SHiroo HAYASHI 716be65883SHiroo HAYASHISpecifying a directory 726be65883SHiroo HAYASHI,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 736be65883SHiroo HAYASHI 746be65883SHiroo HAYASHIIf you specify a directory instead of a file as the argument for the 75fbd3e0daSHiroo HAYASHI``--options=PATHNAME``, ``ctags`` will load all files having a 766be65883SHiroo HAYASHI:file:`.ctags` extension under said directory in alphabetical order. 776be65883SHiroo HAYASHI 786be65883SHiroo HAYASHISpecifying an optlib PATH list 796be65883SHiroo HAYASHI,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 806be65883SHiroo HAYASHI 81fbd3e0daSHiroo HAYASHIMuch like a command line shell, ``ctags`` has an *optlib PATH list* in which it 826be65883SHiroo HAYASHIcan look for a file (or directory) to load. 836be65883SHiroo HAYASHI 846be65883SHiroo HAYASHIWhen loading a file (or directory) specified with ``--options=PATHNAME``, 856be65883SHiroo HAYASHIctags first checks if ``PATHNAME`` is an absolute path or a relative path. 866be65883SHiroo HAYASHIAn absolute path starts with '``/``' or '``.``'. 876be65883SHiroo HAYASHIIf ``PATHNAME`` is an absolute path, ctags tries to load it immediately. 886be65883SHiroo HAYASHI 896be65883SHiroo HAYASHIIf, on the contrary, is a relative path, ``ctags`` does two things: First, 90fbd3e0daSHiroo HAYASHIlooks for the file (or directory) in *optlib PATH list* and tries to load it. 916be65883SHiroo HAYASHI 926be65883SHiroo HAYASHIIf the file doesn't exist in the PATH list, ``ctags`` treats ``PATHNAME`` as a 936be65883SHiroo HAYASHIpath relative to the working directory and loads the file. 946be65883SHiroo HAYASHI 95fbd3e0daSHiroo HAYASHIBy default, *optlib PATH list* is empty. To set or add a directory 966be65883SHiroo HAYASHIpath to the list, use ``--optlib-dir=PATH``. 976be65883SHiroo HAYASHI 986be65883SHiroo HAYASHIFor setting (adding one after clearing):: 996be65883SHiroo HAYASHI 1006be65883SHiroo HAYASHI --optlib-dir=PATH 1016be65883SHiroo HAYASHI 102fbd3e0daSHiroo HAYASHIFor adding on the beginning of the PATH list:: 1036be65883SHiroo HAYASHI 1046be65883SHiroo HAYASHI --optlib-dir=+PATH 1056be65883SHiroo HAYASHI 1066be65883SHiroo HAYASHITips for writing an option file 1076be65883SHiroo HAYASHI...................................................................... 1086be65883SHiroo HAYASHI 1096be65883SHiroo HAYASHI* Use ``--quiet --options=NONE`` to disable preloading. 1106be65883SHiroo HAYASHI 1116be65883SHiroo HAYASHI* ``--_echo=MSG`` and ``--_force-quit=[NUM]`` options are introduced for 1126be65883SHiroo HAYASHI debugging the process of loading option files. See "OPTIONS" 1136be65883SHiroo HAYASHI section of :ref:`ctags-optlib(7) <ctags-optlib(7)>`. 1146be65883SHiroo HAYASHI 1156be65883SHiroo HAYASHI* Universal Ctags has an ``optlib2c`` script that translates an option file 116e30940dcSHiroo HAYASHI into C source code. Your optlib parser can thus easily become a built-in parser. 117e30940dcSHiroo HAYASHI See :ref:`optlib2c` for details. 1186be65883SHiroo HAYASHI 1196be65883SHiroo HAYASHI.. _option-file_difference: 1206be65883SHiroo HAYASHI 1216be65883SHiroo HAYASHIDifference from Exuberant Ctags 1226be65883SHiroo HAYASHI...................................................................... 123d66e81edSHiroo HAYASHIQuoted from man page of Exuberant Ctags: 124d66e81edSHiroo HAYASHI 125d66e81edSHiroo HAYASHI FILES 126d66e81edSHiroo HAYASHI - /ctags.cnf (on MSDOS, MSWindows only) 127d66e81edSHiroo HAYASHI - /etc/ctags.conf 128d66e81edSHiroo HAYASHI - /usr/local/etc/ctags.conf 129d66e81edSHiroo HAYASHI - $HOME/.ctags 130d66e81edSHiroo HAYASHI - $HOME/ctags.cnf (on MSDOS, MSWindows only) 131d66e81edSHiroo HAYASHI - .ctags 132d66e81edSHiroo HAYASHI - ctags.cnf (on MSDOS, MSWindows only) 133d66e81edSHiroo HAYASHI 134d66e81edSHiroo HAYASHI If any of these configuration files exist, each will 135d66e81edSHiroo HAYASHI be expected to contain a set of default options 136d66e81edSHiroo HAYASHI which are read in the order listed when ctags 137d66e81edSHiroo HAYASHI starts, but before the CTAGS environment variable is 138d66e81edSHiroo HAYASHI read or any command line options are read. This 139d66e81edSHiroo HAYASHI makes it possible to set up site-wide, personal or 140d66e81edSHiroo HAYASHI project-level defaults. It is possible to compile 141d66e81edSHiroo HAYASHI ctags to read an additional configuration file 142d66e81edSHiroo HAYASHI before any of those shown above, which will be 143d66e81edSHiroo HAYASHI indicated if the output produced by the --version 144d66e81edSHiroo HAYASHI option lists the "custom-conf" feature. Options 145d66e81edSHiroo HAYASHI appearing in the CTAGS environment variable or on 146d66e81edSHiroo HAYASHI the command line will override options specified in 147d66e81edSHiroo HAYASHI these files. Only options will be read from these 148d66e81edSHiroo HAYASHI files. Note that the option files are read in 149d66e81edSHiroo HAYASHI line-oriented mode in which spaces are significant 150d66e81edSHiroo HAYASHI (since shell quoting is not possible). Each line of 151d66e81edSHiroo HAYASHI the file is read as one command line parameter (as 152d66e81edSHiroo HAYASHI if it were quoted with single quotes). Therefore, 153d66e81edSHiroo HAYASHI use new lines to indicate separate command-line 154d66e81edSHiroo HAYASHI arguments. 155d66e81edSHiroo HAYASHI 156d66e81edSHiroo HAYASHIWhat follows explains the differences and their intentions... 157d66e81edSHiroo HAYASHI 158d66e81edSHiroo HAYASHI 159d66e81edSHiroo HAYASHIDirectory oriented configuration management 160d66e81edSHiroo HAYASHI,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 161d66e81edSHiroo HAYASHI 162d66e81edSHiroo HAYASHIExuberant Ctags provides a way to customize ctags with options like 163d66e81edSHiroo HAYASHI``--langdef=<LANG>`` and ``--regex-<LANG>``. These options are 164d66e81edSHiroo HAYASHIpowerful and make ctags popular for programmers. 165d66e81edSHiroo HAYASHI 166d66e81edSHiroo HAYASHIUniversal Ctags extends this idea; we have added new options for 167d66e81edSHiroo HAYASHIdefining a parser, and have extended existing options. Defining 168d66e81edSHiroo HAYASHIa new parser with the options is more than "customizing" in 169d66e81edSHiroo HAYASHIUniversal Ctags. 170d66e81edSHiroo HAYASHI 171d66e81edSHiroo HAYASHITo make easier the maintenance a parser defined using the options, you can put 172d66e81edSHiroo HAYASHIeach language parser in a different options file. Universal Ctags doesn't 173d66e81edSHiroo HAYASHIpreload a single file. Instead, Universal Ctags loads all the files having the 174d66e81edSHiroo HAYASHI:file:`.ctags` extension under the previously specified directories. If you 175d66e81edSHiroo HAYASHIhave multiple parser definitions, put them in different files. 176d66e81edSHiroo HAYASHI 177d66e81edSHiroo HAYASHIAvoiding option incompatibility issues 178d66e81edSHiroo HAYASHI,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 179d66e81edSHiroo HAYASHI 180d66e81edSHiroo HAYASHIThe Universal Ctags options are different from those of Exuberant Ctags, 181d66e81edSHiroo HAYASHItherefore Universal Ctags doesn't load any of the files Exuberant Ctags loads at 182d66e81edSHiroo HAYASHIstart-up. Otherwise there would be incompatibility issues if Exuberant Ctags 183d66e81edSHiroo HAYASHIloaded an option file that used a newly introduced option in Universal Ctags, 184d66e81edSHiroo HAYASHIand vice versa. 185d66e81edSHiroo HAYASHI 186d66e81edSHiroo HAYASHINo system wide configuration 187d66e81edSHiroo HAYASHI,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 188d66e81edSHiroo HAYASHI 189d66e81edSHiroo HAYASHITo make the preload path list short and because it was rarely ever used, 190d66e81edSHiroo HAYASHIUniversal Ctags does not load any option files for system wide configuration. 191d66e81edSHiroo HAYASHI(i.e., no :file:`/etc/ctags.d`) 192d66e81edSHiroo HAYASHI 193d66e81edSHiroo HAYASHIUsing :file:`.ctags` for the file extension 194d66e81edSHiroo HAYASHI,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 195d66e81edSHiroo HAYASHI 196d66e81edSHiroo HAYASHIExtensions :file:`.cnf` and :file:`.conf` are obsolete. 197d66e81edSHiroo HAYASHIUse the unified extension :file:`.ctags` only. 198