[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/async 04e1a2c 43/60: Add async-byte-compile-file
From: |
Stefan Monnier |
Subject: |
[elpa] externals/async 04e1a2c 43/60: Add async-byte-compile-file |
Date: |
Tue, 8 Oct 2019 10:11:34 -0400 (EDT) |
branch: externals/async
commit 04e1a2c40bef305450389da540ffe7594964e430
Author: Thierry Volpiatto <address@hidden>
Commit: Thierry Volpiatto <address@hidden>
Add async-byte-compile-file
* async-bytecomp.el (async-byte-compile-file): New.
---
async-bytecomp.el | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/async-bytecomp.el b/async-bytecomp.el
index 7c113d5..7bb2d46 100644
--- a/async-bytecomp.el
+++ b/async-bytecomp.el
@@ -173,6 +173,47 @@ Async compilation of packages can be controlled by
(ad-activate 'package--compile)
(ad-deactivate 'package--compile)))
+;;;###autoload
+(defun async-byte-compile-file (file)
+ "Byte compile Lisp code FILE asynchronously.
+
+Same as `byte-compile-file' but asynchronous."
+ (interactive "fFile: ")
+ (let ((call-back
+ (lambda (&optional _ignore)
+ (let ((bn (file-name-nondirectory file)))
+ (if (file-exists-p async-byte-compile-log-file)
+ (let ((buf (get-buffer-create byte-compile-log-buffer))
+ start)
+ (with-current-buffer buf
+ (goto-char (setq start (point-max)))
+ (let ((inhibit-read-only t))
+ (insert-file-contents async-byte-compile-log-file)
+ (compilation-mode))
+ (display-buffer buf)
+ (delete-file async-byte-compile-log-file)
+ (save-excursion
+ (goto-char start)
+ (if (re-search-forward "^.*:Error:" nil t)
+ (message "Failed to compile `%s'" bn)
+ (message "`%s' compiled asynchronously with warnings"
bn)))))
+ (message "`%s' compiled asynchronously with success" bn))))))
+ (async-start
+ `(lambda ()
+ (require 'bytecomp)
+ ,(async-inject-variables "\\`load-path\\'")
+ (let ((default-directory ,(file-name-directory file)))
+ (add-to-list 'load-path default-directory)
+ (byte-compile-file ,file)
+ (when (get-buffer byte-compile-log-buffer)
+ (setq error-data (with-current-buffer byte-compile-log-buffer
+ (buffer-substring-no-properties (point-min)
(point-max))))
+ (unless (string= error-data "")
+ (with-temp-file ,async-byte-compile-log-file
+ (erase-buffer)
+ (insert error-data))))))
+ call-back)))
+
(provide 'async-bytecomp)
;;; async-bytecomp.el ends here
- [elpa] externals/async 868d927 33/60: Add .gitignore, (continued)
- [elpa] externals/async 868d927 33/60: Add .gitignore, Stefan Monnier, 2019/10/08
- [elpa] externals/async 7fa23eb 44/60: Update dired-buffers when operation ends (#99), Stefan Monnier, 2019/10/08
- [elpa] externals/async efe6bda 45/60: Check if dired buffer is alive before reverting (#99), Stefan Monnier, 2019/10/08
- [elpa] externals/async c9bd058 48/60: DRY in async-inject-variables, Stefan Monnier, 2019/10/08
- [elpa] externals/async 5863eef 28/60: Copy the autoload file when installing, Stefan Monnier, 2019/10/08
- [elpa] externals/async dea9627 31/60: Merge pull request #87 from darkfeline/async, Stefan Monnier, 2019/10/08
- [elpa] externals/async 8bb64e3 41/60: Require cl-lib., Stefan Monnier, 2019/10/08
- [elpa] externals/async 7279cc6 38/60: Remove autoload file as well when uninstalling, Stefan Monnier, 2019/10/08
- [elpa] externals/async afe10c4 30/60: Add one-shot dired-async commands, Stefan Monnier, 2019/10/08
- [elpa] externals/async 4d3b737 52/60: Fix error from reverting to nonexistent directories, Stefan Monnier, 2019/10/08
- [elpa] externals/async 04e1a2c 43/60: Add async-byte-compile-file,
Stefan Monnier <=
- [elpa] externals/async 66e6856 34/60: Merge pull request #92 from arichiardi/add-gitignore, Stefan Monnier, 2019/10/08
- [elpa] externals/async bd68cc1 58/60: Handle dotted lists as well, Stefan Monnier, 2019/10/08