Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Breathing life into the (Emacs) cperl-mode

by choroba (Cardinal)
on Jul 02, 2020 at 16:47 UTC ( [id://11118831]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Breathing life into the (Emacs) cperl-mode
in thread Breathing life into the (Emacs) cperl-mode

> it isn't that easy to query the fontification of a particular character in an Emacs buffer from Perl

Just use htmlize and your favourite Perl HTML parser ;-)

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^4: Breathing life into the (Emacs) cperl-mode
by haj (Vicar) on Jul 02, 2020 at 19:40 UTC

    Thanks, but I pass :) For our notorious snippet $a++ / $b; # /; htmlize provides:

    $a++ <span class="constant">/</span> <span class="string"> </span> <span class="variable-name">$b</span> <span class="string">; # </span> <span class="constant">/</span>;

    That surely is a lot of noise. As you can see (you can, can't you?), this is the output from a broken cperl-mode.

    My preferred approach for large-scale fontification tests would be Lindydancer's faceup markup, which together with the other repositories by the same author are really awesome tools to debug and test font-lock features.

    Advertisement: As a recent addition, I added Damian Conway's "Perl Best Practice" recommendations for indenting code to M-x cperl-indent-style. I guess that amongst Perlers PBP is waaay more popular than K&R, BSD, or GNU conventions.

      But after your fix, it gives a bit more sense:
      <span class="variable-name">$a</span>++ / <span class="variable-name"> +$b</span>; <span class="comment-delimiter"># </span><span class="comm +ent">/; </span>
      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11118831]
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-16 19:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found