#2350 perl function list

Next_Release
open
nobody
perl (2)
5
2013-12-23
2013-11-16
Remo Rickli
No

Perl function definitions can look like "sub hello {", but the filter requires "sub hello (){". I tried editing the regexp in functionlist.xml, but could not get right...

Discussion

  • James
    James
    2013-12-20

    Please forgive me for (I assume there is a protocol) not submitting this 'patch' properly.

    Change functionList.xml "function" line (it was line 162 in mine from v6.5.2) for Perl from:

    <function mainExpr="sub[\s]+[\w]+[\s]*\([^\)\(]*\)[\n\s]*\{" displayMode="$className->$functionName">
    

    to:

    <function mainExpr="sub[\s]+[\w]+[\s]*\(?[^\)\(]*\)?[\n\s]*\{" displayMode="$className->$functionName">
    

    It makes the parens after the function name optional.

     
  • James
    James
    2013-12-20

    I noticed that commented-out subroutines were showing up in the function list. While that may be desired by some people, I'd prefer to keep my function list populated with only "live" functions and keeping "dead" functions off the list.

    Here is a slight revision to the expression that seems to work well in my limited testing:

    <function mainExpr="^[\s]*(?<!#)[\s]*sub[\s]+[\w]+[\s]*\(?[^\)\(]*\)?[\n\s]*\{" displayMode="$className->$functionName">
    

    Note: This only works for line comments (#) and not POD documentation (=head, =cut, etc):

     
  • Remo Rickli
    Remo Rickli
    2013-12-23

    Thanks for sharing! However no matter what I change in functionList.xml, npp doesn't seem to pick it up. I've restarted npp and even rebooted...

    What am I missing?

     
  • James
    James
    2013-12-23

    I installed my N++ with the default options. I was originally editing the functionlist.xml in the program directory and, like you were experiencing, my changes weren't effective.

    I did a little searching and found http://notepad-plus-plus.org/features/function-list.html. I learned that there is a different copy of functionlist.xml in %APPDATA%\notepad++. Once I edited that file and restarted N++, my changes were effective and the function list started working for me in perl.

    Good luck!

     
  • Remo Rickli
    Remo Rickli
    2013-12-23

    Ah goodness, I forgot about that! Works like a charm, you just made my day :-) Hope this line makes it into the distribution...