|
From: Jun. T <tak...@kb...> - 2021-09-12 14:30:02
Attachments:
xdg.patch
|
I'm not a fan of XDG basedir, but moving only ~/.gnuplot to XDG
directory may be a kind of "half done".
Attached is a possible patch for moving ~/{.gnuplot_history,.gnuplot-wxt}
to XDG directories (it seems qtterminal.conf is already taken care of).
A few points to discuss:
[1] Where to save the history?
There were three possibilities $XDG_{CONFIG,DATA,CACHE}_HOME, and probably
DATA directory is most widely used for history (but I'm not sure).
But to make the situation still more complicated, they added one more
directory $XDG_STATE_HOME recently. It seems this directory is most
suitable for history, but it is new and very few programs are using it yet,
and I'm rather suspicious of whether many programs that are already using
DATA (or CACHE?) directory for history will modify their code.
(and XDG may add more basedirs to make it further complicated...)
In the attached patch I use the STATE directory,
but I have no objection to using other directories.
Since only one file (the history file) is saved in the directory, I think
we can save it directly under XDG ( ~/.local/state/gnuplot_history)
instead of saving it as ~/.local/state/gnuplot/history.
[2] Migration
With the patch, gnuplot will continue to use traditional config or history
files in ~/ if they exist (as it does for the main config file ~/.gnuplot).
Users must move the traditional files to XDG dirs (or remove ~/.gnuplot-wxt
and ~/.gnuplot_history) manually if they want to migrate.
We could make gnuplot to force move traditional ones to XDG directories, but
I rather hesitate to do this.
[3] wxWidgets
They added a function (wxStandardPaths::FileLayout()) for supporting XDG
basedir in wxWidgets 3.1.1.
https://docs.wxwidgets.org/3.1.5/classwx_standard_paths.html
But even if FileLayout is set to FileLayout_XDG, it seems I still need to set
the full pathname of the config flie manually in wxFileConfig constructor to
make it saved in $XDG_CONFIG_HOME/gnuplot/ (i.e., not directly under
$XDG_CONFIG_HOME/). So I didn't use wxStandardPaths but used xdg_get_var() in
xdg.c and manually set the full pathname of the config file.
Good thing of this is it works with older wxWidgets (3.1.x is a kind of
development release).
I'm not familiar with wxWidgets. If there are anyone who knows wxWidgets better
please feel free to improve the patch.
[4] Documents
Are there any documents that need be updated?
|
|
From: Ethan A M. <me...@uw...> - 2021-09-13 19:24:04
|
On Sunday, 12 September 2021 07:29:51 PDT Jun. T wrote:
> I'm not a fan of XDG basedir, but moving only ~/.gnuplot to XDG
> directory may be a kind of "half done".
I am not a fan either. Neither my home nor my lab machines use XDG
except for the KDE desktop itself, so I don't even have any examples
to look it from other user applications.
The one possible advantage I see, which isn't currently in place at all,
would be to use a XDG_CONFIG file to set the default gnuplot terminal
type. That way distros who provide separate x11/wxt/qt/dumb packages
for gnuplot installation could place a corresponding file in
/etc/xdg/gnuplot.config to set the appropriate system default.
Users could override this in $HOME/.config/gnuplotrc or whatever the
xdg convention is.
In any case I would prefer to minimize any references to XDG in the
core source code. I realize that the previous XDG patch already put a
chunk of code in plot.c to hande the gnuplotrc file, but wouldn't it
be better to have that code and the new patch code for the history file
live in xdg.c instead? Then in plot.c or history.c the call site would
be:
#ifdef USE_XDG_BASEDIR
expanded_history_filename = some_new_xdg_routine(GNUPLOT_HISTORY_FILE));
#endif
if (!expanded_history_filename) {
/* current code */
expanded_history_filename = tilde_expand(GNUPLOT_HISTORY_FILE);
}
read_history(expanded_history_filename);
> Attached is a possible patch for moving ~/{.gnuplot_history,.gnuplot-wxt}
> to XDG directories (it seems qtterminal.conf is already taken care of).
> A few points to discuss:
>
> [1] Where to save the history?
> There were three possibilities $XDG_{CONFIG,DATA,CACHE}_HOME, and probably
> DATA directory is most widely used for history (but I'm not sure).
> But to make the situation still more complicated, they added one more
> directory $XDG_STATE_HOME recently. It seems this directory is most
> suitable for history, but it is new and very few programs are using it yet,
> and I'm rather suspicious of whether many programs that are already using
> DATA (or CACHE?) directory for history will modify their code.
> (and XDG may add more basedirs to make it further complicated...)
>
> In the attached patch I use the STATE directory,
> but I have no objection to using other directories.
>
> Since only one file (the history file) is saved in the directory, I think
> we can save it directly under XDG ( ~/.local/state/gnuplot_history)
> instead of saving it as ~/.local/state/gnuplot/history.
>
> [2] Migration
> With the patch, gnuplot will continue to use traditional config or history
> files in ~/ if they exist (as it does for the main config file ~/.gnuplot).
> Users must move the traditional files to XDG dirs (or remove ~/.gnuplot-wxt
> and ~/.gnuplot_history) manually if they want to migrate.
Isn't the obvious migration to set
XDG_DATA_DIRS = $HOME:$HOME/.local/share
XDG_CONFIG_HOME = $HOME:$HOME/.config
and so on? Your current home directory files will be used whether or not
you have XDG enabled, so moving files is not required.
If you choose to enable XDG and move the files, that works also.
>
> We could make gnuplot to force move traditional ones to XDG directories, but
> I rather hesitate to do this.
See above. I see no reason to do this.
But since I'm not actually using XDG maybe I am failing to see a possible benefit.
Other comments or opinions?
Ethan
> [3] wxWidgets
> They added a function (wxStandardPaths::FileLayout()) for supporting XDG
> basedir in wxWidgets 3.1.1.
> https://docs.wxwidgets.org/3.1.5/classwx_standard_paths.html
> But even if FileLayout is set to FileLayout_XDG, it seems I still need to set
> the full pathname of the config flie manually in wxFileConfig constructor to
> make it saved in $XDG_CONFIG_HOME/gnuplot/ (i.e., not directly under
> $XDG_CONFIG_HOME/). So I didn't use wxStandardPaths but used xdg_get_var() in
> xdg.c and manually set the full pathname of the config file.
>
> Good thing of this is it works with older wxWidgets (3.1.x is a kind of
> development release).
>
> I'm not familiar with wxWidgets. If there are anyone who knows wxWidgets better
> please feel free to improve the patch.
>
> [4] Documents
> Are there any documents that need be updated?
>
>
>
>
--
Ethan A Merritt
Biomolecular Structure Center, K-428 Health Sciences Bldg
MS 357742, University of Washington, Seattle 98195-7742
|
|
From: Petr M. <mi...@ph...> - 2021-09-14 08:51:14
|
> I'm not a fan of XDG basedir, but moving only ~/.gnuplot to XDG
> directory may be a kind of "half done".
>
> Attached is a possible patch for moving ~/{.gnuplot_history,.gnuplot-wxt}
> to XDG directories (it seems qtterminal.conf is already taken care of).
> Since only one file (the history file) is saved in the directory, I think
...
> we can save it directly under XDG ( ~/.local/state/gnuplot_history)
> instead of saving it as ~/.local/state/gnuplot/history.
I noticed many programs store they files in $HOME/.config, and some in
$HOME/.local/share, and some in all of them.
I don't have $HOME/.local/state.
For example Midnight Commander: there is a command line option
mc -F
which shows these locations.
I see that QT terminal has its config in $HOME/.config/gnuplot, while WX
terminal in $HOME. I think WX config should go to $HOME/.config/gnuplot/ as
well.
---
Petr Mikulik
|
|
From: Jun T <tak...@kb...> - 2021-09-14 09:49:47
|
> 2021/09/14 17:35, Petr Mikulik <mi...@ph...> wrote: > I don't have $HOME/.local/state. With my patch, if ~/.gnuplot_history does not exist, gnuplot will try to create ~/.local/state/, and if it fails (permission problem, or ~/.local/ not exists) then fall back to ~/.gnuplot_history. XDG_STATE_HOME is new but the spec https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html says this is the place for history, so I used it in my patch. But XDG_DATA_HOME (~/.local/share) would also be OK since the history file of gnuplot is "portable" and can be "shared". Another option is to save everything (including history) in ~/.config/gnuplot/, but I fear many pro-XDG people will complain... > I see that QT terminal has its config in $HOME/.config/gnuplot, while WX terminal in $HOME. I think WX config should go to $HOME/.config/gnuplot/ as well. I guess many users feel the same way. |
|
From: Jun T <tak...@kb...> - 2021-09-14 09:12:08
Attachments:
xdg-v2.patch
|
> 2021/09/14 4:06, Ethan A Merritt <me...@uw...> wrote:
>
> I realize that the previous XDG patch already put a
> chunk of code in plot.c to hande the gnuplotrc file, but wouldn't it
> be better to have that code and the new patch code for the history file
> live in xdg.c instead?
> Then in plot.c or history.c the call site would
> be:
>
> #ifdef USE_XDG_BASEDIR
> expanded_history_filename = some_new_xdg_routine(GNUPLOT_HISTORY_FILE));
> #endif
> if (!expanded_history_filename) {
> /* current code */
> expanded_history_filename = tilde_expand(GNUPLOT_HISTORY_FILE);
> }
> read_history(expanded_history_filename);
How about the revised patch (xdg-v2.patch)?
I moved "most" of the complication into a function in xdg.c, but plot.c is
not as simple as above.
>> [2] Migration
>> With the patch, gnuplot will continue to use traditional config or history
>> files in ~/ if they exist (as it does for the main config file ~/.gnuplot).
>> Users must move the traditional files to XDG dirs (or remove ~/.gnuplot-wxt
>> and ~/.gnuplot_history) manually if they want to migrate.
>
> Isn't the obvious migration to set
> XDG_DATA_DIRS = $HOME:$HOME/.local/share
> XDG_CONFIG_HOME = $HOME:$HOME/.config
I couldn't understand this part...
> Your current home directory files will be used whether or not
> you have XDG enabled, so moving files is not required.
> If you choose to enable XDG and move the files, that works also.
Yes, this is the case with my match.
As I wrote, with my patch, if ~/.gnuplot_history or ~/.gnuplot-wxt exists
gnuplot will continue to use them. User need not do anything if they are
satisfied with this traditional behavior.
If a user wants to use XDG directory, she/he must manually move
~/.gnuplot_history to ~/.local/state/gnuplot_history, and
~/.gnuplot-wxt to ~/.config/gnuplot/gnuplot-wxt.conf
(or just remove them), but need not set XDG_CONFIG_HOME etc.
(if XDG_CONFIG_HOME is set then it is used instead of ~/.config/, of course)
Is this OK?
|
|
From: Ethan A M. <me...@uw...> - 2021-09-22 22:30:58
|
I applied this patch and did a commit to the development branch.
I added a brief mention under "set history" in the documentation.
I'm not actually using XDG normally, so I could do only limited testing.
thanks,
Ethan
On Tuesday, 14 September 2021 02:11:58 PDT Jun T wrote:
>
> > 2021/09/14 4:06, Ethan A Merritt <me...@uw...> wrote:
> >
> > I realize that the previous XDG patch already put a
> > chunk of code in plot.c to hande the gnuplotrc file, but wouldn't it
> > be better to have that code and the new patch code for the history file
> > live in xdg.c instead?
> > Then in plot.c or history.c the call site would
> > be:
> >
> > #ifdef USE_XDG_BASEDIR
> > expanded_history_filename = some_new_xdg_routine(GNUPLOT_HISTORY_FILE));
> > #endif
> > if (!expanded_history_filename) {
> > /* current code */
> > expanded_history_filename = tilde_expand(GNUPLOT_HISTORY_FILE);
> > }
> > read_history(expanded_history_filename);
>
> How about the revised patch (xdg-v2.patch)?
> I moved "most" of the complication into a function in xdg.c, but plot.c is
> not as simple as above.
>
>
> >> [2] Migration
> >> With the patch, gnuplot will continue to use traditional config or history
> >> files in ~/ if they exist (as it does for the main config file ~/.gnuplot).
> >> Users must move the traditional files to XDG dirs (or remove ~/.gnuplot-wxt
> >> and ~/.gnuplot_history) manually if they want to migrate.
> >
> > Isn't the obvious migration to set
> > XDG_DATA_DIRS = $HOME:$HOME/.local/share
> > XDG_CONFIG_HOME = $HOME:$HOME/.config
>
> I couldn't understand this part...
>
> > Your current home directory files will be used whether or not
> > you have XDG enabled, so moving files is not required.
>
> > If you choose to enable XDG and move the files, that works also.
>
> Yes, this is the case with my match.
>
> As I wrote, with my patch, if ~/.gnuplot_history or ~/.gnuplot-wxt exists
> gnuplot will continue to use them. User need not do anything if they are
> satisfied with this traditional behavior.
>
> If a user wants to use XDG directory, she/he must manually move
> ~/.gnuplot_history to ~/.local/state/gnuplot_history, and
> ~/.gnuplot-wxt to ~/.config/gnuplot/gnuplot-wxt.conf
> (or just remove them), but need not set XDG_CONFIG_HOME etc.
>
> (if XDG_CONFIG_HOME is set then it is used instead of ~/.config/, of course)
>
> Is this OK?
>
>
--
Ethan A Merritt
Biomolecular Structure Center, K-428 Health Sciences Bldg
MS 357742, University of Washington, Seattle 98195-7742
|
|
From: Jun. T <tak...@kb...> - 2021-09-23 14:53:15
|
> 2021/09/23 7:11, Ethan A Merritt <me...@uw...> wrote: > > I'm not actually using XDG normally, so I could do only limited testing. The point is that it does not interfere/surprise users who do not know/use/like XDG. If you find anything it may bother those users please let met know. -- Jun |