update packages
This commit is contained in:
@@ -59,39 +59,85 @@ all packages are always compiled asynchronously."
|
||||
(const :tag "All packages" all)
|
||||
(repeat symbol)))
|
||||
|
||||
(defvar async-byte-compile-log-file
|
||||
(concat user-emacs-directory "async-bytecomp.log"))
|
||||
(defvar async-byte-compile-log-file "async-bytecomp.log"
|
||||
"Prefix for a file used to pass errors from async process to the caller.
|
||||
The `file-name-nondirectory' part of the value is passed to
|
||||
`make-temp-file' as a prefix. When the value is an absolute
|
||||
path, then the `file-name-directory' part of it is expanded in
|
||||
the calling process (with `expand-file-name') and used as a value
|
||||
of variable `temporary-file-directory' in async processes.")
|
||||
|
||||
(defvar async-bytecomp-load-variable-regexp "\\`load-path\\'"
|
||||
"The variable used by `async-inject-variables' when (re)compiling async.")
|
||||
|
||||
(defun async-bytecomp--file-to-comp-buffer (file-or-dir &optional quiet type)
|
||||
(defun async-bytecomp--file-to-comp-buffer-1 (log-file &optional postproc)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer)))
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-max))
|
||||
(let ((inhibit-read-only t))
|
||||
(insert-file-contents log-file)
|
||||
(compilation-mode))
|
||||
(display-buffer buf)
|
||||
(delete-file log-file)
|
||||
(and postproc (funcall postproc)))))
|
||||
|
||||
(defun async-bytecomp--file-to-comp-buffer (file-or-dir &optional quiet type log-file)
|
||||
(let ((bn (file-name-nondirectory (directory-file-name file-or-dir)))
|
||||
(action-name (pcase type
|
||||
('file "File")
|
||||
('directory "Directory"))))
|
||||
(if (file-exists-p async-byte-compile-log-file)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer))
|
||||
(n 0))
|
||||
(with-current-buffer buf
|
||||
(goto-char (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)
|
||||
(unless quiet
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^.*:Error:" nil t)
|
||||
(cl-incf n)))
|
||||
(if (> n 0)
|
||||
(message "Failed to compile %d files in directory `%s'" n bn)
|
||||
(message "%s `%s' compiled asynchronously with warnings"
|
||||
action-name bn)))))
|
||||
(if (and log-file (file-exists-p log-file))
|
||||
(async-bytecomp--file-to-comp-buffer-1
|
||||
log-file
|
||||
(unless quiet
|
||||
(lambda ()
|
||||
(let ((n 0))
|
||||
(unless quiet
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^.*:Error:" nil t)
|
||||
(cl-incf n)))
|
||||
(if (> n 0)
|
||||
(message "Failed to compile %d files in directory `%s'" n bn)
|
||||
(message "%s `%s' compiled asynchronously with warnings"
|
||||
action-name bn)))))))
|
||||
(unless quiet
|
||||
(message "%s `%s' compiled asynchronously with success" action-name bn)))))
|
||||
|
||||
(defmacro async-bytecomp--comp-buffer-to-file ()
|
||||
"Write contents of `byte-compile-log-buffer' to a log file.
|
||||
The log file is a temporary file that name is determined by
|
||||
`async-byte-compile-log-file', which see. Return the actual log
|
||||
file name, or nil if no log file has been created."
|
||||
`(when (get-buffer byte-compile-log-buffer)
|
||||
(let ((error-data (with-current-buffer byte-compile-log-buffer
|
||||
(buffer-substring-no-properties (point-min) (point-max)))))
|
||||
(unless (string= error-data "")
|
||||
;; The `async-byte-compile-log-file' used to be an absolute file name
|
||||
;; shared amongst all compilation async processes. For backward
|
||||
;; compatibility the directory part of it is used to create logs the same
|
||||
;; directory while the nondirectory part denotes the PREFIX for
|
||||
;; `make-temp-file' call. The `temporary-file-directory' is bound, such
|
||||
;; that the async process uses one set by the caller.
|
||||
(let ((temporary-file-directory
|
||||
,(or (when (and async-byte-compile-log-file
|
||||
(file-name-absolute-p
|
||||
async-byte-compile-log-file))
|
||||
(expand-file-name (file-name-directory
|
||||
async-byte-compile-log-file)))
|
||||
temporary-file-directory))
|
||||
(log-file (make-temp-file ,(let ((log-file
|
||||
(file-name-nondirectory
|
||||
async-byte-compile-log-file)))
|
||||
(format "%s%s"
|
||||
log-file
|
||||
(if (string-suffix-p "." log-file)
|
||||
"" "."))))))
|
||||
(with-temp-file log-file
|
||||
(erase-buffer)
|
||||
(insert error-data))
|
||||
log-file)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun async-byte-recompile-directory (directory &optional quiet)
|
||||
"Compile all *.el files in DIRECTORY asynchronously.
|
||||
@@ -104,23 +150,16 @@ All *.elc files are systematically deleted before proceeding."
|
||||
;; This happen when recompiling its own directory.
|
||||
(load "async")
|
||||
(let ((call-back
|
||||
(lambda (&optional _ignore)
|
||||
(async-bytecomp--file-to-comp-buffer directory quiet 'directory))))
|
||||
(lambda (&optional log-file)
|
||||
(async-bytecomp--file-to-comp-buffer directory quiet 'directory log-file))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
,(async-inject-variables async-bytecomp-load-variable-regexp)
|
||||
(let ((default-directory (file-name-as-directory ,directory))
|
||||
error-data)
|
||||
(let ((default-directory (file-name-as-directory ,directory)))
|
||||
(add-to-list 'load-path default-directory)
|
||||
(byte-recompile-directory ,directory 0 t)
|
||||
(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))))))
|
||||
,(macroexpand '(async-bytecomp--comp-buffer-to-file))))
|
||||
call-back)
|
||||
(unless quiet (message "Started compiling asynchronously directory %s" directory))))
|
||||
|
||||
@@ -185,23 +224,16 @@ by default is async you don't need this."
|
||||
Same as `byte-compile-file' but asynchronous."
|
||||
(interactive "fFile: ")
|
||||
(let ((call-back
|
||||
(lambda (&optional _ignore)
|
||||
(async-bytecomp--file-to-comp-buffer file nil 'file))))
|
||||
(lambda (&optional log-file)
|
||||
(async-bytecomp--file-to-comp-buffer file nil 'file log-file))))
|
||||
(async-start
|
||||
`(lambda ()
|
||||
(require 'bytecomp)
|
||||
,(async-inject-variables async-bytecomp-load-variable-regexp)
|
||||
(let ((default-directory ,(file-name-directory file))
|
||||
error-data)
|
||||
(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))))))
|
||||
,(macroexpand '(async-bytecomp--comp-buffer-to-file))))
|
||||
call-back)))
|
||||
|
||||
(provide 'async-bytecomp)
|
||||
|
||||
@@ -65,7 +65,14 @@ Argument ERROR-FILE is the file where errors are logged, if some."
|
||||
(action-string (pcase action
|
||||
('install "Installing")
|
||||
('upgrade "Upgrading")
|
||||
('reinstall "Reinstalling"))))
|
||||
('reinstall "Reinstalling")))
|
||||
;; As PACKAGES are installed and compiled in a single async
|
||||
;; process we don't need to compute log-file in child process
|
||||
;; i.e. we use the same log-file for all PACKAGES.
|
||||
(log-file (make-temp-file
|
||||
(expand-file-name
|
||||
(file-name-nondirectory async-byte-compile-log-file)
|
||||
temporary-file-directory))))
|
||||
(message "%s %s package(s)..." action-string (length packages))
|
||||
(process-put
|
||||
(async-start
|
||||
@@ -92,13 +99,12 @@ Argument ERROR-FILE is the file where errors are logged, if some."
|
||||
(format
|
||||
"%S:\n Please refresh package list before %s"
|
||||
err ,action-string)))))
|
||||
(let (error-data)
|
||||
(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))))
|
||||
(when (get-buffer byte-compile-log-buffer)
|
||||
(let ((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
|
||||
(with-temp-file ,log-file
|
||||
(erase-buffer)
|
||||
(insert error-data)))))))
|
||||
(lambda (result)
|
||||
@@ -127,15 +133,9 @@ Argument ERROR-FILE is the file where errors are logged, if some."
|
||||
'async-package-message
|
||||
str (length lst)))
|
||||
packages action-string)
|
||||
(when (file-exists-p async-byte-compile-log-file)
|
||||
(let ((buf (get-buffer-create byte-compile-log-buffer)))
|
||||
(with-current-buffer buf
|
||||
(goto-char (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)))))))
|
||||
(if (zerop (nth 7 (file-attributes log-file)))
|
||||
(delete-file log-file)
|
||||
(async-bytecomp--file-to-comp-buffer-1 log-file)))))
|
||||
(run-hooks 'async-pkg-install-after-hook)))
|
||||
'async-pkg-install t)
|
||||
(async-package--modeline-mode 1)))
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
;; -*- no-byte-compile: t; lexical-binding: nil -*-
|
||||
(define-package "async" "20250325.509"
|
||||
(define-package "async" "20251005.634"
|
||||
"Asynchronous processing in Emacs."
|
||||
'((emacs "24.4"))
|
||||
:url "https://github.com/jwiegley/emacs-async"
|
||||
:commit "bb3f31966ed65a76abe6fa4f80a960a2917f554e"
|
||||
:revdesc "bb3f31966ed6"
|
||||
:commit "31cb2fea8f4bc7a593acd76187a89075d8075500"
|
||||
:revdesc "31cb2fea8f4b"
|
||||
:keywords '("async")
|
||||
:authors '(("John Wiegley" . "jwiegley@gmail.com"))
|
||||
:maintainers '(("Thierry Volpiatto" . "thievol@posteo.net")))
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
;; Maintainer: Thierry Volpiatto <thievol@posteo.net>
|
||||
|
||||
;; Created: 18 Jun 2012
|
||||
;; Package-Version: 20250325.509
|
||||
;; Package-Revision: bb3f31966ed6
|
||||
;; Package-Version: 20251005.634
|
||||
;; Package-Revision: 31cb2fea8f4b
|
||||
;; Package-Requires: ((emacs "24.4"))
|
||||
|
||||
;; Keywords: async
|
||||
@@ -118,7 +118,7 @@ is returned unmodified."
|
||||
collect elm))
|
||||
(t object)))
|
||||
|
||||
(defvar async-inject-variables-exclude-regexps '("-syntax-table\\'")
|
||||
(defvar async-inject-variables-exclude-regexps '("-syntax-table\\'" "-abbrev-table\\'")
|
||||
"A list of regexps that `async-inject-variables' should ignore.")
|
||||
|
||||
(defun async-inject-variables
|
||||
|
||||
@@ -71,7 +71,9 @@ Should take same args as `message'."
|
||||
(defcustom dired-async-skip-fast nil
|
||||
"If non-nil, skip async for fast operations.
|
||||
Same device renames and copying and renaming files smaller than
|
||||
`dired-async-small-file-max' are considered fast."
|
||||
`dired-async-small-file-max' are considered fast.
|
||||
If the total size of all files exceed `dired-async-small-file-max'
|
||||
operation is not considered fast."
|
||||
:risky t
|
||||
:type 'boolean)
|
||||
|
||||
@@ -203,22 +205,22 @@ See `file-attributes'."
|
||||
(equal (file-attribute-device-number (file-attributes f1))
|
||||
(file-attribute-device-number (file-attributes f2))))
|
||||
|
||||
(defun dired-async--small-file-p (file)
|
||||
(defun dired-async--small-file-p (file &optional attrs)
|
||||
"Return non-nil if FILE is considered small.
|
||||
|
||||
File is considered small if it size is smaller than
|
||||
`dired-async-small-file-max'."
|
||||
(let ((a (file-attributes file)))
|
||||
(let ((a (or attrs (file-attributes file))))
|
||||
;; Directories are always large since we can't easily figure out
|
||||
;; their total size.
|
||||
(and (not (dired-async--directory-p a))
|
||||
(< (file-attribute-size a) dired-async-small-file-max))))
|
||||
|
||||
(defun dired-async--skip-async-p (file-creator file name-constructor)
|
||||
(defun dired-async--skip-async-p (file-creator file name-constructor &optional attrs)
|
||||
"Return non-nil if we should skip async for FILE.
|
||||
See `dired-create-files' for FILE-CREATOR and NAME-CONSTRUCTOR."
|
||||
;; Skip async for small files.
|
||||
(or (dired-async--small-file-p file)
|
||||
(or (dired-async--small-file-p file attrs)
|
||||
;; Also skip async for same device renames.
|
||||
(and (eq file-creator 'dired-rename-file)
|
||||
(let ((new (funcall name-constructor file)))
|
||||
@@ -230,14 +232,22 @@ See `dired-create-files' for FILE-CREATOR and NAME-CONSTRUCTOR."
|
||||
"Around advice for `dired-create-files'.
|
||||
Uses async like `dired-async-create-files' but skips certain fast
|
||||
cases if `dired-async-skip-fast' is non-nil."
|
||||
(let (async-list quick-list)
|
||||
(let ((total-size 0)
|
||||
async-list quick-list)
|
||||
(if (or (eq file-creator 'backup-file)
|
||||
(null dired-async-skip-fast))
|
||||
(setq async-list fn-list)
|
||||
(dolist (old fn-list)
|
||||
(if (dired-async--skip-async-p file-creator old name-constructor)
|
||||
(push old quick-list)
|
||||
(push old async-list))))
|
||||
(let ((attrs (file-attributes old)))
|
||||
(if (dired-async--skip-async-p
|
||||
file-creator old name-constructor attrs)
|
||||
(progn
|
||||
(push old quick-list)
|
||||
(setq total-size (+ total-size (nth 7 attrs))))
|
||||
(push old async-list)))))
|
||||
(when (> total-size dired-async-small-file-max)
|
||||
(setq async-list (append quick-list async-list)
|
||||
quick-list nil))
|
||||
(when async-list
|
||||
(dired-async-create-files
|
||||
file-creator operation (nreverse async-list)
|
||||
@@ -313,6 +323,7 @@ ESC or `q' to not overwrite any of the remaining files,
|
||||
from to)))
|
||||
;; Skip file if it is too large.
|
||||
(if (and (member operation '("Copy" "Rename"))
|
||||
dired-async-large-file-warning-threshold
|
||||
(eq (dired-async--abort-if-file-too-large
|
||||
(file-attribute-size
|
||||
(file-attributes (file-truename from)))
|
||||
|
||||
Reference in New Issue
Block a user