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

Set app environment variables for running 3rd party apps as extensions #758

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lifenjoiner
Copy link
Contributor

@lifenjoiner lifenjoiner commented Jan 23, 2024

Kind of solution for #259.

For grepWin using a launcher:

  1. Prepare the grepWin. Locate it in D:\grepWin\grepWin_portable.exe for example.
  2. Create a script gw.bat:
    @start D:\grepWin\grepWin_portable.exe /content /searchpath:"%cd%"
  3. Config the command line of grepWin editor setting to notepad2 /g %line% %path%.
  4. Ctrl + R --> gw, search or replace.
  5. Double click the search result will locate the line in notepad2.

For ripgrep:

  1. Locate rg.exe in the same directory as notepad2.
  2. Ctrl + R --> cmd --> rg.

N2Root is in case of there is the same name files in the directory of the opened file and notepad2, it can be used as a short and unique prefix.

@zufuliu
Copy link
Owner

zufuliu commented Jan 24, 2024

There is no use of N2Root and modify PATH isn't good. When integrating 3rd tools, we can find their executable from

  1. GetProgramRealPath(), same directory as Notepad2.exe.
  2. GetModuleFileName(), same directory as symbolic link to Notepad2.exe.
  3. SearchPath()

@lifenjoiner
Copy link
Contributor Author

The key logic is launching other files in the order of: dir of the opened file (current dir) --> dir of notepad2 --> systerm path.
I tried getting the dir of notepad2 dynamically, and then implement the logic. But, I did not manage it as simple as this, if dir of notepad2 is not added at the head of PATH.

Modified environment variables only have the lifetime in the current progress and its descendants. It won't be a problem.

Without N2Root, what if there is rg.bat/rg.exe/rg.js in dir of the opened file, and also in the dir of notepad2? Isn't %N2Root%\rg simpler?

@lifenjoiner
Copy link
Contributor Author

Reasons to modify Path:

  1. The path searching order is: current dir --> Path. And we should insert dir of notepad2 between them.
  2. CLI tools. The designed "Ctrl + R --> cmd --> rg" won't be possible, if don't modify Path.

@zufuliu
Copy link
Owner

zufuliu commented Jan 25, 2024

delayed this until there is real usage for the changes.

@lifenjoiner lifenjoiner mentioned this pull request Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants