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

permanent setting #335

Open
DomOBU opened this issue Apr 17, 2024 · 4 comments
Open

permanent setting #335

DomOBU opened this issue Apr 17, 2024 · 4 comments
Labels

Comments

@DomOBU
Copy link

DomOBU commented Apr 17, 2024

Hello,

I'm a new PythonScript user. I'm not a geek and I don't know Python.

On the Notepad++ forum I was recommended to install PythonScript to solve a CSS problem with Lexilla.
A command was provided. I tested it in the console; it's operational but temporary.
I haven't found a way to make it permanent when I launch Notepad++. How would this be possible?

Thank you for your reply.

@Ekopalypse
Copy link
Contributor

I do not know what "command" you are referring to but to make something permanent you usually create a script and name it startup.py. It must be called startup.py and it shouldn't be the one that comes with the plugin itself. Change to configuration from LAZY to ATSTARTUP and then this script will run every time Npp starts.

@DomOBU
Copy link
Author

DomOBU commented Apr 20, 2024

Thank you for your reply.

I have created a file containing :

  • from Npp import editor
  • editor.setProperty('lexer.css.scss.language', 1)
    This last command line works in the PythonScript console.

I've :

  • renamed the startup.py file to oldstartup.py
  • renamed my file to startup.py and copied it to the scripts directory.

Without success.

@Ekopalypse
Copy link
Contributor

Ekopalypse commented Apr 20, 2024

No, the startup.py that is supplied with the plugin must remain. The "user" startup.py must be created in addition.
the setProperty function must be called for both editor instances

editor1.setProperty...
editor2.setProperty...

the editor refers to the currently active instance and would only be set for this instance.

Do you have changed the Python Script Configuration from LAZY to ATSTARTUP?

@Ekopalypse
Copy link
Contributor

Ekopalypse commented Apr 20, 2024

No, this is a Lexer property that you want to set. This must be done differently.
You need to register a callback for bufferactivated and then set the property.
This should still be done in the user startup.py.

def on_buffer_activated(args):
    # check if the file needs to have the setting and then
    # call editor.setProperty('lexer.css.scss.language', 1)
    # something like
    # if editor.getLexer() == whatever_number:
    #     editor.setProperty('lexer.css.scss.language', 1)

notepad.callback(on_buffer_activated, [NOTIFICATION.BUFFERACTIVATED])

@chcg chcg added the Question label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants