Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow older versions of perltidy to use newer .perltidyrc files #146

Open
jidanni opened this issue May 20, 2024 · 4 comments
Open

Allow older versions of perltidy to use newer .perltidyrc files #146

jidanni opened this issue May 20, 2024 · 4 comments

Comments

@jidanni
Copy link

jidanni commented May 20, 2024

Here I can use my .emacs file safely, no matter what version of emacs
I'm using.

$ cat .emacs
(and(functionp 'native-compile-prune-cache)
    (native-compile-prune-cache))

It would be great if .perltidyrc had a similar mechanism,
so I could say e.g.,

--if-implemented-yet -- --want-trailing-commas=1
--if-implemented-yet -- --add-trailing-commas

to avoid causing

Unknown option: want-trailing-commas
Unknown option: add-trailing-commas
Error in this config file: /home/jidanni/.perltidyrc
Use -npro to ignore this file, -h for help'

in the case I had used my newer .perltidyrc on a machine with an older perltidy.

Wait, https://www.perlmonks.org/?node_id=1165148 shows how to do it in
general in perl, so there could be something similar for .perltidyrc,
other than needing to have a different file for each different version
of perltidy.

Anyway, with my --if-implemented-yet, the user wouldn't even have to look up specific version numbers.

@shancock9
Copy link
Contributor

A scheme like this would have had to have been implemented long ago to be
useful.

It would be possible to write a replacement script for the perltidy binary
which filters out unrecognized parameters from a .perltidyrc and sends a
modified version to the Perl::Tidy module.

But if a new binary is going to be involved, a simpler thing to do on a system
that you do not want to update would be to make a special binary with the latest
version and put it in your personal bin directory. To do this,

  • download and unzip the latest tarball in a temporary area
  • cd into the new folder
  • enter ./pm2pl
  • this creates a single file called something like perltidy-20240511.pl
  • move and rename this to something more convenient, perhaps ~/bin/perltidy-latest.pl

The installed version of the Perl::Tidy module will be unchanged, but the new
binary does not use it

@jidanni
Copy link
Author

jidanni commented May 20, 2024

A scheme like this would have had to have been implemented long ago to be
useful.

Never too late to start :-).

@oalders
Copy link
Contributor

oalders commented May 22, 2024

This seems like a pretty niche case. I don't think it's unreasonable to make this the end user's problem to solve.

@shancock9
Copy link
Contributor

I've tentatively added an option to do this by filtering a config file as follows:
if a line in the config file begins with three dashes followed by a parameter name
(rather than two), then it will be removed if the parameter is not known. Otherwise,
a dash will be removed to make the line valid. Older versions of perltidy will
immediately stop if a parameter has three dashes.

I don't know if this will be very useful, since I don't anticipate adding many more
options to perltidy, but it was a simple change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants