aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadon Rosborough <radon@intuitiveexplanations.com>2023-11-17 16:17:08 -0800
committerGitHub <noreply@github.com>2023-11-17 16:17:08 -0800
commit0e9a838bdd0d6c922282adc2964564307fc52dc6 (patch)
tree734c53dbffc55065aec35b8bc1a435809d4df07e
parentddea9bea708ce029cea6126b5be8e9f8979c58b3 (diff)
Apply some code review suggestions from MELPA (#246)
https://github.com/melpa/melpa/pull/8809#issuecomment-1807218549
-rw-r--r--Makefile2
-rw-r--r--apheleia-formatter-context.el2
-rw-r--r--apheleia-formatters.el4
-rw-r--r--apheleia-log.el4
-rw-r--r--apheleia-rcs.el4
-rw-r--r--apheleia-utils.el2
-rw-r--r--apheleia.el16
7 files changed, 22 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 1eee35c..24fda89 100644
--- a/Makefile
+++ b/Makefile
@@ -9,11 +9,11 @@ TAG ?= latest
# The order is important for compilation.
for_compile := \
+ apheleia-utils.el \
apheleia-formatter-context.el \
apheleia-log.el \
apheleia-formatters.el \
apheleia-rcs.el \
- apheleia-utils.el \
apheleia.el
for_checkdoc := *.el
for_checkindent := *.el
diff --git a/apheleia-formatter-context.el b/apheleia-formatter-context.el
index 769f2ef..809d0d1 100644
--- a/apheleia-formatter-context.el
+++ b/apheleia-formatter-context.el
@@ -1,5 +1,7 @@
;;; apheleia-formatter-context.el --- Formatter ctx -*- lexical-binding: t -*-
+;; SPDX-License-Identifier: MIT
+
;;; Commentary:
;; This file defines a helper for encapsulating common state for a formatter
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index 8ee1adb..66b0e0c 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -1,5 +1,7 @@
;;; apheleia-formatters.el --- Run formatters -*- lexical-binding: t -*-
+;; SPDX-License-Identifier: MIT
+
;;; Commentary:
;; This module defines a series of functions for running a formatter process
@@ -552,7 +554,7 @@ command succeeds provided that its exit status is 0."
(format " *apheleia-%s-stdout*" name)))
(stderr (generate-new-buffer
(format " *apheleia-%s-stderr*" name)))
- (log-name (apheliea-log--buffer-name name)))
+ (log-name (apheleia-log--buffer-name name)))
(condition-case-unless-debug e
(progn
(setq apheleia--current-process
diff --git a/apheleia-log.el b/apheleia-log.el
index 0617a27..92d97f9 100644
--- a/apheleia-log.el
+++ b/apheleia-log.el
@@ -1,5 +1,7 @@
;;; apheleia-log.el --- Log utilities -*- lexical-binding: t -*-
+;; SPDX-License-Identifier: MIT
+
;;; Commentary:
;; Helpers for `apheleia' logging.
@@ -51,7 +53,7 @@ This points into a log buffer.")
(pop-to-buffer (marker-buffer apheleia--last-error-marker))
(goto-char apheleia--last-error-marker))
-(defun apheliea-log--buffer-name (formatter)
+(defun apheleia-log--buffer-name (formatter)
"Get the name of the log buffer for FORMATTER."
(format "%s*apheleia-%s-log*"
(if apheleia-hide-log-buffers
diff --git a/apheleia-rcs.el b/apheleia-rcs.el
index e2df650..914b28d 100644
--- a/apheleia-rcs.el
+++ b/apheleia-rcs.el
@@ -1,5 +1,7 @@
;;; apheleia-rcs.el --- Apply RCS patches -*- lexical-binding: t -*-
+;; SPDX-License-Identifier: MIT
+
;;; Commentary:
;; A library to apply a RCS patch to an Emacs buffer while minimising the
@@ -74,7 +76,7 @@ See <https://tools.ietf.org/doc/tcllib/html/rcs.html#section4>
for documentation on the RCS patch format."
(save-excursion
(goto-char (point-min))
- (while (not (= (point) (point-max)))
+ (while (not (eobp))
(unless (looking-at "$\\|\\([ad]\\)\\([0-9]+\\) \\([0-9]+\\)")
(error "Malformed RCS patch: %S" (point)))
(forward-line)
diff --git a/apheleia-utils.el b/apheleia-utils.el
index a749668..9407cd2 100644
--- a/apheleia-utils.el
+++ b/apheleia-utils.el
@@ -1,5 +1,7 @@
;;; apheleia-utils.el --- Formatter helpers. -*- lexical-binding: t -*-
+;; SPDX-License-Identifier: MIT
+
;;; Commentary:
;; Helper functions for defining apheleia formatters.
diff --git a/apheleia.el b/apheleia.el
index 029f490..f4b0ebf 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -177,17 +177,17 @@ similar task."
(defvar apheleia-mode)
;; Prevent infinite loop.
-(defvar apheleia--format-after-save-in-progress nil
- "Prevent `apheleia--format-after-save' from being called recursively.
-This will be locally bound to t while `apheleia--format-after-save' is
+(defvar apheleia-format-after-save-in-progress nil
+ "Prevent `apheleia-format-after-save' from being called recursively.
+This will be locally bound to t while `apheleia-format-after-save' is
operating, to prevent an infinite loop.")
;; Autoload because the user may enable `apheleia-mode' without
;; loading Apheleia; thus this function may be invoked as an autoload.
;;;###autoload
-(defun apheleia--format-after-save ()
+(defun apheleia-format-after-save ()
"Run code formatter for current buffer if any configured, then save."
- (unless apheleia--format-after-save-in-progress
+ (unless apheleia-format-after-save-in-progress
(when (and apheleia-mode (not (buffer-narrowed-p)))
(when-let ((formatters (apheleia--get-formatters)))
(apheleia-format-buffer
@@ -195,7 +195,7 @@ operating, to prevent an infinite loop.")
(lambda ()
(with-demoted-errors "Apheleia: %s"
(when buffer-file-name
- (let ((apheleia--format-after-save-in-progress t))
+ (let ((apheleia-format-after-save-in-progress t))
(apheleia--save-buffer-silently)))
(run-hooks 'apheleia-post-format-hook))))))))
@@ -211,8 +211,8 @@ It is customized by means of the variables `apheleia-mode-alist'
and `apheleia-formatters'."
:lighter apheleia-mode-lighter
(if apheleia-mode
- (add-hook 'after-save-hook #'apheleia--format-after-save nil 'local)
- (remove-hook 'after-save-hook #'apheleia--format-after-save 'local)))
+ (add-hook 'after-save-hook #'apheleia-format-after-save nil 'local)
+ (remove-hook 'after-save-hook #'apheleia-format-after-save 'local)))
(defvar-local apheleia-inhibit nil
"Do not enable `apheleia-mode' automatically if non-nil.