aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadon Rosborough <radon.neon@gmail.com>2019-07-10 19:12:20 -0700
committerRadon Rosborough <radon.neon@gmail.com>2019-07-10 19:12:20 -0700
commit80bf0874bc6590427b7f479d4a1146b5f895927e (patch)
treee09f916779a80f1c4f7bff2af36f21c4df9ec3fb
parent3cfd8f4ec25dc212a8da25dbd0504824316cac76 (diff)
Add Makefile and fix problems it found
-rw-r--r--Makefile46
-rw-r--r--apheleia.el26
2 files changed, 62 insertions, 10 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0845f14
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,46 @@
+EMACS ?= emacs
+
+# The order is important for compilation.
+for_compile := *.el
+for_checkdoc := *.el
+for_longlines := $(wildcard *.el *.md *.yml) Makefile
+
+.PHONY: all
+all: compile checkdoc longlines
+
+.PHONY: compile
+compile:
+ @for file in $(for_compile); do \
+ echo "[compile] $$file" ;\
+ $(EMACS) -Q --batch -L . -f batch-byte-compile $$file 2>&1 \
+ | grep -v "^Wrote" \
+ | grep . && exit 1 || true ;\
+ done
+
+.PHONY: checkdoc
+checkdoc:
+ @for file in $(for_checkdoc); do \
+ echo "[checkdoc] $$file" ;\
+ $(EMACS) -Q --batch \
+ --eval "(or (fboundp 'checkdoc-file) (kill-emacs))" \
+ --eval "(setq sentence-end-double-space nil)" \
+ --eval "(checkdoc-file \"$$file\")" 2>&1 \
+ | grep . && exit 1 || true ;\
+ done
+
+.PHONY: longlines
+longlines:
+ @echo "[longlines] $(for_longlines)"
+ @for file in $(for_longlines); do \
+ cat "$$file" \
+ | sed '/[l]onglines-start/,/longlines-stop/d' \
+ | grep -E '.{80}' \
+ | grep -E -v 'https?://' \
+ | sed "s/^/$$file:long line: /" \
+ | grep . && exit 1 || true ;\
+ done
+
+.PHONY: clean
+clean:
+ @echo "[clean]" *.elc
+ @rm -f *.elc
diff --git a/apheleia.el b/apheleia.el
index 893b3cd..39a7905 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -23,6 +23,7 @@
;;; Code:
(require 'cl-lib)
+(require 'map)
(require 'subr-x)
(defgroup apheleia nil
@@ -130,7 +131,8 @@ contains the patch."
(push (cons nil (point)) point-list)
(dolist (w (get-buffer-window-list nil nil t))
(push (cons w (window-point w)) point-list)
- (push (cons w (count-lines (window-start w) (point))) window-line-list)))
+ (push (cons w (count-lines (window-start w) (point)))
+ window-line-list)))
(with-current-buffer patch-buffer
(apheleia--map-rcs-patch
(lambda (command)
@@ -291,7 +293,8 @@ provided that its exit status is 0."
(error (message "Failed to run %s: %s" name (error-message-string e))))))
(defun apheleia--write-region-silently
- (start end filename &optional append visit lockname mustbenew write-region)
+ (start end filename &optional
+ append _visit lockname mustbenew write-region)
"Like `write-region', but silent.
START, END, FILENAME, APPEND, VISIT, LOCKNAME, and MUSTBENEW are
as in `write-region'. WRITE-REGION is used instead of the actual
@@ -303,11 +306,11 @@ as in `write-region'. WRITE-REGION is used instead of the actual
(defun apheleia--write-file-silently (&optional filename)
"Write contents of current buffer into file FILENAME, silently.
-FILENAME defaults to `buffer-file-name'."
+FILENAME defaults to value of variable `buffer-file-name'."
(cl-letf* ((write-region (symbol-function #'write-region))
((symbol-function #'write-region)
(lambda (start end filename &optional
- append visit lockname mustbenew)
+ append _visit lockname mustbenew)
(apheleia--write-region-silently
start end filename append 0 lockname mustbenew write-region)))
(message (symbol-function #'message))
@@ -430,15 +433,18 @@ commands, lists of strings and symbols, in the format of
This determines what formatter to use in buffers without a
setting for `apheleia-formatter'. The keys are major mode
symbols (matched against `major-mode' with `derived-mode-p') or
-strings (matched against `buffer-file-name' with
-`string-match-p'), and the values are symbols with entries in
-`apheleia-formatters' (or equivalently, they are allowed values
-for `apheleia-formatter'). Earlier entries take precedence over
-later ones.
+strings (matched against value of variable `buffer-file-name'
+with `string-match-p'), and the values are symbols with entries
+in `apheleia-formatters' (or equivalently, they are allowed
+values for `apheleia-formatter'). Earlier entries take precedence
+over later ones.
Be careful when writing regexps to include \"\\'\" and to escape
\"\\.\" in order to properly match a file extension. For example,
-to match \".jsx\" files you might use \"\\.jsx\\'\".")
+to match \".jsx\" files you might use \"\\.jsx\\'\"."
+ :type '(alist
+ :key-type symbol
+ :value-type symbol))
(defvar-local apheleia-formatter nil
"Name of formatter to use in current buffer, a symbol or nil.