Looking for tips/directions on how to best approach creating a custom plugin for Notepad++
sorry for late response
There’s a lot going on with this thread starting with “Hey Guys”.
I’ll try to address some things further, in this and subsequent postings in this thread…
Create your RegEx with the (?x) modifier to allow inline comments and free space
(?x)at the start can affect the meaning of what follows, unless you use
(?-x)at some point after.
Why not avoid that possibility and just use the comment specifier, example:
(?#hello there I'm a comment)at the start of the regex?
if one of the search regex finds a string, NPP would prompt a user with a pop up window/message in any other form, that “hey, this has been found in your file, you might want to take a look at it”?
I don’t think so with just the Macro approach. If you implement the searches in PythonScript, then yes absolutely possible as with any other scripting solution (NppExec for example) and certainly with a proper plugin.
No way to do this in a macro, as stated. PythonScript has two functions for prompting the user:
Each returns data which can impact script logic flow after the prompting box window is closed.
I would also not want to lose on the great functionality of the search result window from Notepad++, that it provides on it’s own.
So that window and PythonScript don’t typically play well together. If you script searches, you have to find your own way of presenting the output to the user.
Michael Vincent last edited by
Why not avoid that possibility and just use the comment specifier, example: (?#hello there I’m a comment) at the start of the regex?
Much nicer solution!
Ekopalypse last edited by
Plugins are usually shared libraries (dll) and creating them with Python is not as easy as with a language that is supposed to create them natively, like C++, C, D, Rust, C#, V or others. Yes, one way to create them is with Cython or also with cffi.
But I would recommend using another language instead, because as far as I know, including Python 3.10, there is still a problem if you want to embed more than one Python interpreter into a running process, which means that as long as you are the only one writing plugins for your own use, it’s fine, but as soon as another plugin developer decides to do so as well or someone wants to use the existing PythonScript plugin, then the problems start.
Slusher59 last edited by
Thank you. As a temporary band-aid fix for this (until I learn how to do the thing properly), is it possible in NPP to display only the search results that have > 0 hits, and hide all searches that returned 0 results?
Ekopalypse last edited by
No, as far as I know there is neither a built-in option nor a plugin message that would allow you to do this. And hacking it might be a bad idea because it could then conflict with subsequent searches.
is it possible in NPP to display only the search results that have > 0 hits, and hide all searches that returned 0 results?
As I said before:
So Search results window and PythonScript don’t typically play well together.
If you script searches, you have to find your own way of presenting the output to the user.
One way of doing this is having your script write output to a new (file) tab that it creates. That way you have total control of what goes into the output. You can even make it appear a lot like the usual Search results. If you want to get really fancy, you could even set it up so that double-clicking in this output would open the file where the hit was found.
It just depends if the time you want to spend on this is better spent scripting or developing a true plugin. But even a true plugin isn’t going to have an easy time of doing custom things with Notepad++'s Search results area.