Skip to content

Commit ab187d4

Browse files
authored
feat(compile): Improve compile messages on error (emacs-eask#285)
* feat(compile): Improve compile messages on error * changelog * don't provide
1 parent 30b5878 commit ab187d4

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1313
* fix(test): ERT test fails on Emacs 30+ (cc1f4e15b7b40b986ad1a93f6e40d121340598de)
1414
* fix(test): eask options should not be passed to buttercup (#281)
1515
* feat(core): Lazy install on required packages (#284)
16+
* feat(compile): Improve compile messages on error (#285)
1617

1718
## 0.10.x
1819
> Released Jun 13, 2024

lisp/_prepare.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ scope of the dependencies (it's either `production' or `development')."
600600
601601
If the argument FORCE is non-nil, force initialize packages in this session."
602602
(when (or (not package--initialized) (not package-archive-contents) force
603-
;; XXX we need to initialize once in global scope since most Emacs
603+
;; XXX: we need to initialize once in global scope since most Emacs
604604
;; configuration would likely to set `package-archives' variable
605605
;; themselves.
606606
(and (eask-config-p) (not eask--package-initialized)))
@@ -697,7 +697,7 @@ Argument BODY are forms for execution."
697697
(eask-with-progress
698698
(format " - %sInstalling %s (%s)... " eask--action-prefix name version)
699699
(eask-with-verbosity 'debug
700-
;; XXX Without ignore-errors guard, it will trigger error
700+
;; XXX: Without ignore-errors guard, it will trigger error
701701
;;
702702
;; Can't find library xxxxxxx.el
703703
;;

lisp/core/compile.el

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,21 @@
3737
;;
3838
;;; Core
3939

40-
(defconst eask-compile--log-buffer-name "*Compile-Log*"
41-
"Byte-compile log buffer name.")
40+
(require 'bytecomp)
41+
42+
;; XXX: The function `byte-compile-warn' last modified is 2015;
43+
;; I'll say it's safe to override this function.
44+
(advice-add 'byte-compile-warn :override
45+
(lambda (format &rest args)
46+
(setq format (apply #'format-message format args))
47+
(byte-compile-log-warning format t (if byte-compile-error-on-warn
48+
:error
49+
:warning))))
4250

4351
(defun eask-compile--print-log ()
4452
"Print `*Compile-Log*' buffer."
45-
(when (get-buffer eask-compile--log-buffer-name)
46-
(with-current-buffer eask-compile--log-buffer-name
53+
(when (get-buffer byte-compile-log-buffer)
54+
(with-current-buffer byte-compile-log-buffer
4755
(if (and (eask-clean-p) (eask-strict-p))
4856
(eask-error (buffer-string)) ; Exit with error code!
4957
(eask-print-log-buffer))
@@ -85,14 +93,14 @@ The CMD is the command to start a new Emacs session."
8593
(content (eask-compile--byte-compile-file-external-content filename cmd)))
8694
(if (string-empty-p content)
8795
t ; no error, good!
88-
(with-current-buffer (get-buffer-create eask-compile--log-buffer-name)
96+
(with-current-buffer (get-buffer-create byte-compile-log-buffer)
8997
(insert content)))))
9098

9199
(defun eask-compile--byte-compile-file (filename)
92100
"Byte compile FILENAME."
93101
;; *Compile-Log* does not kill itself. Make sure it's clean before we do
94102
;; next byte-compile task.
95-
(ignore-errors (kill-buffer eask-compile--log-buffer-name))
103+
(ignore-errors (kill-buffer byte-compile-log-buffer))
96104
(let* ((filename (expand-file-name filename))
97105
(result))
98106
(eask-with-progress
@@ -102,7 +110,7 @@ The CMD is the command to start a new Emacs session."
102110
(eask-compile--byte-compile-file-external filename)
103111
(byte-compile-file filename))
104112
result (eq result t)))
105-
(if result "done ✓" "skipped ✗"))
113+
(unless byte-compile-verbose (if result "done ✓" "skipped ✗")))
106114
(eask-compile--print-log)
107115
result))
108116

@@ -112,7 +120,7 @@ The CMD is the command to start a new Emacs session."
112120
(compiled (length compiled))
113121
(skipped (- (length files) compiled)))
114122
;; XXX: Avoid last newline from the log buffer!
115-
(unless (get-buffer eask-compile--log-buffer-name)
123+
(unless (get-buffer byte-compile-log-buffer)
116124
(eask-msg ""))
117125
(eask-info "(Total of %s file%s compiled, %s skipped)" compiled
118126
(eask--sinr compiled "" "s")

lisp/core/exec.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
(eask-start
3737
(eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
38-
;; XXX This is the hack by adding all `bin' folders from local elpa.
38+
;; XXX: This is the hack by adding all `bin' folders from local elpa.
3939
(eask-setup-paths)
4040
(if (eask-argv 1)
4141
(eask-with-progress

test/commands/test/buttercup/test-ok/buttercup-test.el

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@
2828
(it "contains a spec with an expectation"
2929
(expect t :to-be t)))
3030

31-
(provide 'buttercup-test)
3231
;;; buttercup-test.el ends here

0 commit comments

Comments
 (0)