@@ -60,6 +60,30 @@ all packages are always compiled asynchronously."
60
60
(defvar async-bytecomp-load-variable-regexp " \\ `load-path\\' "
61
61
" The variable used by `async-inject-variables' when (re)compiling async." )
62
62
63
+ (defun async-bytecomp--file-to-comp-buffer (file-or-dir &optional quiet )
64
+ (let ((bn (file-name-nondirectory file-or-dir)))
65
+ (if (file-exists-p async-byte-compile-log-file)
66
+ (let ((buf (get-buffer-create byte-compile-log-buffer))
67
+ (n 0 ))
68
+ (with-current-buffer buf
69
+ (goto-char (point-max ))
70
+ (let ((inhibit-read-only t ))
71
+ (insert-file-contents async-byte-compile-log-file)
72
+ (compilation-mode ))
73
+ (display-buffer buf)
74
+ (delete-file async-byte-compile-log-file)
75
+ (unless quiet
76
+ (save-excursion
77
+ (goto-char (point-min ))
78
+ (while (re-search-forward " ^.*:Error:" nil t )
79
+ (cl-incf n)))
80
+ (if (> n 0 )
81
+ (message " Failed to compile %d files in directory `%s' " n bn)
82
+ (message " Directory `%s' compiled asynchronously with warnings "
83
+ bn)))))
84
+ (unless quiet
85
+ (message " Directory `%s' compiled asynchronously with success " bn)))))
86
+
63
87
;;;### autoload
64
88
(defun async-byte-recompile-directory (directory &optional quiet )
65
89
" Compile all *.el files in DIRECTORY asynchronously.
@@ -73,26 +97,7 @@ All *.elc files are systematically deleted before proceeding."
73
97
(load " async" )
74
98
(let ((call-back
75
99
(lambda (&optional _ignore )
76
- (if (file-exists-p async-byte-compile-log-file)
77
- (let ((buf (get-buffer-create byte-compile-log-buffer))
78
- (n 0 ))
79
- (with-current-buffer buf
80
- (goto-char (point-max ))
81
- (let ((inhibit-read-only t ))
82
- (insert-file-contents async-byte-compile-log-file)
83
- (compilation-mode ))
84
- (display-buffer buf)
85
- (delete-file async-byte-compile-log-file)
86
- (unless quiet
87
- (save-excursion
88
- (goto-char (point-min ))
89
- (while (re-search-forward " ^.*:Error:" nil t )
90
- (cl-incf n)))
91
- (if (> n 0 )
92
- (message " Failed to compile %d files in directory `%s' " n directory)
93
- (message " Directory `%s' compiled asynchronously with warnings " directory)))))
94
- (unless quiet
95
- (message " Directory `%s' compiled asynchronously with success " directory))))))
100
+ (async-bytecomp--file-to-comp-buffer directory quiet))))
96
101
(async-start
97
102
`(lambda ()
98
103
(require 'bytecomp )
@@ -170,23 +175,7 @@ Same as `byte-compile-file' but asynchronous."
170
175
(interactive " fFile: " )
171
176
(let ((call-back
172
177
(lambda (&optional _ignore )
173
- (let ((bn (file-name-nondirectory file)))
174
- (if (file-exists-p async-byte-compile-log-file)
175
- (let ((buf (get-buffer-create byte-compile-log-buffer))
176
- start)
177
- (with-current-buffer buf
178
- (goto-char (setq start (point-max )))
179
- (let ((inhibit-read-only t ))
180
- (insert-file-contents async-byte-compile-log-file)
181
- (compilation-mode ))
182
- (display-buffer buf)
183
- (delete-file async-byte-compile-log-file)
184
- (save-excursion
185
- (goto-char start)
186
- (if (re-search-forward " ^.*:Error:" nil t )
187
- (message " Failed to compile `%s' " bn)
188
- (message " `%s' compiled asynchronously with warnings" bn)))))
189
- (message " `%s' compiled asynchronously with success" bn))))))
178
+ (async-bytecomp--file-to-comp-buffer file))))
190
179
(async-start
191
180
`(lambda ()
192
181
(require 'bytecomp )
0 commit comments