Skip to content
Browse files

Convert to use flymake-create-temp-with-folder-structure to prevent P…

…erl::Critic complaining that package declarations don't match filename. (refs #1)
  • Loading branch information...
1 parent 6d38f6c commit 66f22ba05e11df378888593a24e970762a8c4b3b @illusori committed Dec 27, 2011
Showing with 13 additions and 3 deletions.
  1. +2 −0 Changes
  2. +11 −3 flymake-perlcritic.el
View
2 Changes
@@ -2,3 +2,5 @@
* Add support for flymake-find-perl-lib-dir by modifying PERL5LIB
so that both perl -c and perlcritic find the project lib dir.
* Add help-text to flymake_perlcritic.
+ * Use flymake-create-temp-with-folder-structure to prevent Perl::Critic
+ complaining that package declarations don't match filename.
View
14 flymake-perlcritic.el
@@ -39,9 +39,7 @@
'("\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): \\(.*\\)" 1 2 3 4))
(defun flymake-perl-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
- (if (fboundp 'flymake-create-temp-copy)
- 'flymake-create-temp-copy
- 'flymake-create-temp-inplace)))
+ '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))))
@@ -54,6 +52,16 @@
(if flymake-perlcritic-profile (concat "--profile " flymake-perlcritic-profile) "")
(concat "--severity " (number-to-string flymake-perlcritic-severity))))))
)
+ (defun flymake-perl-cleanup ()
+ "Cleanup after `flymake-perl-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))))
+ (let ((mode-and-masks (flymake-get-file-name-mode-and-masks "example.pm")))
+ (if (nth 1 mode-and-masks)
+ (setcdr mode-and-masks (cons 'flymake-perl-cleanup (cddr mode-and-masks)))
+ (setcdr mode-and-masks (cons 'flymake-perl-cleanup nil))))
(add-hook 'perl-mode-hook (lambda() (flymake-mode 1)))
)
)

0 comments on commit 66f22ba

Please sign in to comment.
Something went wrong with that request. Please try again.