Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds option to run configuration to expand macros in environment variables #3872

Merged
merged 6 commits into from
Feb 8, 2025

Conversation

briha
Copy link
Contributor

@briha briha commented Jan 29, 2025

Fix #3867

Summary of additions and changes

  • Added checkbox to LaTeX run configuration, which, when checked, expands IntelliJ macro's in environment variables. When unchecked, the old behaviour is preserved.
Screenshot 2025-01-29 at 20 01 24

How to test this pull request

Set TEXINPUTS to a value containing a macro. Run the following with LuaLaTeX to print the value of said TEXINPUTS:

\documentclass{article}

\begin{document}
\directlua{
  texio.write_nl("TEXINPUTS: " .. os.getenv("TEXINPUTS"))
}
\end{document}

Alternatively, one can also include a file that isn't findable, and add the directory containing said file to TEXINPUTS through a macro to verify it works correctly.

  • Updated the documentation, or no update necessary
    Documentation section added in 9a31277
  • Added tests, or no tests necessary
    I don't know what a test would look like, but again: if one is necessary, I'd be happy to implement it, having been provided more details about what it would look like.

Copy link
Collaborator

@PHPirates PHPirates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, great work!
It works well for me, just a few minor things.

This will definitely require some documentation. This macro replacement using the default macros is something I haven't completely figured out yet. Take for example the ContentRoot macro, when you put the caret in a LaTeX file and compile then it is fine, but if you put it somewhere else like the pdf file or the project tool window then this macro does not work for me (is replaced by the empty string). This might not be easy to fix, if not we should document this.

briha added 2 commits February 3, 2025 23:18
…d file (CommonDataKeys.VIRTUAL_FILE) by the .tex file targetted in the RunConfiguration during macro expansion
@briha
Copy link
Contributor Author

briha commented Feb 3, 2025

This will definitely require some documentation. This macro replacement using the default macros is something I haven't completely figured out yet. Take for example the ContentRoot macro, when you put the caret in a LaTeX file and compile then it is fine, but if you put it somewhere else like the pdf file or the project tool window then this macro does not work for me (is replaced by the empty string). This might not be easy to fix, if not we should document this.

I'll follow up with a suggestion for the documentation.

I have now, in the latest version, changed the DataContext during macro expansion, so that the file (and thus ContentRoot) always points towards the .tex file targeted by the current run configuration. This should resolve this ambiguity, though two points here:

  1. Is there any case where the old behaviour might be wanted?
  2. I do not like the way I had to implement it at all. Am I missing some API somewhere that allows me to do this in a nice way? I ended up sub-classing ProgramParametersConfigurator and re-implementing a number of its functions, as the required ones are private static. This is obviously less than optimal, though, as far as I can tell, it does work.

@briha
Copy link
Contributor Author

briha commented Feb 7, 2025

Added a documentation section in 9a31277. Please let me know if there's any change you'd like to see there.

@briha briha requested a review from PHPirates February 7, 2025 23:01
Copy link
Collaborator

@PHPirates PHPirates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, works great! Thanks for adding the documentation.

@PHPirates PHPirates merged commit d69d378 into Hannah-Sten:master Feb 8, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add placeholders to use in environment variables, to allow for generic launch configuration
2 participants