Loading preferences by file extension.
-
Hello, thank you for the reply. The vertical edge settings are what I am trying to adjust by file. You got everything else correct. So I have:
.def with spacing “A”,
.ini with spacing “B”… etc
Our team has hired some technician level associates in order to help us, so I have been trying to create visual boundaries in each “column” Realistically that is the only preference parameter that I need to come in with the file.
I am manually loading them by replacing the appdata with a saved set from another instance.
Best,
Jim -
@James-Swallow said in Loading preferences by file extension.:
The vertical edge settings are what I am trying to adjust by file
Ah, okay, yes. Those settings should work with either the PythonScript or the batch workaround.
if you want to go the PythonScript route, let us know. Otherwise, hopefully you have enough for the batch. (or you can wait to see if someone else has other suggestions).
-
see here for an example based on the language used.
-
OK, So I got that script to run. A couple of questions:
On Startup, is there a way to automate this so it will apply to open instances without changing the language and then changing back?
Second question, What is the best way to run this with shortcuts if that is not an option? -
@James-Swallow said in Loading preferences by file extension.:
On Startup, is there a way to automate this so it will apply to open instances without changing the language and then changing back?
Interesting. I would have thought that BUFFERACTIVATED notification would trigger at Notepad++'s initial startup, too. But if the callback isn’t triggering, it’s probably not notified. There is a notification for “notepad++ has finished loading everything”: NPPN_READY, which in PythonScript is NOTIFICATION.READY. So if you add that to the list of notifications, it should work for you.
Second question, What is the best way to run this with shortcuts if that is not an option?
Hmmm. I think if you added a call to
on_set_edge_config()
(or whatever you called your version of the callback function) at the end of the script, then if you run the script manually, it will trigger the callback, even if the script was already run from startup.py. (I’m not 100% sure). If so, then use the PythonScript > Configuration… to add your script to the Menu Items. Then, after Notepad++ restart, you can assign as keyboard shortcut to that script using Settings > Shortcut Mapper > Plugin Commands and filtering for PythonScript to easily find your script’s name. -
Just a note that if you started your script via startup.py and call it again, you will get two callbacks registered doing the same thing, that would be unnecessary. And if you want to call it intially with
on_set_edge_config()
, do not forget to add aNone
parameter, because the function expects anargs
dictionary. -
@PeterJones said in Loading preferences by file extension.:
I would have thought that BUFFERACTIVATED notification would trigger at Notepad++'s initial startup
Yea, the fact that this doesn’t happen is a sometimes-annoying quirk. :-(
-
So your best advice, as the script’s author, is to add a call to
on_set_edge_config(None)
instartup.py
? -
Yes, that’s what I usually do too, but I have to admit, npp_ready is also a nice solution too, since it’s only called once. As usual, there are more ways to Rome.
-
Thanks for all the input thus far. Much obliged!