Does Autocompletion require a formal lexer?
-
Hello again.
I thought might try and take a stab at the autocompletion feature, and I’m pretty sure I did the xml file properly. I’m only, again, trying one function just to test if it works. When it didn’t, I re-read the manual and it mentions:
These function lists are stored in auto-completion definition files, each named according to its language. (The words in these files do not necessarily include all the keywords listed in the lexer definitions.) These files can specify which of the words are keywords and which are functions; functions support an additional completion feature, “parameter hint.”
So, unless that lexer references the UDL, it insinuates to me that another file is required. I’ve noticed also, that I can’t get the
dBASEPlus
to show up in the languages dialog in the preferences dialog…so not sure if that has anything to do with it.Here is my autocompletion file:
<?xml version="1.0" encoding="Windows-1252" ?> <NotepadPlus> <AutoComplete language="dBASEPlus"> <Environment ignoreCase="yes" startFunc="(" stopFunc=")" paramSeparator="," terminal="" additionalWordChar = ""/> <KeyWord name="fopen" func="yes"> <Overload retVal="FILE handle" descr="Returns a file handle to use"> <Param name="filename expC" /> <Param name="access expC" /> </Overload> </KeyWord> </AutoComplete> </NotepadPlus>
Below is a couple of screenshots that what’s going on elsewhere that I think are supposed to be matching also, the language is showing in the language selection menu:
Below is the UDL showing the word in the keyword list, which I have the bold set for when it displays:
These are my preferences settings:
Below shows no word completion box:
Below shows no Function hints:
Below shows no hint or completion, but the UDL is recognized properly:
So does auto-completion require an lexer for the language be built to use it? Do my files, settings etc look right if a lexer isn’t needed? I have read the manual, but maybe I missed something or didn’t understand something?
Sorry for the long post and pics, but…tried and don’t seem to be getting anywhere yet.
Thanks in advance.
Lee
-
No, it doesn’t need a full lexer. Autocompletion, like functionList, works just fine with UDL, when properly set up.
And your
autoCompletion\dbaseplus.xml
works for me. I put that in my autoCompletion folder, and it “just worked”.I am not sure why you aren’t seeing the autocomplete, because I do:
When I type enough characters of
fopen
, it pops down and shows fopen, even though it wasn’t anywhere else in my active document. And when I type the open paren, or do Ctrl+Shift+Space after the paren if it’s gone away, I see the function parameter completion:
If something has temporarily interfered with the function-name autocompletion, you might try Ctrl+Spacebar (or Edit > AutoCompletion > Function Completion) to get it to re-popup… and with that version, it will only show functions, not other words (like
false
) that start with the same letters(s) – so typingf
then Ctrl+Spacebar will just pop downfopen
, notfalse / fopen / function
(which include all words starting withf
that are already in my document).
-
@peterjones, I did try the Ctrl+Spacebar, which is why I thought I did something wrong. Nice to know:
1.) It doesn’t need an external lexer
2.) It works for you, as is, meaning I did something rightUnfortunately, it still means I’m doing something wrong. Per chance, does your dBASEPlus show up in the preferences dialog for languages that can be selected, and/or did you import or put in the actual languages list the dBASEPlus definition, or just the dialog?
It’s crazy that I can’t see it working, but I will say, when I was trying to use it, there was a bit of flash in the screen where I would have expected it to be, like it is when I’ve used the other languages, or when I’ve been typing and there have been words in already where it tries to show them as options.but why it’s not working now for ME…has be dumbfounded. :( I’ll look around maybe I did something wrong in my setup. ::shrug::
Thanks for testing it and veryifying that it does indeed work. My Christmas present will be huge for the community if I can get this to work in all 3 modules…without these kinds of problems I’m experiencing now. :)
Lee
-
Are you sure you have the autoCompletion file in the right folder? User Defined Languages and Function List config files can go in
%AppData%\Notepad++\
, but the AutoCompletion files must go in the<installDirectory>\autoCompletion\
folder:Auto-complete files files are located in the autoCompletion\ subfolder of the Notepad++ installation folder (unlike some config files, these will not work in the %AppData%\Notepad++\ hierarchy).
– https://npp-user-manual.org/docs/auto-completion/#auto-completion-file-formatFor your reference, I have zipped up my portable copy that has a minimal combination of UDL, functionList, and autoCompletion working with the examples that you have shown. I will message you a temporary URL (only available for a few days) for downloading the zipfile.
-
@peterjones , I figured it out, but now I’m also kind of confused about something, so…Yay on the one, and wow, on the second. :)
Apparently, I had to copy the file into the installed directory in the
C:\Program Files (x86)\Notepad++_8_1_9_2_64bit\autoCompletion
directory. Now maybe I’m misunderstanding something, but I thought the 64 bit applications were installed in theC\Program Files\Notepad++\autoCompletion
directory? I started naming the installed programs because when I had multiple copies of NPP I was getting confused because a 32bit would ask to update and I’d get a 64bit install, when I was trying to keep them separate and be able to run both. Maybe I’m misunderstanding how the 64bit and 32bit are supposed to be installed? Here’s my screenshots of what I mean.Program Files:
Here, they didn’t work.Program Files (x86), where it does work:
Am I confused about the proper separation of the two versions, or did I do something that’s supposed to be impossible? :)
Lee
-
@peterjones , Thanks, we must have crossed paths, I was answering while you were uploading. :)
As you see, I figured it out what I had to do, but as I mentioned, a little confused on what I thought was the proper place for 64/32 bit apps. :(
Lee
-
@peterjones
To head off a possible question here’s my debug along with screenshot of the version I’m using to do this.Debug:
Notepad++ v8.1.9.2 (64-bit)
Build time : Nov 21 2021 - 04:30:20
Path : C:\Program Files (x86)\Notepad++_8_1_9_2_64bit\notepad++.exe
Command Line :
Admin mode : ON
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Home (64-bit)
OS Version : 2009
OS Build : 19043.1348
Current ANSI codepage : 1252
Plugins : mimeTools.dll NppConverter.dll NppExport.dllScreenshot:
-
On a 64bit OS, it is generally set up so that 64-bit applications go in the
C:\Program Files\
, and 32-bit applications install intoC:\Program Files (x86)\
. I don’t know how you confused things so much – other than when installing programs, you can usually choose a different location to install into, and maybe you chose the wrong one when installing each.If I were the one doing it, I would uninstall both; install 64-bit Notepad++ in the right location, and just use a portable unzip on the rare occasions that I wanted to use 32-bit. It seems to me that having two installations using the same
%AppData%\Notepad++
configuration would be confusing (and possibly causing problems) – especially if you are running both simultaneously.On my home computer, I have a recent 64bit installed, and I have portable zips available for most historic versions in both 32bit and 64bit since v7.6.3 to be able to help people in the Forum, starting from an out-of-the-box, so that my customizations don’t interfere with answering questions. At work, I have my primary NPP as a highly-configured portable unzip in one location (I was having to ask IT for
Program Files
write permission every time I upgraded NPP or tried a new plugin, so moved to a portable in a non-controlled folder, and just use user-level file associations to point to the portable version – thus not requiring elevated permissions. -
@peterjones
Okay, so I’m not confused what’s supposed to go where, but obviously, I did something that’s not supposed to happen…because yeah, I was selecting where to install and probably never noticed the start of the path because I was just naming the new one to the version it was. Figuring theye were new and may screw something up, I probably started keeping them in named versions. Obviously, that’s on me then, but mind you, this is after years of using them, so I tend to keep version separate until I was sure there wasn’t anything buggy going on, and just never cleaned house…until starting this project. I’ll save my files and do the uninstall and normalize my setup.I kind of remember why now, I still didn’t plan to upgrade Windows past my last purchased verions, which was Win 2000, and then I got I think XP for a puter for my wife, so that was my last purchased version. Everything now has been on my laptop which came with 8.0 on it and then 8.1, which I’d have erased if they hadn’t updated it for free because of the phone UI they were trying to implement on the desktop. If it wasn’t “free” on the puter, I’d have been well in to Linux on it by now. :)
Anyway, sage advice if I want to keep both versions So thanks for the advice, the confirmation of my working mods, and the advice and help trying to implement this dBASEPlus package, which, is way overdue.
Lee
-
@lycan-thrope
I’ve got a question about possibly handling duplicates in the Autocompletion file, if they’re allowed and/or how to handle them if they are.dBASE, for those that don’t know, is one of the original big 3 of PC desktop applications in the early days. Since then, a lot of updating has been done, and one of the early changes was making a small SQL variant in the langage called LocalSQL, that allows dBASE’s tables and other database variants tables to be used inside dBASE with that LocalSQL. Unfortunately, there are a couple of actual Functions that are identically named, but handled differently. The dBASE editor handles them appropriately in the IDE and programs. I’d like to be able to provide the identical word, to be used by both, but the hints on completion would be different.
I’m asking if that is possible and if not, cie la vie.
Thanks in advance for any insight,
Lee
-
@lycan-thrope
Well, I guess I answered my own question. I put both in with different descriptions and parameter number and the result it, it went with the first one in the list, meaning, it’ll never reach the second.I guess a work around could be just putting the Function attribute in, but putting a text with advice on the two options, if the text hint can be big enough, so they can look at it, while they type it, but not putting any parameters in so it will stay up instead of jumping to the variable as it’s being filled in. Got to go try it.
Lee
-
@lycan-thrope said in Does Autocompletion require a formal lexer?:
handling duplicates in the Autocompletion file, if they’re allowed and/or how to handle them if they are.
If I understand correctly. the same name has different parameter lists: am I correct?
If so, you can look at the Perl autocompletion that ships with NPP – for example, the
eval
has multiple option lists, which are implemented by multiple<Overload>
entries in the same<KeyWord>
:<KeyWord name="eval" func="yes"> <Overload retVal="" descr="catch exceptions or compile and run code"> <Param name="BLOCK" /> </Overload> <Overload retVal="" descr="catch exceptions or compile and run code"> <Param name="EXPR" /> </Overload> <Overload retVal="" descr="catch exceptions or compile and run code"> <Param name="" /> </Overload> </KeyWord>
You’ll see a little
1 of 3
with arrows for choosing between them
And if it does something different with each argument list, you can even have a different Description for each.
This is described in the Overload section of the autocompletion docs
-
@lycan-thrope
That did the trick. Still comes up with a hint, but stays up while typing and I was able to basically document the two differences in the description. Problem solved. :) If there are any other tricks I don’t know about that can make it work otherwise, any help would be appreciated.Lee
-
@peterjones ,
Thanks…I just saw it when my own response was loading. LOL Thanks that looks a lot more effective.Lee
-
@peterjones ,
Thank you again, that worked perfectly. I guess I didn’t catch that in the Overload section as I thought that it meant for each of the Overload sections…not realizing it meant for each keyword. Thanks again for catching my lack of understanding what I’m reading. :-) I did call you a genius, now you’re a mind reader. Heheh.Lee
-
Here’s what I went with, adding the reason for each version, so there would be no mistakenly taking the one without knowing which it applied to.
<KeyWord name="MAX" func="yes"> <Overload retVal="{Greater value}" descr="dBASE - Compares two numbers (or two date, character, or logical expressions) and returns the greater value."> <Param name="value exp1" /> <Param name="value exp2" /> </Overload> <Overload retVal="{Greater value}" descr="SQL - Compares provided expression and returns the greater value"> <Param name="value exp1" /> </Overload> </KeyWord>
There is duplicates for at least each SQL function used as well as equivalents in dBASE. For instance, the Upper() and Lower() are identical, so I didn’t see any need to worry about those, since they take the same kind and number of parameters, but as you can see, Min() and Max() take different numbers of parameters and perhaps types.
Thanks again.
Lee
-
@lycan-thrope
I have a little problem. I filled in a keyword function here:<KeyWord name="ACOPY" func="yes"> <Overload retVal="{nVal}" descrip="Copies elements from one array to another. Returns the number of elements copied."> <Param name="<source array>"/> <Param name="<target array>"/> <Param name="[<startingelement expN>]"/> <Param name="[<elements expN>]"/> <Param name="[<targetelemnt expN>]]]"/> </Overload> </KeyWord>
But this is all that shows:
I’m missing some text and not quite sure why. Any ideas? I don’t see any out of place syntax highlighting in the text, even though it is long. Is there a limit to length before it’s ignored?
Thanks in advance.
Lee
-
@lycan-thrope
On a hunch, just in case, I need to disclose that the keyword just before it doesn’t have a “Parameter” section in the “Overload” section, like so:<KeyWord name="ACCESS" func="yes"> <Overload retVal="{accessLevelN}" descrip="Returns the access level of the current user for DBF table security."> </Overload> </KeyWord>
Just in case that may have something to do with it. As I read the Autocompletion section, the parameter was an option, as is the description, but in this case, this function returns a security level of the user, and takes no parameters, as far as I know, but it does return an access level number for the users access priveledges. Hence, no parameter supplied…unless it needs to have a Null parameter there. Just an FYI for full disclosure. I also can’t get the description for this function which is why I bring it up. The other desciptions past these two work, but these two don’t so I have reason to believe ther’s something there that’s wrong, but I’m just not seeing it, especially since I don’t see any syntax highlighting goofs.
Lee
-
Hello, @lycan-thrope, @peterjones and All,
@lycan-thrope, why do you use :
<Overload retVal="{nVal}" descrip="Copies elements from one array to another. Returns the number of elements copied.">
And not :
<Overload retVal="{nVal}" descr="Copies elements from one array to another. Returns the number of elements copied.">
Maybe, this syntax explains the problem ? ( not tested ! )
BR
guy038
-
Argh… Thanks.
I had made my self some skeletons to copy/paste to test some of the functions and parameters that I thought might give me problems before trying to do the file enmasse with the wonderfully written hints about how to mass format a keyword list…and apparently my hand typed abbreviations deviated from the proper abbreviations. :-(
Thanks… in my defense, it was another all-nighter and blurry eyes were present. :-)
Lee