emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/plz dd491941ab 79/81: Meta: Update makem.sh


From: ELPA Syncer
Subject: [elpa] externals/plz dd491941ab 79/81: Meta: Update makem.sh
Date: Wed, 11 May 2022 17:58:04 -0400 (EDT)

branch: externals/plz
commit dd491941abc0bb2fa1b62975b30a7a0713c5e520
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Meta: Update makem.sh
---
 makem.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 65 insertions(+), 15 deletions(-)

diff --git a/makem.sh b/makem.sh
index d1a5edba8f..3985ff7dda 100755
--- a/makem.sh
+++ b/makem.sh
@@ -3,11 +3,11 @@
 # * makem.sh --- Script to aid building and testing Emacs Lisp packages
 
 # URL: https://github.com/alphapapa/makem.sh
-# Version: 0.5
+# Version: 0.6-pre
 
 # * Commentary:
 
-# makem.sh is a script helps to build, lint, and test Emacs Lisp
+# makem.sh is a script that helps to build, lint, and test Emacs Lisp
 # packages.  It aims to make linting and testing as simple as possible
 # without requiring per-package configuration.
 
@@ -136,6 +136,27 @@ EOF
     echo $file
 }
 
+function elisp-elint-file {
+    local file=$(mktemp)
+    cat >$file <<EOF
+(require 'cl-lib)
+(require 'elint)
+(defun makem-elint-file (file)
+  (let ((errors 0))
+    (cl-letf (((symbol-function 'orig-message) (symbol-function 'message))
+              ((symbol-function 'message) (symbol-function 'ignore))
+              ((symbol-function 'elint-output)
+               (lambda (string)
+                 (cl-incf errors)
+                 (orig-message "%s" string))))
+      (elint-file file)
+      ;; NOTE: \`errors' is not actually the number of errors, because
+      ;; it's incremented for non-error header strings as well.
+      (kill-emacs errors))))
+EOF
+    echo "$file"
+}
+
 function elisp-checkdoc-file {
     # Since checkdoc doesn't have a batch function that exits non-zero
     # when errors are found, we make one.
@@ -234,20 +255,23 @@ Exits non-zero if mis-indented lines are found.  Checks 
files in
   (let ((errors-p))
     (cl-labels ((lint-file (file)
                            (find-file file)
-                           (let ((tick (buffer-modified-tick)))
-                             (let ((inhibit-message t))
-                               (indent-region (point-min) (point-max)))
-                             (when (/= tick (buffer-modified-tick))
-                               ;; Indentation changed: warn for each line.
-                               (dolist (line (undo-lines buffer-undo-list))
-                                 (message "%s:%s: Indentation mismatch" 
(buffer-name) line))
-                               (setf errors-p t))))
+                           (let ((inhibit-message t))
+                             (indent-region (point-min) (point-max)))
+                           (when buffer-undo-list
+                             ;; Indentation changed: warn for each line.
+                             (dolist (line (undo-lines buffer-undo-list))
+                               (message "%s:%s: Indentation mismatch" 
(buffer-name) line))
+                             (setf errors-p t)))
+                (undo-pos (entry)
+                           (cl-typecase (car entry)
+                             (number (car entry))
+                             (string (abs (cdr entry)))))
                 (undo-lines (undo-list)
                             ;; Return list of lines changed in UNDO-LIST.
                             (nreverse (cl-loop for elt in undo-list
-                                               when (and (consp elt)
-                                                         (numberp (car elt)))
-                                               collect (line-number-at-pos 
(car elt))))))
+                                               for pos = (undo-pos elt)
+                                               when pos
+                                               collect (line-number-at-pos 
pos)))))
       (mapc #'lint-file (mapcar #'expand-file-name command-line-args-left))
       (when errors-p
         (kill-emacs 1)))))
@@ -452,8 +476,7 @@ function ert-tests-p {
 }
 
 function package-main-file {
-    # Echo the package's main file.  Helpful for setting 
package-lint-main-file.
-
+    # Echo the package's main file.
     file_pkg=$(git ls-files ./*-pkg.el 2>/dev/null)
 
     if [[ $file_pkg ]]
@@ -535,6 +558,8 @@ function sandbox {
     args_sandbox=(
         --title "makem.sh: $(basename $(pwd)) (sandbox: $sandbox_dir)"
         --eval "(setq user-emacs-directory (file-truename \"$sandbox_dir\"))"
+        --load package
+        --eval "(setq package-user-dir (expand-file-name \"elpa\" 
user-emacs-directory))"
         --eval "(setq user-init-file (file-truename \"$init_file\"))"
     )
 
@@ -820,6 +845,9 @@ function lint {
     lint-checkdoc
     lint-compile
     lint-declare
+    # NOTE: Elint doesn't seem very useful at the moment.  See comment
+    # in lint-elint function.
+    # lint-elint
     lint-indent
     lint-package
     lint-regexps
@@ -876,6 +904,28 @@ function lint-elsa {
             || error "Linting with Elsa failed."
 }
 
+function lint-elint {
+    # NOTE: Elint gives a lot of spurious warnings, apparently because it 
doesn't load files
+    # that are `require'd, so its output isn't very useful.  But in case it's 
improved in
+    # the future, and since this wrapper code already works, we might as well 
leave it in.
+    verbose 1 "Linting with Elint..."
+
+    local errors=0
+    for file in "${files_project_feature[@]}"
+    do
+        verbose 2 "Linting with Elint: $file..."
+        run_emacs \
+            --load "$(elisp-elint-file)" \
+            --eval "(makem-elint-file \"$file\")" \
+            && verbose 3 "Linting with Elint found no errors." \
+                || { error "Linting with Elint failed: $file"; ((errors++)) ; }
+    done
+
+    [[ $errors = 0 ]] \
+        && success "Linting with Elint finished without errors." \
+            || error "Linting with Elint failed."
+}
+
 function lint-indent {
     verbose 1 "Linting indentation..."
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]