Community
    • Login

    Wrong syntax highlightning

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 4 Posters 922 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • peter szammerP
      peter szammer
      last edited by peter szammer

      Notepad++ 8.1.9.3
      In lisp file, “;|” and “|;” mark a comment block and should be displayed in comment color.
      But only the first line beginning with “;|” is displayed correctly and the color of the other lines looks incorrectly. Is this sa bug?
      It seams, that n++ interpreting “;” before “|” as a commentLine, but in union with “|” it should be interpreted as commentStart.
      The codeline in the lang.xml is …

      <Language name="lisp" ext="lsp lisp" commentLine=";" commentStart=";|" commentEnd="|;">
      

      All other highlightnings in Lisp,lsp are right.

      What I’m doing wrong?
      Please help.
      Thanks

      EkopalypseE 1 Reply Last reply Reply Quote 1
      • EkopalypseE
        Ekopalypse @peter szammer
        last edited by

        @peter-szammer

        I would try to define both in comment style, e.g.

        open: ;| ;
        close: |; ((EOL))

        1 Reply Last reply Reply Quote 1
        • ArkadiuszMichalskiA
          ArkadiuszMichalski
          last edited by ArkadiuszMichalski

          This setting is only for toggle line/block comments (not highlightning, the lexer is responsible for it). I don’t know how Lisp block comments look like, but the current lexer recognizes #|comment|#.

          peter szammerP 1 Reply Last reply Reply Quote 2
          • peter szammerP
            peter szammer @ArkadiuszMichalski
            last edited by

            @ekopalypse … thank you for response!
            But: negativ
            Just the first line after commentStart is right, but all others not.

            @ ArkadiuszMichalski
            I know that the color are made by lexer … strange is, that only “COMMENTLINE” and “COMMENT” is available in lexer. Here “COMMENT” can only mean the commentblock. Or?

            But I don’t understand why in C the commentblock with …
            commentStart= “/" commentEnd="/”
            works after all?
            And in Lisp …
            commentStart= “;|” commentEnd=“|;”
            works not.
            Strangely laborious.

            EkopalypseE PeterJonesP 2 Replies Last reply Reply Quote 0
            • EkopalypseE
              Ekopalypse @peter szammer
              last edited by

              @peter-szammer

              Ok, now I understand @Arkadiusz-Michalski’s answer.
              For whatever reason, LISP and three other lexers were in the disabled languages box for me and so I didn’t see them when I checked the lexers via the languages menu, which led me to believe it was a UDL issue, which it clearly is not.
              Sorry for the confusion.
              The LISP lexer only considers |# for comment blocks.

              EkopalypseE 1 Reply Last reply Reply Quote 1
              • EkopalypseE
                Ekopalypse @Ekopalypse
                last edited by Ekopalypse

                My current understanding of the lexer is that when it detects a #, it switches to the SCE_LISP_MACRO_DISPATCH state, and when the next character is a |, it switches to SCE_LISP_MULTI_COMMENT, which then resolves to SCE_LISP_DEFAULT when |# appears.
                Does this make sense?

                1 Reply Last reply Reply Quote 2
                • PeterJonesP
                  PeterJones @peter szammer
                  last edited by

                  @peter-szammer said in Wrong syntax highlightning:

                  But I don’t understand why in C the commentblock with …
                  works after all?
                  And in Lisp …
                  works not.

                  Because, as @ArkadiuszMichalski already said, the commentLine, commentStart, and commentEnd attributes in the langs.xml are only used by the “toggle line/block comments” – which means for the Edit > Comment/Uncomment menu actions:
                  bc1d4fb6-11fe-40b4-b823-67c5a5a2edb0-image.png

                  The syntax highlighting is handled by a library of compiled C++ “lexer” code inside Notepad++; the lexer for C/C++ knows that /* ... */ is a block comment and // is a line comment; the lexer for LISP believes that #|comment|# is the block-comment syntax for LISP. The LISP lexer does not look at the XML attributes mentioned above when deciding what is and is not a comment, and you cannot change what the lexer considers a comment by changing those attributes in the langs.xml config file.

                  If the LISP lexer implementation is wrong, then it would have to be proven wrong in the original Scintilla library implementation, then a bug reported to Scintilla (which is a completely separate project, which the Notepad++ developers have no influence over), then they would have to decide to fix it, and release a new version of the Scintilla library, and then Notepad++ developers would have to incorporate that newer version into the Notepad++ codebase. If it happened at all, it would be a long process. (And you would have to check; Scintilla has gone through quite a few versions since the last time Notepad++ updated, so maybe the Scintilla LISP lexer already has the updates you desire.)

                  However, if you wanted a workaround until such time as Notepad++ officially considers those extra LISP notations to be comments, you can add extra highlighting to a builtin lexer (like the LISP lexer) using regexes via the PythonScript plugin in conjunction with the script EnhanceAnyLexer.py that @Ekopalypse shares in his github repo: install PythonScript plugin using the Plugins Admin, install the script per the instructions embedded in the downloaded EnhanceAnyLexer.py file; follow the instructions in that script for customizing it with a regex to match your desired line comments – something like r';\|.*?\|;' as the regex to match (where the backslashes are necessary because regex engine thinks | means LOGICAL-OR, not the literal | character).

                  PeterJonesP 1 Reply Last reply Reply Quote 1
                  • PeterJonesP
                    PeterJones @PeterJones
                    last edited by

                    User manual PR#306 should clarify this in the user manual.

                    Assuming it is accepted and merged, the new verbiage will be in the next release of the npp-user-manual.org website, which will likely happen soon after the next version of Notepad++ is released.

                    Until it is merged, there is still time for further clarification if people wanted to comment on the chosen wording/explanation.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors