]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
add flymake-perlcritic
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 18 Oct 2019 14:59:21 +0000 (16:59 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 18 Oct 2019 14:59:21 +0000 (16:59 +0200)
elpa/flymake-perlcritic-20120328.814/bin/flymake_perlcritic [new file with mode: 0755]
elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-autoloads.el [new file with mode: 0644]
elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-pkg.el [new file with mode: 0644]
elpa/flymake-perlcritic-20120328.814/flymake-perlcritic.el [new file with mode: 0644]
elpa/flymake-perlcritic-readme.txt [new file with mode: 0644]

diff --git a/elpa/flymake-perlcritic-20120328.814/bin/flymake_perlcritic b/elpa/flymake-perlcritic-20120328.814/bin/flymake_perlcritic
new file mode 100755 (executable)
index 0000000..4b93112
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+#  Wrapper around perlcritic and perl -c for Emacs flymake.
+
+showhelp() {
+    echo "flymake_perlcritic [-I <include-dir>] [-h] <source-file>
+
+Run perlcritic and \"perl -c\" on <source-file> in a manner appropriate for use by Emacs flymake-perlcritic.el.
+
+    -I <include-dir> Add the supplied dir to \$PERL5LIB include paths.
+    -h               Display this help.
+    <source-file>    The source file to run the checks on.";
+    exit 0;
+}
+
+while getopts "I:h" "OPTNAME";
+do
+    case $OPTNAME in
+        I) INCLUDE=$OPTARG ;;
+        h) showhelp        ;;
+        *) exit -1         ;;
+    esac
+done
+shift $(($OPTIND - 1))
+
+FILE_NAME="$1"
+shift
+
+if [ -n "$INCLUDE" ]; then
+    if [ -n "$PERL5LIB" ]; then
+        export PERL5LIB="$INCLUDE:$PERL5LIB"
+    else
+        export PERL5LIB="$INCLUDE"
+    fi
+fi
+
+# Run perlcritic first.
+# TODO: be nice to include severity and have it turn into warning/error.
+perlcritic --nocolour "$FILE_NAME" --verbose "%f:%l:%c: Warning: %m. %e.\n" $*
+
+# Run perl -c too for good measure.
+perl -wc -Mstrict "$FILE_NAME"
+
+exit 0
\ No newline at end of file
diff --git a/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-autoloads.el b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-autoloads.el
new file mode 100644 (file)
index 0000000..49630e4
--- /dev/null
@@ -0,0 +1,27 @@
+;;; flymake-perlcritic-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+                         (or (file-name-directory #$) (car load-path))))
+
+\f
+;;;### (autoloads nil "flymake-perlcritic" "flymake-perlcritic.el"
+;;;;;;  (0 0 0 0))
+;;; Generated autoloads from flymake-perlcritic.el
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "flymake-perlcritic" '("flymake-perlcritic-")))
+
+;;;***
+\f
+;;;### (autoloads nil nil ("flymake-perlcritic-pkg.el") (0 0 0 0))
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; flymake-perlcritic-autoloads.el ends here
diff --git a/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-pkg.el b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-pkg.el
new file mode 100644 (file)
index 0000000..6f85c8e
--- /dev/null
@@ -0,0 +1,10 @@
+(define-package "flymake-perlcritic" "20120328.814" "Flymake handler for Perl to invoke Perl::Critic"
+  '((flymake "0.3"))
+  :authors
+  '(("Sam Graham <libflymake-perlcritic-emacs BLAHBLAH illusori.co.uk>"))
+  :maintainer
+  '("Sam Graham <libflymake-perlcritic-emacs BLAHBLAH illusori.co.uk>")
+  :url "https://github.com/illusori/emacs-flymake-perlcritic")
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
diff --git a/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic.el b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic.el
new file mode 100644 (file)
index 0000000..e7a117b
--- /dev/null
@@ -0,0 +1,90 @@
+;;; flymake-perlcritic.el --- Flymake handler for Perl to invoke Perl::Critic
+;;
+;; Copyright (C) 2011-2012  Free Software Foundation, Inc.
+;;
+;; Author: Sam Graham <libflymake-perlcritic-emacs BLAHBLAH illusori.co.uk>
+;; Maintainer: Sam Graham <libflymake-perlcritic-emacs BLAHBLAH illusori.co.uk>
+;; URL: https://github.com/illusori/emacs-flymake-perlcritic
+;; Version: 1.0.3
+;; Package-Requires: ((flymake "0.3"))
+;;
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;; Commentary:
+;;
+;; flymake-perlcritic.el adds support to flymake.el for running Perl::Critic
+;; (http://search.cpan.org/perldoc?Perl::Critic) to perform static
+;; analysis of your Perl code in addition to syntax checking.
+;;
+;;; Usage:
+;; (require 'flymake-perlcritic)
+
+(eval-when-compile (require 'flymake))
+
+(defcustom flymake-perlcritic-command (executable-find
+  (concat (file-name-directory (or load-file-name buffer-file-name))
+          "bin/flymake_perlcritic"))
+  "If flymake_perlcritic isn't in your $PATH, set this to the command needed to run it."
+  :group 'flymake-perlcritic
+  :type 'string)
+
+(defcustom flymake-perlcritic-profile nil
+  "The path to the profile file to configure perlcritic, if nil then perlcritic will look in its default location (~/.perlcriticrc)."
+  :group 'flymake-perlcritic
+  :type 'string)
+
+(defcustom flymake-perlcritic-severity 4
+  "The severity to run perlcritic at, values are 1 to 5 with 1 being strictest."
+  :group 'flymake-perlcritic
+  :type 'integer)
+
+(defun flymake-perlcritic-init ()
+  (let* ((temp-file (flymake-init-create-temp-buffer-copy
+                      'flymake-create-temp-with-folder-structure))
+         (local-file (file-relative-name temp-file
+                       (file-name-directory buffer-file-name)))
+         (include-dir (if (fboundp 'flymake-find-perl-lib-dir)
+                        (flymake-find-perl-lib-dir buffer-file-name))))
+    (if (fboundp 'flymake-perlbrew-path-sync)
+      (flymake-perlbrew-path-sync))
+    (list flymake-perlcritic-command
+      (append
+        (if include-dir (list (concat "-I" include-dir)))
+        (list local-file)
+        (if flymake-perlcritic-profile (list "--profile" flymake-perlcritic-profile))
+        (list "--severity" (number-to-string flymake-perlcritic-severity))))))
+
+(defun flymake-perlcritic-cleanup ()
+  "Cleanup after `flymake-perlcritic-init' - delete temp file and dirs."
+  (flymake-safe-delete-file flymake-temp-source-file-name)
+  (when flymake-temp-source-file-name
+    (flymake-delete-temp-directory
+      (file-name-directory flymake-temp-source-file-name))))
+
+(eval-after-load "flymake"
+  '(progn
+    ;; Add a new error pattern to catch Perl::Critic output, this is a custom
+    ;; format defined in perlcritic_flymake since the Perl::Critic default
+    ;; isn't parsable in a way that flymake.el likes.
+    (add-to-list 'flymake-err-line-patterns
+                 '("\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): \\(.*\\)" 1 2 3 4))
+    (let ((mode-and-masks (flymake-get-file-name-mode-and-masks "example.pm")))
+      (setcar mode-and-masks 'flymake-perlcritic-init)
+      (if (nth 1 mode-and-masks)
+        (setcar (nthcdr 1 mode-and-masks) 'flymake-perlcritic-cleanup)
+        (nconc mode-and-masks (list 'flymake-perlcritic-cleanup))))
+    (add-hook 'perl-mode-hook (lambda() (flymake-mode 1)) t)))
+
+(provide 'flymake-perlcritic)
+;;; flymake-perlcritic.el ends here
diff --git a/elpa/flymake-perlcritic-readme.txt b/elpa/flymake-perlcritic-readme.txt
new file mode 100644 (file)
index 0000000..7863377
--- /dev/null
@@ -0,0 +1,3 @@
+flymake-perlcritic.el adds support to flymake.el for running Perl::Critic
+(http://search.cpan.org/perldoc?Perl::Critic) to perform static
+analysis of your Perl code in addition to syntax checking.