Edit: My last post here has most recent instructions.

Comments

armyofda12mnkeys’s picture

I'm working on redoing this since alot of peeps have asked for it ...
Do peeps use any of the _drupal_functions()? like the backend functions that usually start with an underscore?

armyofda12mnkeys’s picture

Here is my Drupal autocomplete,
It is custom to my system so you can use just those ...

It will be updated here:
http://www.arianhojat.com/files/drupal/notepad_plus_plus/drupal_autocomp...
and also news on it on the forum (check the last post, since can't update the links on first post):
https://sourceforge.net/projects/notepad-plus/forums/forum/482781/topic/...

#####################
___INSTALL___

First goto (Notepad++)->Settings tab->Preferences, and goto Backup/Auto-Completion,
Check "Enable Autocomplete on each input"
Choose 'Function Completion' radio button
From the 1-th character (or 3, whatever you want to start autocompletion after X characters)
Check "Function parameters hint on input".

Now paste the drupal.xml file into "C:\Documents and Settings\$$$$__YOUR_USERNAME___$$$$\Application Data\Notepad++" (this sets up autocompletion of all keywords and functions)
and
Then put userDefineLang.xml in "C:\Program Files\Notepad++\plugins\APIs" (this sets up the highlighting of all keywords,
NOTE: if you have a custom User Defined Language already setup in Notepad++, then paste the XML appropriately in this file so won't overwrite your changes, but most people will not have defined custom language already so you'll be good) ...

#####################
___USE___

Just type functions and should autocomplete and highlight when matches a keyword/func.

For some reason if you need to use uppercase keywords like MENU_CALLBACK that you can't remember, type Control+Enter and choose it from drop-down (for some reason it doesn't autocomplete for now UPPERCASE keywords, will look into it).

Also sometimes I go into (Notepad++)- >View tab->User-Defined Dialogue->pick drupal from the drop down->Operators tab, and add $ to my list of operators so common other keywords i have added like _SESSION,_POST,form_state,form_id show up as colored even if operator like $ is in front of it ... (but this messes up other things like $theme would now be highlighted even though not intended as a $keyword, your choice).

or set the colors of Drupal functions to be swapped with the 3rd Keyword List in the Keyword List tab, so Drupal functions show up as the 'drupal blue' color... but I like them more highlighted with the magenta color, your choice. Can mess with the User-Defined Dialogue box to change these color settings.

########
___ADVANCED_INSTALL__

For more advanced users, you can also customize the functions to use whatever module's functions your site has, by running the php file included...
aka take the code in the drupal_autocomplete.php and paste it into a new drupal Page set with the Php Filter, and submit the page. The code will go through all the Drupal functions enabled by modules on your system for you to paste them into (Notepad++)->View tab->User-Defined Dialogue->Keyword Lists tab->Keyword List 2 (so it can highlight Drupal keywords)... It will also automatically create a new drupal.xml in your Notepad++ directory update those functions so they not only highlight but autocomplete ( aka it will recreate the drupal.xml file). Note: i parse out backend functions aka those that start with _, so you can add those manually to the array if you need them on 1-on-1 basis (or take out the regex code taht strips out these functions, but i have a feeling its alot of functions most people don't use). PS with all the php modules enabled, the php keywords to paste into Keyword List 1 may be too big, so just paste the ones in my XML since they are more core functions.

Enjoy!,
Arian Hojat

marcvangend’s picture

Thanks Arian. I think the concept is great, but so far, it doesn't work the way I hoped.

First of all, it turned out that I had to put userDefineLang.xml in "C:\Documents and Settings\$$$$__YOUR_USERNAME___$$$$\Application Data\Notepad++" to get it to work.

Second, I noticed a bug that escaped quotes in strings are not handled properly by the syntax coloring.

My biggest concern, and the reason that I will not be using this for now, is that 'drupal' is defined as a language that is completely separate from PHP. (This is perhaps due to the way Notepad++ allows for user defined languages - I don't know.) IMHO, the ideal N++ Drupal plugin would not be equivalent to, but extend the PHP language definition. Advantages would be that syntax coloring is inherited from the php language definition (so drupal and non-drupal php code looks the same) and N++ suggests both Drupal keywords and native PHP keywords.

armyofda12mnkeys’s picture

>First of all, it turned out that I had to put userDefineLang.xml ....
Yes, the 2 file locations i got wrong in the README.txt and the locations should be swapped. Doh, my fault, the readme updated.

>Second, I noticed a bug that escaped quotes in strings are not handled properly by the syntax coloring.
I can see this happening possibly for certain things, can you send an example of code after changing above so 2 files in right places. I may or may not be able to fix it
UPDATE: i updated the userDefineLang.xml file, or try going into the (Notepad++)- >View tab->User-Defined Dialogue->pick drupal from the drop down->Operators tab and
checking escape character and using \ if thats yer escape char I'm assuming in strings.

>is that 'drupal' is defined as a language that is completely separate from PHP.
>IMHO, the ideal N++ Drupal plugin would not be equivalent to, but extend the PHP language definition.
Well notepad++ will suggest both keywords if the drupal.xml is in correct location (APIs folder). I extended the php.xml autocomplete with drupal keywords/functions (hence the drupal.xml is both combined)...
As for the color highlighting, you can go into (Notepad++)- >View tab->User-Defined Dialogue->pick drupal from the drop down->Keyword Lists tab-> and in the textarea for the 2nd Group, change the color of the drupal keywords to be the same as php (blue or maybe a slightly off blue like the drupal turquoise color which is what I'd prefer over same color).

-Arian

marcvangend’s picture

Thanks for the quick reply.

Changing the file locations indeed fixes the inheritance of PHP keywords.

The escaping bug was seen in the following code:

$string1 = 'this is a string';
// this is a comment
$string2 = 'this: \' is an apostrophe';
// this is another comment

Your fix in the update works (it changed line 4 in my userDefineLang to <Global caseIgnored="no" escapeChar="\" />). Thanks for that.

I now changed the colors manually to match my php-coloring settings, which is good enough since I don't change the coloring on a daily basis :-)

armyofda12mnkeys’s picture

P.S. just updated the files again so things like MENU_CALLBACK and __CLASS__ can autocomplete, and code-folding for {} works.

AND
If you ever need any custom functions added that aren't highlighted/autocompleted, you can add them to the respected View->User-Defined Dialogue->Keyword List for color highlights,
and for autocomplete, add the function/keyword in ASCII order in the drupal.xml file.

or can use the optional php file in the zip to auto-magically help create the file(s) needed (aka I can see peeps who use cck/views to enable those modules, then run my script which will re-create the function autocomplete file and give output to paste into the Dialogue screen for color highlight. Note: However php has alot of functions depending on modules enabled, and that textbox is limited to 30k chars, so I just keep the core functions in my orig userDefinedLang.xml file unless need to add specific ones).

dropletCUCC’s picture

Your site is down is it possible that you still have the UserDefined language for your Drupal API. I am working in Notepad++ and this would be a great help.

jadolyo’s picture

The download like is dead now, I searched on Google and I found dead links too, So anyone can upload the files again, Thank you.

armyofda12mnkeys’s picture

Sorry about that, I'll take a look later this weekend.
No one was really interested in it but i thought it was very useful since i thought alot of Windows people would use Notepad++ for php/drupal ...

Do you need to Drupal 6 or 7?

I can take a look at customizing 2 sets of those Notepad++ language XML's for Drupal 6 and 7...
Should have something by this week/end.

EDIT: give me a lil more time... Working with Notepad++ people to resolve some issues that cause Notepad++ to crash if the keyword list is too long.

-Arian

armyofda12mnkeys’s picture

I made the Notepad_++ files for Drupal6 and 7 from a recent install of drupal on a php 5.3 server...
One annoying factor is that Notepad++ doesn't allow > 31K chars in their keyword lists (Its being fixed now in Beta)... So i put the extra keywords for php/drupal that overrun that limit into Keyword Lists 7 and 8 respectfully ...

https://dl.dropboxusercontent.com/u/36600570/drupal/notepad_plus_plus/Au...

Quick Video Install and Demo:
http://screencast.com/t/mkkLPJ2m

Detailed Instructions:

0. Do not have Notepad++ open... Close it.

1. Make sure have latest version: Notepad 6.3.3 which is what i tested on
Wont guarantee other versions as the UDL file format has changed.

2. Copy drupal6.xml and drupal7.xml to C:\Program Files\Notepad++\plugins\APIs (or Notepad++ folder might be in 'C:\Program Files (x86)\Notepad++\plugins\API' if on a 64 bit computer and installed the 32 bit Notepad++ version).

3.
Did you do a default install of Notepad++ (specifically, did you not change the part where it asks you to install your personal settings into %AppData%, which is the default location)?

  • Yes:

    Do you have a userDefineLang.xml file already in C:\Users\$$$$__YOUR_USERNAME___$$$$\Application Data\Notepad++ or C:\Documents and Settings\$$$$__YOUR_USERNAME___$$$$\Application Data\Notepad++ ('Yes' would implies you've imported other langs before into Notepad++)?
    • No (most common scenario and easiest way to install):

      Easy to just copy userDefineLang.xml to C:\Documents and Settings\$$$$__YOUR_USERNAME___$$$$\Application Data\Notepad++
    • Yes:

      Open Notepad++ and goto Language->Define your own Lanuage and do 'Import' from this file I created so it'll merge my stuff into your current userDefineLang.xml
  • No:

    Copy or Merge via the userDefineLang.xml to whereever you stated to store Notepad++ settings.

4. Start up Notepad++ ....
Go into Settings->Preferences... Backup/Autocomplete:
and:
check 'Enabled auto-completion on each input'
Use 'From the 3rd character' or whatever amount of letters want the autocomplete to use to hint available functions
click 'Function completion'
check 'Function parameters hint on input'

5. Now open a .module file... Right now i have drupal6 defaulted at .module files...
but if you mostly a Drupal7 user, you can go into Language->Define your own Language... Switch to drupal6 and drupal7 in the 'User Language' dropdown, and swap both 'Ext.'.

Note: if its a .php file that you want to use this User Defined Language for, just go into Languages tab and pick 'drupal6' manually ... or you can associate .php extension with this language ... but i prefer to manually pick for non-.module files (like usually i'll use Notepad++'s default php highlighter for .php files, but switch to my drupal6 custom language manually if i need to edit a .inc or .php file that has drupal functions).

6. if would like a php or drupal keyword added/deleted, switch to Keyword List's tab and add appropriately in List7 or 8 which i reserved for extras (and also >31k keywords since can't fit into List1 and 2 respectfully).

PS for advanced users: There is a way to custom generate these files based on your server (as maybe you enabled some other php modules and want to autocreate those files to get autocompletion based on what your server has)... but its a bit difficult for average user's maybe so hence why packaging my own for everyone to use... I used the php Reflection classes to generate the autocomplete as best as could... Generally i did it with putting the php code in drupal_autocomplete.php into a new Page with the php filter, then visited the page... Then copied the generated keywords listed on the page's textareas into the Notepad++ Keyword Lists so it can have custom styling (that Language->Define your own Language popup)... and the drupal.xml file is created automatically which has the autocomplete info.

leofishman’s picture

dropbox return 404, is there any other link to download it?

thanks a lot!