diff --git a/Makefile b/Makefile index 333c7f6..dfa9247 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ SHELL = bash EMACS ?= emacs PORT ?= 8000 -NOOUTPUT = grep -v '^Loading' | { ! grep '^'; } PACKAGES = packages FONT_SIZE ?= 180 ENV ?= env @@ -68,12 +67,11 @@ lint-file: @printf "\n--> Step: Byte-compile file\n\n" $(EMACS) --batch -L . \ --eval "(setq byte-compile-error-on-warn t)" \ - -f batch-byte-compile "$(filename)" 2>&1 + -f batch-byte-compile "$(filename)" @printf "\n--> Step: Run checkdoc\n\n" yes n | $(EMACS) --batch \ - --eval '(find-file "$(filename)")' \ - --eval '(setq sentence-end-double-space nil)' \ - --eval '(checkdoc-current-buffer)' 2>&1 | $(NOOUTPUT) + -l test/checkdoc-batch.el \ + -f checkdoc-batch-and-exit "$(filename)" @printf "\n--> Step: Run package-lint\n\n" $(EMACS) --batch --eval "(setq package-user-dir \"$$PWD/$(PACKAGES)\")" \ --eval "(package-initialize)" \ diff --git a/test/checkdoc-batch.el b/test/checkdoc-batch.el new file mode 100644 index 0000000..deb5c0a --- /dev/null +++ b/test/checkdoc-batch.el @@ -0,0 +1,28 @@ +;; checkdoc-batch.el --- Batch mode for checkdoc -*- lexical-binding: t; -*- + +(defun checkdoc-batch-and-exit () + "Run checkdoc in batch mode for a set of files. +Exit with 1 if one or more warnings were emitted, otherwise with 0." + (unless noninteractive + (error "`checkdoc-batch-and-exit' is to be used only with -batch")) + (let ((status 0) + path) + (while command-line-args-left + (setq path (car command-line-args-left)) + (with-current-buffer (find-file-noselect path) + (checkdoc-current-buffer t)) + (with-current-buffer "*Style Warnings*" + (goto-char (point-min)) + (while (not (eobp)) + (let* ((rule "[ \t\n\r\f]+") + (line (string-trim (buffer-substring-no-properties + (line-beginning-position) + (line-end-position)) + rule rule))) + (when (and (not (string= line "")) + (not (string-prefix-p "*" line))) + (princ (concat line "\n")) + (setq status 1))) + (ignore-errors (next-line)))) + (setq command-line-args-left (cdr command-line-args-left))) + (kill-emacs status)))