How to create abbreviations for java code

Not being a plugin author myself, I’m not sure of the process for (a) getting your plugin in the list [so I’m not sure how yours would have gotten there] or (b) getting your plugin version-bumped in the list.

The other thing is that it’s not “my” plugin. Someone else is the original author, it just seemed to be abandoned. And since I was using it on 32-bit and wanted to move to 64-bit, I got it to work for that and added some extra enhancements that I wanted. So it really isn’t my plugin nor I think mine to list.

Happy to make it available on GitHub, but feel pretty weird about it being published in some list with me as the goto / author.

For adding to the list (though I’ve never done it), the nppPluginList page implies you just do a Pull Request to add it into the JSON files. You can search for closed PR to see what the PR look like that get plugins updated (I couldn’t find any PR attached to @chcg’s commits, though I admit navigating these things isn’t second nature to me yet, so there might be an associated PR with his commits).

Happy to make it available on GitHub, but feel pretty weird about it being published in some list with me as the goto / author.

Especially if annoying people like me start asking you to make fixes, rather than the original author. Then you might have to start supporting it, or ignoring those people. :-)

I say this for no particular reason, because I wouldn’t ask you to look into why, when I installed 0.1.1.1 via Plugins Admin, it defaulted to an empty QuickText.conf.ini, rather than using the values for the defaults – because if I were to ask you about that, it would be like trying to assign you ownership, and I wouldn’t do that. ;-)

Oh, you meant because of copyright/license/ownership? That makes sense, too. It was released under GPL2, so as long as you attribute the original authors, maintain license, and make it clear that you have made changes from the original, there’s nothing wrong. (I’m never sure whether GPL requires you to change the name of the project if you make a fork or not, though it doesn’t seem to be that way: IANAL.
In other open-source communities – like Perl’s CPAN, it is possible to take ownership of abandoned open-source projects, and those don’t require renames, so I would assume it’s the same here.)

I don’t know why it doesn’t use the default one supplied with the ZIP file / install. Thanks for the work-around. I guess I never noticed already having it installed and working - probably had to jump through those hoops the first time I set it up from the original author and then my subsequent “upgrades” were just overwriting the DLL - the config and INI file where already in place.

Not sure if this helps now that you’ve figured it out:

QuickText.conf.default.ini = is an example of the the Plugin’s config file
QuickText.default.ini = is an example for the code snippets

But in all seriousness, if you’d like bug reports or feature requests to be tracked on your github, I can add them. If it’s good enough for you, and you aren’t planning on any support or future fixes, then I don’t want to clutter your repo with issues that will just be ignored for years (or forever).

I don’t mind you or anyone adding issues to track as long as you don’t mind they may never be fixed :-P

Seriously though, I found QuickText the most “useful” snippet plugin for how I worked and 2 things happened, I moved to 64-bit and Notepad++ updated Scintilla - both of which “broke” my usage of QuickText. I hacked at it with my sub-par C++ skills and was able to get 64-bit compiled with the new N++ plugin architecture and Scintilla updates so was pleased to just keep using it.

I haven’t given much thought to how I’d re-architect QuickText to address some of my minor gripes, but as it is now, it just “works” so I leave it alone.

I’m “more actively” updating “my” other plugins - again, none of these are “mine”, they are clones of other people’s work that either seemed abandoned, not updated in years or my request for features were turned down, so I implemented them myself. For the same reason as QuickText, I’m hesitant on listing them officially.

But for “power users” like yourself, that can stand a bit of “buginess” and hopefully no seg-fault crashes, feel free to try them out. Again, feedback welcomed (but possibly ignored :-) (coding N++ plugins isn’t my day job).

Joking aside, thanks for taking a look and taking the time to do the write-ups. I think 11 is an easy fix, 12 I’ve notice myself and just lived with it by editing the QuickText.ini file directly to add multiple new snippets. 13 I didn’t realize, although GLOBAL tags didn’t work at all in previous original versions. 14 and 15 - dealing with Unicode scare me :-(

I’ll probably approach in what I think is easiest: 11, 13, 12 and back burner 14 and 15 for now.

None are showstoppers for me. Until I train myself to actually use the quick text snippets, they won’t be efficiency stoppers.

And I have a pythonscript implementation of #15, so for now I have a workaround on that one: gist for pyscReplaceBackslashSequence.py (the mention of nppQuickText actually interrupted my development, while I explored to see if it would be enough for me; I ended up finalizing my script anyway)

actually interrupted my development, while I explored to see if it would be enough for me

I hear that. Frequently I’ll wish there was a quicker way to do something or something I’ll see a peer doing in VS Code and I’ll think “there must be a Notepad++ way to do this”. I’ll get sidetracking trying to find something.

I’ll look for a plugin or look for a way to script it in NppExec (my goto scripting engine). In fact I have a bunch of NppExec scripts (compile, style, help manual / docs, run, debug, open include files) that do a bit of formatting then send arguments to a monster Windows batch file that actually executes the task.

Sometime a find a plugin that’s promising, but it doesn’t do everything or it’s just 32-bit and then I’ll find myself cloning and hacking at it (JAPH, or in this case JAN++PH [Just Another Notepad++ Plugin Hacker]) to get what I want. That’s how all of “my” plugins came to be.

First, many thanks for building an x64 version of the QuickText plugin and for all the bug fixes

May I bother you, a little bit, with a couple of weird things, still occurring in your last0.1.2.4 version ?

A) : First problem :

Let suppose that you place the caret right after a word, which is not a tag, for the current language

If you run the option Plugins > QuickText > Replace Tag, it writes :

The » character, in an ANSI encoded file ( An \xbb byte )

The value xBB, in reverse video, in any Unicode encoded text ( Indeed, this single byte is not valid in an Unicode file ! )

This also happens if you run the Plugins > QuickText > Replace Tag option anywhere inside some blank range of text or even in an empty text. Is it the normal behaviour or is it a bug, due to my old Win XP SP3 laptop ?!

B)Second problem :

Let’s suppose that the tags file QuickText.ini is opened, with other tabs, in your current N++ session

Then, you decide to delete the only tab ( copyright ) of the GLOBAL section, using the Plugins > QuickText > Options... option. After validating the suppression :

If the current tab is the QuickText.ini you must, first, switch to an other tab

Now, switch to the QuickText.ini tab to get the expected dialog : “This file has been modified by another program, do you want to reload it ?”

After a click on the Yes button of this dialog, you can notice that the layout of the sections of QuickText.ini has become completely different !

All the ini sections, which do not have any tag, have been deleted, including the [255]GLOBAL one, of course

From now on, the different sections are sorted alphabetically and NOTnumerically

C)Third problem :

Let’s suppose that you change the TEXT section as below :

[0]
LANGUAGE_NAME=TXT
LANGUAG_NAME=TXT_1
LANGUAGES_NAME=TXT_2

After saving these changes, run the Plugins > QuickText > Refresh Configuration option

A) This does not happen for me. It is probably as expected for now since I always use ANSI encoded files and my QuickText.ini is ANSI encoded. As @PeterJones documented in the GitHub issues, UNICODE does not work in this plugin and since there is a mess of someone else’s old code, I’m not prioritizing fixing that - sorry.

B) The tab switching to get the change notification happens for me with any file in N++. Not sure that’s related. The order of sections is as expected as well since when the file is rewritten, it’s written according to looping through the C++ vector storing the languages - I don’t believe any sort is applied. So however they are in there, they are written out. I’ll see if there’s a way to easily sort, but I don’t think it’s necessary.

C) LANGUAGE_NAME is not a tag. It’s a comment. The original version didn’t even check for it so if yo had them, they would show up as tags. I ignored them originally, but then they weren’t rewritten to the file on save so disappeared. Now I purposefully placed them back in, but they should never be visible in the Options dialog as Tags to expend. I’ll see if I can make that more clear by making them #LANGUAGE_NAME. So the behavior if replacing tags is as expected, the first one does not expand since it is not a valid tag (not seen in Options dialog) and you’re hitting the issue in A) about encoding. The second and third don’t match the regex I look to ignore for comments so show up as valid tags and are expanded.

D) I think would be too difficult to implement as I’d need to track all languages with some placeholder in the vector even though they don’t have tags. And as in B), they certainly wouldn’t stay in order.

Hope that helps explain some of the behavior. I’ll see about changing C) to make the comment more obvious but I don’t think the rest will be fixed anytime soon unfortunately. I just don’t have the skills or time for that kind of re-write.

In fact , I don’t really mind about this QuickText.dll behaviour, when trying to run the Plugins > QuickText > Replace Tag option, with caret close to a word which is not a tag, for current language. But, out of curiosity, what happens when using the Replace Tag option, in your system ?

BTW, as my settings for Setting > Preferences... > new Document > Encoding is UTF_8, with the Applied to opened ANSI files option ticked AND as the QuickText.ini file does not have any character with Unicode code-point over\x007F, the chosen encoding for the QuickText.ini file is always UTF_8, when starting N++ !

Even if I force the QuickText.ini to have an ANSI encoding, I still get the xbb character, in reverse video, if current fie is Unicode encoded or the » character if current file is ANSI encoded !

Regarding point B) :

I just wanted to emphasize that, after suppression of the unique global tag copyright, in addition to all the changes of the QuickText.in file, which occurs, if the current N++ file is QuickText.ini file, then the update dialog does not appear. You’ll need to switch to any other tab and, then, switch back to the QuickText.ini to get this dialog !!

Regarding point C) :

Ah…OK, I understand ! And you’re right : probably the syntax #LANGUAGE_NAME would remove the ambiguity !

Regarding point D

Oh ! I was not asking for a dynamic and updated list of all N++ possible languages, at any time, but, only, for a static updated list of present languages, used in the v7.8.4 release !

A)
When using either the menu option Plugins > QuickText > Replace Tag or the shortcut key I have mapped to that (which is Tab) anywhere in a document I just get a ‘tab’ inserted (which I have N++ converting into 4 spaces). The same goes for in proximity to a tag. If my caret is adjacent to the end of a tag word for the current doc type, then the hotkey or the menu option both perform as expected - expanding the tag without insertion of any weird characters.

Note my default file type in N++ is ANSI and when I menu option Plugins > QuickText > Open Tags File, that opens as ANSI as well.

I’m still thinking this is an ANSI / Unicode thing, but it could also be the shortcut key you have mapped to the menu option, unless just using the menu option directly still produces the weird character insertion. If that’s the case, I’m sticking with my ANSI / Unicode issue which @PeterJones describes in GitHub issues 14 and 15.

B)
I believe this is just default behavior of N++. Proof of concept: create 2 files:

Open %TEMP%\deleteme.txt in N++. In a command prompt, run the deleteme.bat file and while it’s doing its 7 second sleep, click back to N++ and activate the tab with deleteme.txt. You’ll notice nothing happens. Even after the batch file completes and deletes the file you’re looking at, N++ does nothing. You’ll need to click a different tab and the click back to the deleteme.txt tab for N++ to prompt that the file has changed do you want to reload from disk.

I see this as the same. You have QuickText.ini open. You make a change which rewrites it. Unless you somehow reactivate the tab with QuickText.ini in it (click off it than back on it) you won’t get the N++ reload from disk prompt.

C)
I made that change and pushed to GitHub. There is no precompiled release, you’ll need to compile yourself. Note there are other changes you may need to manually make like removing the hash “#” as an allowedChar from your plugins/config/QuickText.conf.ini file and manually adding the hash “#” in front of all the LANGUAGE_NAME= in your plugins/QuickText/QuickText.ini file. For new installs, you won’t need to do this, but if you already have an install, you probably need to. Sorry.

D)
Again, this is someone else’s code that I understand about 10% of and given my poor C++ skills, I don’t really know how to improve it (i.e., GitHub issues 14 and 15 mentioned above). The tags are read into memory and are not read on demand from the file. So when reading in the tags, if a language does not have a tag, there is no entry created in the C++ vector in memory. Now when it comes time to save the file, we use an “iterator” to go through the C++ vector in memory (which no longer has any of the languages that had no tags) and it goes in whatever order a C++ iterator does (I have no idea how to make it sort nicely). In fact, like I said previously, there was no place in the memory list to store the LANGUAGE_NAME so when the file was rewritten, all that was lost. I just added that back in as part of these latest fixes.

Here we have the regex when reading the tags in to ignore the LANGUAGE_NAME - now with the hash “#” to make like a coment.

Here we have the WriteFile() routine that saves the tags file. You’ll see I had to add the “lang_menu” argument as input so I could map to the language name by ID and get the #LANGUAGE_NAME= rewritten (which wasn’t there in the original code. Also you can see the for() loop base on an iterator. It’s iterating through a data structure with key/value pairs so not easy for me to just us a for() loop with index to loop through all languages and write them to file regardless of whether they have tags or not. It could be possible, but beyond my abilities.

All this to say I was surprised to see that this is in the Plugins Admin - I probably never noticed since I already had it installed, it never showed as “available” for me. This isn’t “my” code, just my improvements to work for me which I’m happy to share, but purposely didn’t publish myself knowing there were shortcomings / bugs / etc. that when exposed to a wider audience, people would want fixed, but would be beyond my capabilities (i.e., time, skills, general code-base understanding).

After some searches, I found out that the QuickText plugin simply displays the character whose decimal value is the scan-code of the key, read by the Shortcut Mapper. Of course, for key codes over127, the result is different between an ANSI and Unicode file !

Here is, below, an almost exhaustive list, where :

Column 1 contains the name of keys, used with Shift and/or Ctrl and/or Alt, in the Shortcut Mapper

Column 2 contains the character displayed, in an Unicode file, by the QuickText plugin, when caret is not close to an abbreviation tag

Column 3 contains the character displayed, in an ANSI file, by the QuickText plugin, when caret is not close to an abbreviation tag

Column 4 contains the decimal N++ Scan-code of the key, read by the Shortcut Mapper

And it seems that every abbreviation tag is fully functional, when the corresponding language is selected ;-)) I just did few tests, in various languages, of course !

Remark : I noticed that all the # LANGUAGE_NAME entries are considered as abbreviation tags, in the Plugins > QuickText > Options... dialog

Regarding point D

As my C skills are quite near 0, I simply decided to give it a try. So, I just added all languages, with code from 50 ( COBOL ) to 84 ( Visual Prolog ) to the QuickText.ini file

And, I was happily surprised to find that, after defining an abbreviation tag for these two new languages, in the QuickText.ini file, the hit of the ESC key correctly expanded them to their substitution text, just as expected, once the COBOL or Visual Prolog language was selected, for a standard UTF-8 encoded file :-))

In the next post, you’ll find the exact contents of my QuickText.ini file, without few abbreviation tags used during my tests, of course !

That’s great news about A), I think I’ve seen that behavior myself once or twice when using Alt as a modifier for a hotkey that does text insert - it put a weird character in so I just removed the Alt modifier for the hotkey chord. I’m glad Tab works for you!

ONE NOTE: Maybe I should have made this clearer - the ‘#LANGUAGE_NAME’ needs to be NO SPACES between the hash “#” and the “LANGUAGE_NAME”. I see in your example, you’ve put a space between. If you remove the space, everything should work as expected - you should not see them as expansions in the Options dialog.

Sorry for the confusion.

Also, thanks for the breakdown in A) about the character insertions based on modifiers and encoding - very helpful going forward. And thanks for your QuickText.ini file. I’ll incorporate that into future releases as well as making the QuickText.default.ini file just QuickText.ini so it should hopefully work “out of the box”.

I did some looking at the codebase this morning. Again my limited C++ knowledge hampers my efforts, but it looks like sorting the languages will be harder than I expected since in the Combo box of the Options dialog, the order matters when selecting a language - it returns a zero-based index which is then matched to the N++ language list (enum LangType in Notepad_plus_msgs.h, an include file from the N++ project) which itself has the same order as the LANGUAGES I use in QuickText. All this matters to match the appropriate language. I suppose a more complicated data structure to store the language ID rather than putting it in a vector array by the ID would be more visually appealing, but certainly more C++ work than I have skills for at the moment.

My thought behind this was to be able to add User Defined Languages instead of just adding all tags in the USER language for all user defined languages. But again, all user defined languages return an ID of 15 - they need to be differentiated by string matching the name after matching the ID of 15 - logic that QuickText and the data structure to store the language don’t yet have.

Finally, I was playing with DoxyIt over the weekend and like the way they do named hotspots hopping in the inserted comment text. QuickText just uses the “$” character to indicate hotspots and removes it when inserting to the document. It’d be nice to actually regex match $(.*) like in DoxyIt so QuickText could have named hotspots, but alas the code implementing the hotspot identification is just iterating character matching through the string - I’d need to redesign that as well to do a regex match and account for the additional characters.

I just don’t have the C++ chops to make these changes easily (although they probably are pretty straightforward for someone who knows what they’re doing in C++).