Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ my .emacs looks like so:
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))
(require 'flymake-puppet)
(add-hook 'puppet-mode-hook (lambda () (flymake-puppet-load)))

You can override the command and args to use. This can e.g. be useful if you want
to invoke puppet-lint through bundler or if you want to ignore certain checks:

(setq flymake-puppet-lint-command "bundle")
(setq flymake-puppet-lint-args '("exec" "puppet-lint" "--no-autoloader_layout-check"))

14 changes: 10 additions & 4 deletions flymake-puppet.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
;; Deepak Giridharagopal <deepak@brownman.org>
(require 'flymake)

(defvar flymake-puppet-lint-command "puppet-lint"
"How to invoke puppet-lint")

(defvar flymake-puppet-lint-args nil
"Additional arguments to puppet-lint")

(defconst flymake-puppet-err-line-patterns
'(("\\(.*line \\([0-9]+\\).*\\)" nil 2 nil 1)
("\\(.*.rb:[0-9]+.*\\)" nil nil nil 1)))
Expand All @@ -16,9 +22,9 @@ location."

(defun flymake-puppet-init ()
"Construct a command that flymake can use to check puppetscript source."
(list "puppet-lint"
(list (flymake-init-create-temp-buffer-copy
'flymake-puppet-create-temp-in-system-tempdir))))
(list flymake-puppet-lint-command (append flymake-puppet-lint-args
(list (flymake-init-create-temp-buffer-copy
'flymake-puppet-create-temp-in-system-tempdir)))))

(defun flymake-puppet-load ()
"Configure flymake mode to check the current buffer's puppet syntax.
Expand All @@ -29,7 +35,7 @@ does not alter flymake's global configuration, so function
(interactive)
(set (make-local-variable 'flymake-allowed-file-name-masks) '(("." flymake-puppet-init)))
(set (make-local-variable 'flymake-err-line-patterns) flymake-puppet-err-line-patterns)
(if (executable-find "puppet-lint")
(if (executable-find flymake-puppet-lint-command)
(flymake-mode t)
(message "Not enabling flymake: puppet-lint command not found")))

Expand Down