Respect notmuch-config(1) FILES specs.#33
Respect notmuch-config(1) FILES specs.#33ferdinandyb wants to merge 1 commit intoaperezdc:masterfrom
Conversation
aperezdc
left a comment
There was a problem hiding this comment.
@ferdinandyb I agree that following the same steps as Notmuch to find the condiguration file would be great, thanks for looking into this. That being said, this patch needs a bit of work before we can merge it. I have written a couple of comments with some hints on how to continue.
Looking forward to an updated patch ⚒️
| else if(!notmuch_config_path_lookupvar) | ||
| config_path = g_strdup_printf ("%s/.notmuch-config", g_get_home_dir ()); | ||
| else if (g_getenv ("NOTMUCH_PROFILE")){ | ||
| if (g_getenv("XDG_CONFIG_HOME")){ |
There was a problem hiding this comment.
You should use g_get_user_config_dir() which will work even if the XDG_CONFIG_HOME environment variable is undefined. Then you don't need to check if g_getenv() returned a non-NULL value.
To check whether the file exists you can use g_file_new_build_filename() to calculate the path and create a GFile for it at the same time, then use g_file_query_exists(). Finally, if the file is present, its full path can be obtained with g_file_get_path().
| } | ||
| else | ||
| config_path = notmuch_config_path_lookupvar; | ||
| config_path = g_strdup_printf ("%s/.notmuch-config", g_get_home_dir ()); |
There was a problem hiding this comment.
I know the path was already being calculated in this way, but it would be better to use g_build_filename() instead:
| config_path = g_strdup_printf ("%s/.notmuch-config", g_get_home_dir ()); | |
| config_path = g_build_filename (g_get_home_dir (), ".notmuch-config", NULL); |
|
Thanks for the followup! It is indeed just half-done. Could you also check my question about the config override and the debug flag? |
8efabc7 to
569becc
Compare
My two cents:
|
|
perfect, I'll likely take a week or two to follow up |
WIP
Questions and comments:
--configsupersede any environment variables (the same as the notmuch command itself)$HOME/.notmuch-config. I did a quick search of how you do this in C, but as there are multiple ways and nothing really popped out as appropriate, what do you prefer for that? In the end I need a function that returns a true or false :)G_OPTION_ARG_NONEtype--debugflag which prints which config file / database is actually used in the end, or maybe at that point maybe the "check file exists" func could print each file it tries, otherwise I think it might get confusing if things don't work as expected.