cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
884 stars 84 forks source link

Use `$homeDir`/`$HOME` in `$LATEXINDENT_CONFIG` file #430

Closed Andrew15-5 closed 1 year ago

Andrew15-5 commented 1 year ago

I've found that $LATEXINDENT_CONFIG file only contains the paths to configuration files.

https://github.com/cmhughes/latexindent.pl/issues/291#issuecomment-933381735 I would also like to know why this approach has been chosen.

But most importantly, I would like to use any variable that will make $LATEXINDENT_CONFIG file reusable between different users. Right now, you have to hard code your username, which is almost always should be avoided (for portability/reusability and security reasons).


For example, in the documentation: https://latexindentpl.readthedocs.io/en/latest/sec-appendices.html?highlight=config#linux-1 it should say:

echo 'export LATEXINDENT_CONFIG="$HOME/latexindent-config.yaml"' >> ~/.profile

or even better (to keep user's home directory tidy):

echo 'export LATEXINDENT_CONFIG="$HOME/.config/latexindent/latexconfig.yaml"' >> ~/.profile
# or this (I don't personally have this variable set):
echo 'export LATEXINDENT_CONFIG="$XDG_CONFIG_DIR/latexindent/latexconfig.yaml"' >> ~/.profile

(Different file name was taken from https://latexindentpl.readthedocs.io/en/latest/sec-appendices.html?highlight=config#indentconfig-options.)

instead of:

echo 'export LATEXINDENT_CONFIG="/home/username/latexindent-config.yaml"' >> ~/.profile

I want to have the following in my $LATEXINDENT_CONFIG file:

paths:
- "$homeDir/.config/latexindent/latexindent.yaml"
# or
paths:
- "$HOME/.config/latexindent/latexindent.yaml"

Is this possible to do now or in the future?

cmhughes commented 1 year ago

You can out whatever path you want in indentconfig.yaml including itself, so for example

paths:
- /home/cmhughes/indentconfig.yaml

And then you should be able to put your settings in indentconfig.yaml.

Andrew15-5 commented 1 year ago

Thanks for the tip, it works. But what about using home dir variable in paths in YAML config file?

cmhughes commented 1 year ago

I have no idea how/if that can work, but feel free to take it on if you like.

I don't have any capacity to do so.

On Wed, 8 Mar 2023, 14:40 Andrew Voynov, @.***> wrote:

Thanks for the tip, it works. But what about using home dir variable in paths in YAML config file?

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/430#issuecomment-1460262134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYBCUZ3ROH3IVFWHKUDW3CK45ANCNFSM6AAAAAAVTZHCAI . You are receiving this because you commented.Message ID: @.***>

Andrew15-5 commented 1 year ago

Ok, hopefully soon I will have time to tinkle with this problem.