Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by haj (Deacon)
on Jul 02, 2020 at 16:28 UTC ( #11118830=note: print w/replies, xml ) Need Help??


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

Thanks for the feedback! To wit: ERT is Emacs Lisp Regression Testing.
  • Dividing the existing source is surely an option, but isn't very high on my priority list. There's little benefit, and a division needs care for production and installation to fit into the Emacs package. Emacs makes navigation in a big file rather easy. New features, in particular optional stuff, might go into extra files.
  • Updating the docs is ... indeed interesting. There used to be a tool (written in Perl) to convert POD to texinfo, to read it directly in Emacs, but this seems to be no longer functional.
  • I've already dropped all the special cases for XEmacs, Emacs below version 26, font-lock-extra, choose-color.el, and cperl-mode's homegrown fontification for multiline strings. Did I miss something? Apropos: The selection of the minimum Emacs version is a somewhat unfortunate consequence from cperl-mode being bundled with Emacs. I haven't checked yet how much effort a backport to, say, Emacs 24 would be.
  • Yes, I need a test suite, and I've started writing tests for the bugs I fixed. However, I doubt that I'll write tests for the existing code unless I find bug reports. Though I would love to write a test suite in Perl (the Test:: infrastructure is lightyears ahead of ERT), ERT is mandated if you want to get stuff into Emacs. Also, it isn't that easy to query the fontification of a particular character in an Emacs buffer from Perl...

With regard to integrating with Perl, a connection to modules like PPI or even Code::ART would be interesting. To quote THeDamian: How hard can that be? But then, I'm not Damian, he's doing his sourcery in Vimscript, so don't hold your breath.

  • Comment on Re^2: Breathing life into the (Emacs) cperl-mode

Replies are listed 'Best First'.
Re^3: Breathing life into the (Emacs) cperl-mode
by choroba (Archbishop) on Jul 02, 2020 at 16:47 UTC
    > 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]

      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]
Re^3: Breathing life into the (Emacs) cperl-mode
by LanX (Cardinal) on Jul 03, 2020 at 10:02 UTC
    Hi

    • division: the final .el should be a single one, sure. I was thinking of a build and testing process triggered from a Perl script joining different parts. Testing with different emacs versions° is not easy and you'll find more contributors providing Perl tests.
    • docs: sorry, you misunderstood me, cperl has a long list of one liner description for each Perl command. IMHO these should be outsourced.
    • info: What you mean is the hypertext help system which relies on static perldocs in "info" format. Info is great for navigation of deep manuals, perldocs are rather flat and should be IMHO better displayed with "woman.el" (man doesn't work on windows).
    • if you drop support for older or other versions like XEmacs you should maybe consider renaming the fork of cperl-mode

    On a different note: elisp regexing is a PITA because of slasheritis and pretty unreadable. (Btw: XEmacs solved this with raw strings)

    I was thinking of translating Perl regex to lisp to open up for a broader audience.

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

    °) and Perl versions and extensions

      About Perl documentation...
      ...perldocs are rather flat and should be IMHO better displayed with "woman.el" (man doesn't work on windows).

      Update: I've just pushed a cperl-mode where M-x cperl-perldoc just works on Windows. I didn't find woman.el particularly rewarding, though, and I took a different route. On the plus side, hyperlinks in POD files now work, and are resolved in your local installation (unless they are https links). Many perldoc pages are flat, but others like the Moose::Cookbook make more fun when links work.

      Other documentation functions of cperl-mode will also be made available on Windows, as my time permits.

      The code is at cperl-mode.el on GitHub, there's also a List of changes.

      I've also completed the FSF paperwork, so there are chances that some changes will make their way into the official Emacs distribution.

      Sorry, I'm afraid that I'm going to disappoint you...

      • division: I fail to see how a division helps with either testing with different emacs versions or finding contributors providing Perl tests. I do see, however, some overhead to set up that process and document how to use it. So that's still pretty low on my priority list.
      • Outsourcing docs: That is another job for Shouldbedone-Man. I don't see enough benefit right now.
      • info format: Having convenient access to perldocs documentation from within Emacs is a valid requirement. The requirement is not exactly new, but the tool suggested in the answer to Sean's article seems to have rotted away. So it's either getting pod2info or pod2texi back to life, or ... but wait... It seems that you already have a solution. Care to share?
      • The decision to drop support for older and other versions hasn't be done by me, but by the Emacs maintainers, before I started to hack on cperl-mode. I've only removed some conditionals where cperl-mode worked around XEmacs quirks, or provided workarounds for old Emacs versions. I intend my work to be a drop-in replacement for the cperl-mode which comes with Emacs - or maybe even become the maintainer of cperl-mode, a position which has been vacant for quite some time now. So, no, renaming is not an option.
      I was thinking of translating Perl regex to lisp to open up for a broader audience.

      Excellent! Please go ahead!

        > Sorry, I'm afraid that I'm going to disappoint you...

        You are not disappointing me at all, you asked for opinions I shared mine in the hope they might be helpful. :)

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

      Another update:
      perldocs are rather flat and should be IMHO better displayed with "woman.el" (man doesn't work on windows).

      As it turns out, this is already available. Not from Emacs nor ELPA/MELPA, but there's Emacs::PDE on CPAN. This distribution provides, among other tools, M-x perldoc which is using WoMan and works quite fine on Windows. Even better, there's a command M-x perldoc-tree which offers all local docs in a nice tree view.

      This, of course, makes a refurbishment of the perldoc stuff in cperl-mode a lot less interesting.

        Yeah I saw this already, problem is PDE is mostly abandoned, and many things don't work anymore.

        There are also other projects/bundles

        That's why I'd rather prefer decomposing features into modules which can be maintained independently...

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-08-10 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (58 votes). Check out past polls.

    Notices?