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

[Feature Request] Language auto detection from simplified session file #5844

Open
andry81 opened this issue Jun 27, 2019 · 3 comments
Open

Comments

@andry81
Copy link

andry81 commented Jun 27, 2019

Description of the Issue

The feature was removed or broken some time ago:
#5629
#5338

I have used it from Total Commander to open many files at once with out put the paths into a command line (command line length is very limited). Now it does not work.

Version: 7.7.1 x86

Steps to Reproduce the Issue

#5338

Expected Behavior

Auto detect language in case of open many files from a session file.

@andry81
Copy link
Author

andry81 commented Jul 7, 2020

Bump the issue. Still reproduciable in the 7.8.8 x86.

The issue can be workarounded by sequence of CTRL+W + CTRL+SHIFT+T to reopen a tab and trigger the language detection for the file. But that is annoying because has to be invoked on all tabs.

@andry81
Copy link
Author

andry81 commented Aug 31, 2020

For those who suffer from the bug you can use python script to reopen all tabs upon Notepad++ launch:

def reopen_all_files():
  print('reopen_all_files:')
  notepad.saveAllFiles()
  all_files = notepad.getFiles()
  notepad.closeAll()

  for f in all_files:
    notepad.open(f[0])
    print("  - {}".format(f[0]))
  print()

The complete version is here:
https://github.com/andry81/contools--notepadplusplus/tree/HEAD/scripts/python/tacklebar/libs/npplib.py

Update:
This workaround has an issues, when you appending files to already opened notepad++ instance and it does not trigger the startup python script.

@andry81
Copy link
Author

andry81 commented Oct 1, 2020

Another much better solution is to call notepad++ with the -z --open_from_file_list -z <list_file> command line:
https://community.notepad-plus-plus.org/topic/19247/launching-tail-f-from-the-command-line/14
https://npp-user-manual.org/docs/command-prompt/

import shlex
from Npp import notepad
if '--open_from_file_list' in shlex.split(notepad.getCommandLine()):
   ...

This a bit more reliable and faster, because you don't need to write a convertion logic from a custom file paths list into the notepad++ session file. But neverless it suffers from the same issue as previous workaround with files appending into already existed notepad++ instance. The script has invoked only on instance creation and does not on files appending in already existed instance.

Example implementation:
https://github.com/andry81/contools--notepadplusplus/tree/HEAD/scripts/python/tacklebar/libs/npplib.py
https://github.com/andry81/contools--notepadplusplus/tree/HEAD/scripts/python/startup.py

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

No branches or pull requests

1 participant