Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: IDE for Perl programming? ( *cperl-mode* bug)

by LanX (Saint)
on Mar 12, 2021 at 17:08 UTC ( [id://11129517]=note: print w/replies, xml ) Need Help??


in reply to Re^3: IDE for Perl programming? ( *cperl-mode* )
in thread IDE for Perl programming?

> unfinished tr with _ as delimiter.

actually it's definitely a bug in cperl's parser, the only way to have valid word characters as delimiers for quote-like operators is to prepend a whitespace

The cases where whitespace must be used are when the quoting character is a word character (meaning it matches /\w/):

q XfooX # Works: means the string 'foo' qXfooX # WRONG!

DB<21> $_= "ab"x6 DB<22> use strict; y _a_X_ DB<23> p XbXbXbXbXbXb DB<23>

Though I must say this is one of the features of Perl I wouldn't ever miss...

... can we please have a feature to switch that (and y ) off?

Pretty please!

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^5: IDE for Perl programming? ( *cperl-mode* bug)
by haj (Vicar) on Mar 12, 2021 at 23:24 UTC
    There's also the opposite case where you must not use whitespace:
    # This works and means the string 'foo': q#foo# # This is a single q, #foo# is a comment. q #foo#
    Funny, eh?
Re^5: IDE for Perl programming? ( *cperl-mode* bug)
by haj (Vicar) on Mar 12, 2021 at 23:04 UTC

    Yes, it is a bug in the parser. In that monstrosity which analyses POD, Here-docs, regexes, and quote-like constructs, because in all of these things characters may change their meaning. choroba filed Bug#47112, a quick patch is coming soon.

    By the way: You can, in fact, eliminate that bug without any patch by setting the customizable variable cperl-under-as-char to t.

    Sigh. This dates back to a change Richard M. Stallman himself committed in 1998. Let's see whether I manage to revert that.

      > Yes, it is a bug in the parser.

      I'm not so sure anymore. The parsing problems disappear as soon as I start emacs with -q

      so something in my init-files seems to trigger the problem.

      Tested with

      • emacs 24.3 on Win and Ubuntu
      • emacs 27.1 on Win.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      PS: In respect to cperl-under-as-char

      This variable is obsolete since 24.4; use ‘superword-mode’ instead.

        Well, there is a bug in CPerl mode. It is a bit evasive and not that easy to trigger. choroba has filed a bug report and there's a patch which you should be able to use at least in Emacs 27.1. It also contains a test case with a sequence of commands which triggers the bug in Emacs 26.1 to Emacs 28.

        I am well aware of the deprecation of cperl-under-as-char and provided it only as a possible workaround. By the way: There be dragons. Superword mode treats all symbol characters as word characters, and in CPerl mode the colon : is also a symbol character.

        In general, the fontification of CPerl mode should not depend on the setting of this variable nor on the setting of superword mode, and in most (but not all, as we see here) cases the underscore is explicitly included when parsing Perl identifiers.

        When I open a file with sub y_max {}, it displays correctly, but if I insert a newline before it, it goes back to the wrong highlighting even with -q.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      > By the way: You can, in fact, eliminate that bug without any patch by setting the customizable variable cperl-under-as-char to t.

      tried this, but unfortunately no avail. :(

      > Yes, it is a bug in the parser. In that monstrosity which analyses POD, Here-docs, regexes, and quote-like constructs, because in all of these things characters may change their meaning.

      I still think the only viable way is to have an expandable set of tests with Perl snippets to parse.

      An external Perl script should run them thru different emacs installations in batch mode.

      I started working on this some years ago, have to dig this out again ...

      ... unfortunately I am a bit too exhausted at the moment to do it right away.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129517]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-19 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found