HaraldJoerg / cperl-mode

Bring new language features and popular DSLs into cperl-mode
GNU General Public License v3.0
22 stars 6 forks source link

A command to run perltidy with the input from an emacs buffer #5

Open bojinlund opened 4 years ago

bojinlund commented 4 years ago

I have in most of my Perl files:

# (compile (concat "perltidy " (buffer-name)) nil) # (ediff-files (concat (buffer-name) ".tdy") (buffer-name)) to make it easy to tidy up a file.

A command in the modernized cperl-mode to run perltidy with the input from a emacs buffer hade been good! Also, to run perltidy with input from a buffer which has not yet been saved, and write the output to another buffer

HaraldJoerg commented 4 years ago

I have discovered that there's already a perltidy tool for Emacs, in the CPAN distribution Emacs::PDE, and also apparently some forks of its perltidy.el. It doesn't support the ediff part right now, and it is this part which I like most. So, I'll push the feature with in the next days in a separate branch, and I'll reach out to Ye Wenbin about his plans: that distribution hasn't been updated since 2008.

matthewpersico commented 2 years ago

Anything ever come of this?

HaraldJoerg commented 2 years ago

Ah, ouch... thanks for the reminder.

I could not find any version of perltidy integration into Emacs which has been kept up to date with current Emacsen and could easily be enhanced. This issue also got a bit out of my focus... sorry. These days I'm working for the "original" CPerl mode which ships with Emacs - and am now allowed to commit to Emacs. This means that most changes go to the Emacs repository, and I'm taking care that they nevertheless work with Emacs 26.1 and above.

In a discussion with Emacs developers about this and similar features (for example, a better perldoc mode) they suggested that things like this could go into an installable Emacs package and thus can be used together with both perl-mode.el and cperl-mode.el. This makes sense to me but I haven't come around to learn the process of package building for Emacs.

Since perltidy integration as suggested here is a lot easier than e.g. perldoc integration, I guess I should give it a try and just write a fresh perltidy.el and publish it here to collect feedback before starting the packaging stuff. I've now moved it from the "forgotten" drawer to a new position in the "todo" stack.

HaraldJoerg commented 2 years ago

So, I've now taken a first stab at this feature - for now, in a separate file perl-tidy-ediff.el.

I am not so sure about how to distribute it "officially". I could tuck it away into cperl-mode.el, but then I'd need to obey the name convention to start functions and variables with cperl-. This is kinda ugly and also a bit beside the point, because this function works equally well with perl-mode.

It could also be an addition to one of the perltidy integrations into Emacs (there's at least one on GitHub and two on CPAN), but they all look a bit stale.

Or I could publish it together with an improved perldoc integration in a new package on ELPA.

Any feedback regarding functions, bugs, and distribution alternatives is welcome!