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

Add ".plt" to Prolog extensions #6141

Merged
merged 11 commits into from
Feb 17, 2023
Merged

Add ".plt" to Prolog extensions #6141

merged 11 commits into from
Feb 17, 2023

Conversation

GeoffChurch
Copy link
Contributor

@GeoffChurch GeoffChurch commented Oct 26, 2022

.plt files are used by Gnuplot for saved plots, and by SWI-Prolog (and probably SICSTUS Prolog) for PlUnit tests. Most seem to be misclassified as Gnuplot.

We can try a simple ":-\s?begin_tests" heuristic, but hopefully the classifier will pick up on the vastly different syntax.

I wrote a Prolog .plt sample, and copied an existing Gnuplot sample to have the .plt extension.

Fixes #5074

Checklist:

  • I am associating a language with a new file extension.

    • The new extension is used in hundreds of repositories on GitHub.com
    • I have included a real-world usage sample for all extensions added in this PR:
      • Sample source(s):
        • [URL to each sample source, if applicable]
      • Sample license(s): I wrote the sample Prolog .plt for this PR, so it can fall under linguist's license.
    • I have included a change to the heuristics to distinguish my language from others using the same extension.
  • I am fixing a misclassified language

    • I have included a new sample for the misclassified language:
    • I have included a change to the heuristics to distinguish my language from others using the same extension.

@lildude
Copy link
Member

lildude commented Nov 12, 2022

Please update the OP to link to the source of the GNUplot sample and state the license.

@GeoffChurch
Copy link
Contributor Author

Done

@Alhadis
Copy link
Collaborator

Alhadis commented Nov 12, 2022

We can try a simple ":-\s?begin_tests" heuristic, but hopefully the classifier will pick up on the vastly different syntax.

Why not both? The heuristic will catch the most obvious Prolog cases, and any file not containing a :- token will fall through to the classifier strategy. This works because a line beginning with :- isn't valid Gnuplot syntax:

gnuplot> :- set key off
         ^
         invalid command
diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml
index d948886c..449de061 100644
--- a/lib/linguist/heuristics.yml
+++ b/lib/linguist/heuristics.yml
@@ -485,6 +485,10 @@ disambiguations:
     named_pattern: perl5
   - language: Raku
     named_pattern: perl6
+- extensions: ['.plt']
+  rules:
+  - language: Prolog
+    pattern: '^\s*:-'
 - extensions: ['.plist']
   rules:
   - language: XML Property List

@GeoffChurch
Copy link
Contributor Author

Is there anything remaining to be done before this can be merged?

@lildude
Copy link
Member

lildude commented Jan 1, 2023

Is there anything remaining to be done before this can be merged?

Yup. You need to fix the failing test 😉

@GeoffChurch
Copy link
Contributor Author

@lildude okay hopefully that does it!

@GeoffChurch
Copy link
Contributor Author

Hi, can this get merged now? I think it's good-to-go

Copy link
Collaborator

@Alhadis Alhadis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lildude, this LGTM. 👍

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

Note: this PR will not be merged until close to when the next release is made. See here for more details.

@lildude lildude changed the title Add ".plt" to Prolog extensions along with sample Add ".plt" to Prolog extensions Feb 17, 2023
@lildude lildude merged commit 3eb115d into github-linguist:master Feb 17, 2023
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.plt files recognized as "Gnuplot", but they're also unit test files for Prolog
4 participants