Skip to content

Commit 5fab6e3

Browse files
committed
main: make ~/.ctags.d as the default element for the optlib path list
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 99c8ba9 commit 5fab6e3

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

docs/man/ctags.1.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ Option File Options
830830

831831
``--optlib-dir=[+]<directory>``
832832
Add an optlib *<directory>* to or reset the optlib path list.
833-
By default, the optlib path list is empty.
833+
See "`Default optlib path list`_" about the default elements for optlib path list.
834834

835835
optlib Options
836836
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2203,6 +2203,19 @@ Preloading option files
22032203

22042204
``*.ctags`` files in a directory are loaded in alphabetical order.
22052205

2206+
Default optlib path list
2207+
~~~~~~~~~~~~~~~~~~~~~~~~
2208+
2209+
``$XDG_CONFIG_HOME/ctags``, or ``$HOME/.config/ctags`` if
2210+
``$XDG_CONFIG_HOME`` is not defined
2211+
(on other than MS Windows)
2212+
2213+
``$HOME/.ctags.d``
2214+
2215+
``$HOMEDRIVE$HOMEPATH/ctags.d`` (on MS Windows only)
2216+
2217+
These directories are parts of the optlib path list by default.
2218+
See "`Option File Options`_" about the optlib path list.
22062219

22072220
SEE ALSO
22082221
--------

main/options.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3808,14 +3808,47 @@ extern void readOptionConfiguration (void)
38083808
parseConfigurationFileOptions ();
38093809
}
38103810

3811+
static stringList* optlibPathListNew(struct preloadPathElt *pathList)
3812+
{
3813+
stringList * appended = stringListNew ();
3814+
3815+
for (size_t i = 0; pathList[i].path != NULL || pathList[i].makePath != NULL; ++i)
3816+
{
3817+
struct preloadPathElt *elt = pathList + i;
3818+
preloadMakePathFunc maker = elt->makePath;
3819+
const char *path = elt->path;
3820+
3821+
if (!elt->isDirectory)
3822+
continue;
3823+
3824+
if (elt->stage == OptionLoadingStageCurrentDir)
3825+
continue;
3826+
3827+
if (maker)
3828+
path = maker(elt->path, elt->extra);
3829+
3830+
if (path == NULL)
3831+
continue;
3832+
3833+
vString *vpath;
3834+
if (path == elt->path)
3835+
vpath = vStringNewInit (path);
3836+
else
3837+
vpath = vStringNewOwn ((char *)path);
3838+
stringListAdd(appended, vpath);
3839+
}
3840+
3841+
return appended;
3842+
}
3843+
38113844
/*
38123845
* Option initialization
38133846
*/
38143847

38153848
extern void initOptions (void)
38163849
{
38173850
OptionFiles = stringListNew ();
3818-
OptlibPathList = stringListNew ();
3851+
OptlibPathList = optlibPathListNew (preload_path_list);
38193852

38203853
verbose ("Setting option defaults\n");
38213854
installHeaderListDefaults ();

man/ctags.1.rst.in

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ Option File Options
830830

831831
``--optlib-dir=[+]<directory>``
832832
Add an optlib *<directory>* to or reset the optlib path list.
833-
By default, the optlib path list is empty.
833+
See "`Default optlib path list`_" about the default elements for optlib path list.
834834

835835
optlib Options
836836
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2203,6 +2203,19 @@ Preloading option files
22032203

22042204
``*.ctags`` files in a directory are loaded in alphabetical order.
22052205

2206+
Default optlib path list
2207+
~~~~~~~~~~~~~~~~~~~~~~~~
2208+
2209+
``$XDG_CONFIG_HOME/ctags``, or ``$HOME/.config/ctags`` if
2210+
``$XDG_CONFIG_HOME`` is not defined
2211+
(on other than MS Windows)
2212+
2213+
``$HOME/.ctags.d``
2214+
2215+
``$HOMEDRIVE$HOMEPATH/ctags.d`` (on MS Windows only)
2216+
2217+
These directories are parts of the optlib path list by default.
2218+
See "`Option File Options`_" about the optlib path list.
22062219

22072220
SEE ALSO
22082221
--------

0 commit comments

Comments
 (0)