Skip to content

Commit 1776c70

Browse files
committed
Merge pull request #1324 from gracjan/pr-conventions
Add automated coding conventions checking
2 parents 69291d2 + 7aeba53 commit 1776c70

20 files changed

+213
-788
lines changed

Makefile

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ EMACS := $(shell which "$${EMACS}" 2> /dev/null || which "emacs")
2727
EMACS_VERSION := $(shell "$(EMACS)" -Q --batch --eval '(princ emacs-version)')
2828

2929
EFLAGS = --eval "(add-to-list 'load-path (expand-file-name \"tests/compat\") 'append)" \
30-
--eval '(setq byte-compile-error-on-warn t)' \
31-
--eval '(when (not (version< emacs-version "24.4")) (setq load-prefer-newer t))' \
32-
--eval '(defun byte-compile-dest-file (filename) \
33-
(concat (file-name-directory filename) "build-" emacs-version "/" \
34-
(file-name-nondirectory filename) "c"))'
30+
--eval "(when (boundp 'load-prefer-newer) (setq load-prefer-newer t))"
3531

3632
BATCH = $(EMACS) $(EFLAGS) --batch -Q -L .
3733

@@ -58,32 +54,35 @@ check-emacs-version :
5854
(message \" 3. make EMACS=/path/to/emacs\") \
5955
(kill-emacs 2))"
6056

61-
compile: build-$(EMACS_VERSION)
57+
compile: build-$(EMACS_VERSION)/build-flag
6258

63-
build-$(EMACS_VERSION) : $(ELFILES)
64-
if [ ! -d $@ ]; then mkdir $@; fi
65-
$(BATCH) -f batch-byte-compile-if-not-done $^
59+
build-$(EMACS_VERSION)/build-flag : $(ELFILES)
60+
if [ ! -d $$(dirname $@) ]; then mkdir $$(dirname $@); fi
61+
$(BATCH) --eval '(setq byte-compile-error-on-warn t)' \
62+
--eval "(defun byte-compile-dest-file (filename) \
63+
(concat (file-name-directory filename) \"build-\" emacs-version \"/\" \
64+
(file-name-nondirectory filename) \"c\"))'" \
65+
-f batch-byte-compile $^
66+
touch $@
6667

6768
check-%: tests/%-tests.el
6869
$(BATCH) -l "$<" -f ert-run-tests-batch-and-exit;
6970

70-
check: $(ELCHECKS) build-$(EMACS_VERSION)
71+
check: compile $(AUTOLOADS) check-ert check-conventions
72+
73+
check-conventions :
74+
$(BATCH) -l tests/haskell-code-conventions.el \
75+
-f haskell-check-conventions-batch-and-exit
76+
@echo "conventions are okay"
77+
78+
check-ert: $(ELCHECKS)
7179
$(BATCH) --eval "(when (= emacs-major-version 24) \
7280
(require 'undercover) \
7381
(undercover \"*.el\" \
7482
(:exclude \"haskell-mode-pkg.el\" \"haskell-compat.el\")))" \
7583
-L tests \
7684
$(patsubst %,-l %,$(ELCHECKS)) \
7785
-f ert-run-tests-batch-and-exit
78-
@TAB=$$(echo "\t"); \
79-
if grep -Hn "[ $${TAB}]\+\$$" *.el tests/*.el; then \
80-
echo "Error: Files contain whitespace at the end of lines" >&2; \
81-
exit 3; \
82-
fi; \
83-
if grep -Hn "[$${TAB}]" *.el tests/*.el; then \
84-
echo "Error: Tab character is not allowed" >&2; \
85-
exit 3; \
86-
fi
8786
@echo "checks passed!"
8887

8988
clean:

haskell-mode.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ comment. May return a qualified name."
642642
;; First, skip whitespace if we're on it, moving point to last
643643
;; identifier char. That way, if we're at "map ", we'll see the word
644644
;; "map".
645-
(when (and (looking-at (rx eol))
645+
(when (and (eolp)
646646
(not (bolp)))
647647
(backward-char))
648648
(when (and (not (eobp))
@@ -1168,7 +1168,7 @@ generated."
11681168
"Echo STR in mini-buffer.
11691169
Given string is shrinken to single line, multiple lines just
11701170
disturbs the programmer."
1171-
(message (haskell-mode-one-line str (frame-width))))
1171+
(message "%s" (haskell-mode-one-line str (frame-width))))
11721172

11731173
(defun haskell-mode-one-line (str width)
11741174
"Try to fit STR as much as possible on one line according to given WIDTH."

haskell.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
303303
(?n))))
304304
;; unwind
305305
(haskell-mode-toggle-interactive-prompt-state t)))
306-
(message
307-
(format "The Haskell process `%s' is dearly departed." process-name)))))
306+
(message "The Haskell process `%s' is dearly departed." process-name))))
308307

309308
(defun haskell-process ()
310309
"Get the current process from the current session."

0 commit comments

Comments
 (0)