From 0b02b68538e2036851fda15cd8ccc32bbd5d3145 Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Sat, 6 Dec 2014 19:51:45 -0500 Subject: [PATCH] Heuristic for .lsp and .lisp (Common Lisp, NewLisp) --- lib/linguist/heuristics.rb | 8 ++++++++ test/test_heuristics.rb | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 0d0b8338..48b64d0c 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -165,5 +165,13 @@ module Linguist Language["text"] end end + + disambiguate "Common Lisp", "NewLisp" do |data| + if /^\s*\((defun|defactor|in-package|defpackage) /.match(data) + Language["Common Lisp"] + elsif /^\s*\(define /.match(data) + Language["NewLisp"] + end + end end end diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index 4b208770..195fb7c8 100644 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -126,6 +126,13 @@ class TestHeuristcs < Test::Unit::TestCase }) end + def test_lsp_by_heuristics + assert_heuristics({ + "Common Lisp" => all_fixtures("Common Lisp"), + "NewLisp" => all_fixtures("NewLisp") + }) + end + def assert_heuristics(hash) candidates = hash.keys.map { |l| Language[l] }