[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b2b4bd6 107/187: * async-bytecomp.el: New file.
From: |
Michael Albinus |
Subject: |
[elpa] master b2b4bd6 107/187: * async-bytecomp.el: New file. |
Date: |
Wed, 30 Dec 2015 11:49:59 +0000 |
branch: master
commit b2b4bd62cf5c9d96a5a7a395e4f522044d47c7d4
Author: Thierry Volpiatto <address@hidden>
Commit: Thierry Volpiatto <address@hidden>
* async-bytecomp.el: New file.
---
async-bytecomp.el | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 94 insertions(+), 0 deletions(-)
diff --git a/async-bytecomp.el b/async-bytecomp.el
new file mode 100644
index 0000000..db92cf9
--- /dev/null
+++ b/async-bytecomp.el
@@ -0,0 +1,94 @@
+;;; async-bytecomp.el --- Async functions to compile elisp files async
+
+;; Copyright (C) 2014 John Wiegley
+;; Copyright (C) 2014 Thierry Volpiatto
+
+;; Authors: John Wiegley <address@hidden>
+;; Thierry Volpiatto <address@hidden>
+
+;; Version: 1.0
+;; Keywords: dired async byte-compile
+;; X-URL: https://github.com/jwiegley/dired-async
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; This package provide the `async-byte-recompile-directory' function
+;; which allows, as the name says to recompile a directory outside of
+;; your running emacs.
+;; The benefit is your files will be compiled in a clean environment without
+;; the old *.el files loaded.
+;; Among other things, this fix a bug in package.el which recompile
+;; the new files in the current environment with the old files loaded,
creating
+;; errors in most packages after upgrades.
+;;
+;; NB: This package is advicing the function `package--compile'.
+
+;;; Code:
+
+(require 'async)
+
+(defvar async-byte-compile-log-file "/tmp/async-bytecomp.log")
+
+(defun async-byte-recompile-directory (directory &optional arg force)
+ (cl-loop with dir = (directory-files directory t "\\.elc\\'")
+ unless dir return nil
+ for f in dir
+ when (file-exists-p f) do (delete-file f))
+ (let ((call-back
+ `(lambda (&optional ignore)
+ (if (file-exists-p async-byte-compile-log-file)
+ (progn
+ (pop-to-buffer (generate-new-buffer-name
+ byte-compile-log-buffer))
+ (erase-buffer)
+ (insert-file-contents async-byte-compile-log-file)
+ (compilation-mode)
+ (delete-file async-byte-compile-log-file)
+ (let ((n 0))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "^.*:Error:" nil t)
+ (incf n)))
+ (when (> n 0)
+ (message "Failed to compile %d files in directory `%s'"
n ,directory))))
+ (message "Directory `%s' compiled asynchronously with success"
,directory)))))
+ (async-start
+ `(lambda ()
+ (require 'bytecomp)
+ ,(async-inject-variables "\\`load-path\\'")
+ (let ((default-directory (file-name-as-directory ,directory))
+ error-data)
+ (add-to-list 'load-path default-directory)
+ (byte-recompile-directory ,directory ,arg ,force)
+ (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)
+ (message "Started compiling asynchronously directory %s..." directory)))
+
+(defadvice package--compile (around byte-compile-async activate)
+ (package-activate-1 pkg-desc)
+ (async-byte-recompile-directory (package-desc-dir pkg-desc) 0 t))
+
+(provide 'async-bytecomp)
+
+;;; async-bytecomp.el ends here
- [elpa] master aabc7b4 086/187: * helm-async.el: Rename all with dired-async prefix instead of helm-async., (continued)
- [elpa] master aabc7b4 086/187: * helm-async.el: Rename all with dired-async prefix instead of helm-async., Michael Albinus, 2015/12/30
- [elpa] master a37e1db 089/187: * dired-async.el: Finish converting all names to dired*., Michael Albinus, 2015/12/30
- [elpa] master b311374 092/187: * dired-async.el (dired-async-mode): Notify number of jobs running in lighter., Michael Albinus, 2015/12/30
- [elpa] master b514e21 093/187: * async-test.el: Remove now unnecessary tests., Michael Albinus, 2015/12/30
- [elpa] master 4d14cbb 094/187: * async-test.el: Update copyrights., Michael Albinus, 2015/12/30
- [elpa] master 3712607 097/187: * smtpmail-async.el: Exclude some vars when injecting (#22)., Michael Albinus, 2015/12/30
- [elpa] master a0195ad 104/187: Fix markdown in README, Michael Albinus, 2015/12/30
- [elpa] master 3a23aa1 095/187: * dired-async.el (helm-async-be-async): Move it as obsolete variable alias to helm., Michael Albinus, 2015/12/30
- [elpa] master eaa0ec1 098/187: * smtpmail-async.el: Fix encoding problems (#27), Michael Albinus, 2015/12/30
- [elpa] master 05c9861 103/187: * smtpmail-async.el (async-smtpmail-before-send-hook): Add docstring., Michael Albinus, 2015/12/30
- [elpa] master b2b4bd6 107/187: * async-bytecomp.el: New file.,
Michael Albinus <=
- [elpa] master b67254c 096/187: * smtpmail-async.el (async-smtpmail-send-it): Eval content of buffer outside temp buffer.(attempt to fix issue in mu4e), Michael Albinus, 2015/12/30
- [elpa] master 1c54de3 091/187: * README.md: Update., Michael Albinus, 2015/12/30
- [elpa] master f48fe54 099/187: * smtpmail-async.el: Try to catch 'done to not exit when smtpmail-via-smtp is recalled (#22)., Michael Albinus, 2015/12/30
- [elpa] master 85cedab 085/187: * async-file.el: Removed., Michael Albinus, 2015/12/30
- [elpa] master addec5e 102/187: * smtpmail-async.el (async-smtpmail-send-it): Inject the value of auth-sources (#22), Michael Albinus, 2015/12/30
- [elpa] master cca41ed 106/187: * README.md: Fix typo., Michael Albinus, 2015/12/30
- [elpa] master fe319a7 101/187: * smtpmail-async.el (async-smtpmail-before-send-hook): New hook that run on child emacs before sending., Michael Albinus, 2015/12/30
- [elpa] master b962cbf 105/187: Merge pull request #32 from Trevoke/patch-1, Michael Albinus, 2015/12/30
- [elpa] master ed0202f 109/187: fix #33 async-start evals (symbol-file 'async-batch-invoke 'defun) at compile time, Michael Albinus, 2015/12/30
- [elpa] master f81ff95 108/187: Remove version number in all files., Michael Albinus, 2015/12/30