From 4f65dad57c7100b37774d39abac236d004d91d08 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 10 Feb 2022 16:41:25 +0100 Subject: [PATCH] update async Signed-off-by: Andreas Gerler --- bba.org | 2 +- .../async-autoloads.el | 15 +++- .../async-bytecomp.el | 37 +++++---- .../async-pkg.el | 8 +- .../async.el | 80 ++++++++++++------- .../dired-async.el | 75 ++++++----------- .../smtpmail-async.el | 20 +++-- 7 files changed, 125 insertions(+), 112 deletions(-) rename elpa/{async-20200809.501 => async-20220104.1222}/async-autoloads.el (91%) rename elpa/{async-20200809.501 => async-20220104.1222}/async-bytecomp.el (89%) rename elpa/{async-20200809.501 => async-20220104.1222}/async-pkg.el (53%) rename elpa/{async-20200809.501 => async-20220104.1222}/async.el (84%) rename elpa/{async-20200809.501 => async-20220104.1222}/dired-async.el (89%) rename elpa/{async-20200809.501 => async-20220104.1222}/smtpmail-async.el (82%) diff --git a/bba.org b/bba.org index d7157b94..d4bb7b54 100644 --- a/bba.org +++ b/bba.org @@ -285,7 +285,7 @@ Keep track of your important stuff! #+BEGIN_SRC emacs-lisp :tangle yes (if (>= emacs-major-version 24) (progn - (add-to-list 'load-path "~/.emacs.d/elpa/async-20200809.501") + (add-to-list 'load-path "~/.emacs.d/elpa/async-20220104.1222") (require 'async) ) ) diff --git a/elpa/async-20200809.501/async-autoloads.el b/elpa/async-20220104.1222/async-autoloads.el similarity index 91% rename from elpa/async-20200809.501/async-autoloads.el rename to elpa/async-20220104.1222/async-autoloads.el index 210aebe2..1519fe8c 100644 --- a/elpa/async-20200809.501/async-autoloads.el +++ b/elpa/async-20220104.1222/async-autoloads.el @@ -59,7 +59,18 @@ will leave *emacs* process buffers hanging around): (async-start (lambda () (delete-file \"a remote file on a slow link\" nil)) - 'ignore) + \\='ignore) + +Special case: +If the output of START-FUNC is a string with properties +e.g. (buffer-string) RESULT will be transformed in a list where the +car is the string itself (without props) and the cdr the rest of +properties, this allows using in FINISH-FUNC the string without +properties and then apply the properties in cdr to this string (if +needed). +Properties handling special objects like markers are returned as +list to allow restoring them later. +See for more infos. Note: Even when FINISH-FUNC is present, a future is still returned except that it yields no value (since the value is @@ -112,7 +123,7 @@ Same as `byte-compile-file' but asynchronous. \(fn FILE)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async-bytecomp" '("async-byte"))) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "async-bytecomp" '("async-"))) ;;;*** diff --git a/elpa/async-20200809.501/async-bytecomp.el b/elpa/async-20220104.1222/async-bytecomp.el similarity index 89% rename from elpa/async-20200809.501/async-bytecomp.el rename to elpa/async-20220104.1222/async-bytecomp.el index 430d196b..fe397ae3 100644 --- a/elpa/async-20200809.501/async-bytecomp.el +++ b/elpa/async-20220104.1222/async-bytecomp.el @@ -1,6 +1,6 @@ ;;; async-bytecomp.el --- Compile elisp files asynchronously -*- lexical-binding: t -*- -;; Copyright (C) 2014-2016 Free Software Foundation, Inc. +;; Copyright (C) 2014-2019 Free Software Foundation, Inc. ;; Authors: John Wiegley ;; Thierry Volpiatto @@ -8,20 +8,18 @@ ;; 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 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 3 of the License, 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. +;; 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. +;; along with this program. If not, see . ;;; Commentary: ;; @@ -41,6 +39,9 @@ (require 'cl-lib) (require 'async) +(declare-function package-desc-name "package.el") +(declare-function package-desc-dir "package.el") + (defcustom async-bytecomp-allowed-packages 'all "Packages in this list will be compiled asynchronously by `package--compile'. All the dependencies of these packages will be compiled async too, @@ -91,7 +92,7 @@ All *.elc files are systematically deleted before proceeding." (async-start `(lambda () (require 'bytecomp) - ,(async-inject-variables "\\`\\(load-path\\)\\|byte\\'") + ,(async-inject-variables "\\`\\(?:load-path\\'\\|byte-\\)") (let ((default-directory (file-name-as-directory ,directory)) error-data) (add-to-list 'load-path default-directory) @@ -128,13 +129,15 @@ All *.elc files are systematically deleted before proceeding." pkgs))))))) seen)) -(defadvice package--compile (around byte-compile-async) +(defun async--package-compile (orig-fun pkg-desc &rest args) (let ((cur-package (package-desc-name pkg-desc)) (pkg-dir (package-desc-dir pkg-desc))) (if (or (member async-bytecomp-allowed-packages '(t all (all))) (memq cur-package (async-bytecomp--get-package-deps async-bytecomp-allowed-packages))) (progn + ;; FIXME: Why do we use (eq cur-package 'async) once + ;; and (string= cur-package "async") afterwards? (when (eq cur-package 'async) (fmakunbound 'async-byte-recompile-directory)) ;; Add to `load-path' the latest version of async and @@ -145,7 +148,7 @@ All *.elc files are systematically deleted before proceeding." ;; `async-byte-recompile-directory' will add directory ;; as needed to `load-path'. (async-byte-recompile-directory (package-desc-dir pkg-desc) t)) - ad-do-it))) + (apply orig-fun pkg-desc args)))) ;;;###autoload (define-minor-mode async-bytecomp-package-mode @@ -155,8 +158,8 @@ Async compilation of packages can be controlled by :group 'async :global t (if async-bytecomp-package-mode - (ad-activate 'package--compile) - (ad-deactivate 'package--compile))) + (advice-add 'package--compile :around #'async--package-compile) + (advice-remove 'package--compile #'async--package-compile))) ;;;###autoload (defun async-byte-compile-file (file) diff --git a/elpa/async-20200809.501/async-pkg.el b/elpa/async-20220104.1222/async-pkg.el similarity index 53% rename from elpa/async-20200809.501/async-pkg.el rename to elpa/async-20220104.1222/async-pkg.el index 19b84371..e6d4c862 100644 --- a/elpa/async-20200809.501/async-pkg.el +++ b/elpa/async-20220104.1222/async-pkg.el @@ -1,11 +1,11 @@ -(define-package "async" "20200809.501" "Asynchronous processing in Emacs" - '((emacs "24.3")) - :commit "14f48de586b0977e3470f053b810d77b07ea427a" :authors +(define-package "async" "20220104.1222" "Asynchronous processing in Emacs" + '((emacs "24.4")) + :commit "0d52411d3accc3e11a2c64838703a8ce9755c77c" :authors '(("John Wiegley" . "jwiegley@gmail.com")) :maintainer '("John Wiegley" . "jwiegley@gmail.com") :keywords - '("convenience" "async") + '("async") :url "https://github.com/jwiegley/emacs-async") ;; Local Variables: ;; no-byte-compile: t diff --git a/elpa/async-20200809.501/async.el b/elpa/async-20220104.1222/async.el similarity index 84% rename from elpa/async-20200809.501/async.el rename to elpa/async-20220104.1222/async.el index 6437a301..6df1b6d2 100644 --- a/elpa/async-20200809.501/async.el +++ b/elpa/async-20220104.1222/async.el @@ -1,28 +1,27 @@ -;;; async.el --- Asynchronous processing -*- lexical-binding: t -*- +;;; async.el --- Asynchronous processing in Emacs -*- lexical-binding: t -*- -;; Copyright (C) 2012-2016 Free Software Foundation, Inc. +;; Copyright (C) 2012-2019 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Created: 18 Jun 2012 -;; Version: 1.9.4 -;; Package-Requires: ((emacs "24.3")) -;; Keywords: convenience async -;; URL: https://github.com/jwiegley/emacs-async +;; Version: 1.9.5 +;; Package-Requires: ((emacs "24.4")) -;; 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. +;; Keywords: async +;; X-URL: https://github.com/jwiegley/emacs-async -;; 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. +;; 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 3 of the License, 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. +;; along with this program. If not, see . ;;; Commentary: @@ -39,7 +38,6 @@ (defcustom async-variables-noprops-function #'async--purecopy "Default function to remove text properties in variables." - :group 'async :type 'function) (defvar async-debug nil) @@ -100,14 +98,14 @@ variable's value with `async-variables-noprops-function'. It is intended to be used as follows: (async-start - `(lambda () - (require 'smtpmail) + \\=`(lambda () + (require \\='smtpmail) (with-temp-buffer (insert ,(buffer-substring-no-properties (point-min) (point-max))) ;; Pass in the variable environment for smtpmail - ,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\") + ,(async-inject-variables \"\\\\=`\\(smtpmail\\|\\(user-\\)?mail\\)-\") (smtpmail-send-it))) - 'ignore)" + \\='ignore)" `(setq ,@(let (bindings) (mapatoms @@ -164,6 +162,19 @@ It is intended to be used as follows: (kill-buffer (current-buffer)))) (set (make-local-variable 'async-callback-value) proc) (set (make-local-variable 'async-callback-value-set) t)) + ;; Maybe strip out unreadable "#"; They are replaced by + ;; empty string unless they are prefixing a special + ;; object like a marker. See issue #145. + (goto-char (point-min)) + (save-excursion + ;; Transform markers in list like + ;; (marker (moves after insertion) at 2338 in + ;; test\.org) so that remap text properties function + ;; can parse it to restitute marker. + (while (re-search-forward "#<\\([^>]*\\)>" nil t) + (replace-match (concat "(" (match-string 1) ")") t t))) + (while (re-search-forward "#(" nil t) + (replace-match "(" t t)) (goto-char (point-max)) (backward-sexp) (async-handle-result async-callback (read (current-buffer)) @@ -175,8 +186,11 @@ It is intended to be used as follows: (set (make-local-variable 'async-callback-value-set) t)))))) (defun async--receive-sexp (&optional stream) - (let ((sexp (decode-coding-string (base64-decode-string - (read stream)) 'utf-8-auto)) + ;; FIXME: Why use `utf-8-auto' instead of `utf-8-unix'? This is + ;; a communication channel over which we have complete control, + ;; so we get to choose exactly which encoding and EOL we use, isn't it? + (let ((sexp (decode-coding-string (base64-decode-string (read stream)) + 'utf-8-auto)) ;; Parent expects UTF-8 encoded text. (coding-system-for-write 'utf-8-auto)) (if async-debug @@ -184,7 +198,7 @@ It is intended to be used as follows: (setq sexp (read sexp)) (if async-debug (message "Read sexp {{{%s}}}" (pp-to-string sexp))) - (eval sexp))) + (eval sexp t))) (defun async--insert-sexp (sexp) (let (print-level @@ -226,8 +240,7 @@ It is intended to be used as follows: (defun async-ready (future) "Query a FUTURE to see if it is ready. -I.e., if no blocking -would result from a call to `async-get' on that FUTURE." +I.e., if no blocking would result from a call to `async-get' on that FUTURE." (and (memq (process-status future) '(exit signal)) (let ((buf (process-buffer future))) (if (buffer-live-p buf) @@ -333,7 +346,18 @@ will leave *emacs* process buffers hanging around): (async-start (lambda () (delete-file \"a remote file on a slow link\" nil)) - 'ignore) + \\='ignore) + +Special case: +If the output of START-FUNC is a string with properties +e.g. (buffer-string) RESULT will be transformed in a list where the +car is the string itself (without props) and the cdr the rest of +properties, this allows using in FINISH-FUNC the string without +properties and then apply the properties in cdr to this string (if +needed). +Properties handling special objects like markers are returned as +list to allow restoring them later. +See for more infos. Note: Even when FINISH-FUNC is present, a future is still returned except that it yields no value (since the value is diff --git a/elpa/async-20200809.501/dired-async.el b/elpa/async-20220104.1222/dired-async.el similarity index 89% rename from elpa/async-20200809.501/dired-async.el rename to elpa/async-20220104.1222/dired-async.el index 1dba956b..4b6f7554 100644 --- a/elpa/async-20200809.501/dired-async.el +++ b/elpa/async-20220104.1222/dired-async.el @@ -1,6 +1,6 @@ ;;; dired-async.el --- Asynchronous dired actions -*- lexical-binding: t -*- -;; Copyright (C) 2012-2016 Free Software Foundation, Inc. +;; Copyright (C) 2012-2019 Free Software Foundation, Inc. ;; Authors: John Wiegley ;; Thierry Volpiatto @@ -8,20 +8,18 @@ ;; Keywords: dired async network ;; 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 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 3 of the License, 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. +;; 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. +;; along with this program. If not, see . ;;; Commentary: @@ -52,46 +50,38 @@ (defcustom dired-async-env-variables-regexp "\\`\\(tramp-\\(default\\|connection\\|remote\\)\\|ange-ftp\\)-.*" "Variables matching this regexp will be loaded on Child Emacs." - :type 'regexp - :group 'dired-async) + :type 'regexp) (defcustom dired-async-message-function 'dired-async-mode-line-message "Function to use to notify result when operation finish. Should take same args as `message'." - :group 'dired-async :type 'function) (defcustom dired-async-log-file "/tmp/dired-async.log" "File use to communicate errors from Child Emacs to host Emacs." - :group 'dired-async :type 'string) (defcustom dired-async-mode-lighter '(:eval (when (eq major-mode 'dired-mode) " Async")) "Mode line lighter used for `dired-async-mode'." - :group 'dired-async :risky t :type 'sexp) (defface dired-async-message - '((t (:foreground "yellow"))) - "Face used for mode-line message." - :group 'dired-async) + '((t (:foreground "yellow"))) + "Face used for mode-line message.") (defface dired-async-failures - '((t (:foreground "red"))) - "Face used for mode-line message." - :group 'dired-async) + '((t (:foreground "red"))) + "Face used for mode-line message.") (defface dired-async-mode-message - '((t (:foreground "Gold"))) - "Face used for `dired-async--modeline-mode' lighter." - :group 'dired-async) + '((t (:foreground "Gold"))) + "Face used for `dired-async--modeline-mode' lighter.") (define-minor-mode dired-async--modeline-mode - "Notify mode-line that an async process run." - :group 'dired-async + "Notify mode-line that an async process run." :global t :lighter (:eval (propertize (format " [%s Async job(s) running]" (length (dired-async-processes))) @@ -321,8 +311,8 @@ ESC or `q' to not overwrite any of the remaining files, do (condition-case err (funcall fn from dest t) (file-error - (dired-log "%s: %s\n" (car err) (cdr err))) - nil)) + (dired-log "%s: %s\n" (car err) (cdr err)) + nil))) (when (get-buffer dired-log-buffer) (dired-log t) (with-current-buffer dired-log-buffer @@ -343,31 +333,18 @@ ESC or `q' to not overwrite any of the remaining files, (let (wdired-use-interactive-rename) (apply old-fn args))) -(defadvice wdired-do-renames (around wdired-async) - (let (wdired-use-interactive-rename) - ad-do-it)) - -(defadvice dired-create-files (around dired-async) - (dired-async-create-files file-creator operation fn-list - name-constructor marker-char)) - ;;;###autoload (define-minor-mode dired-async-mode "Do dired actions asynchronously." - :group 'dired-async :lighter dired-async-mode-lighter :global t (if dired-async-mode - (if (fboundp 'advice-add) - (progn (advice-add 'dired-create-files :override #'dired-async-create-files) - (advice-add 'wdired-do-renames :around #'dired-async-wdired-do-renames)) - (ad-activate 'dired-create-files) - (ad-activate 'wdired-do-renames)) - (if (fboundp 'advice-remove) - (progn (advice-remove 'dired-create-files #'dired-async-create-files) - (advice-remove 'wdired-do-renames #'dired-async-wdired-do-renames)) - (ad-deactivate 'dired-create-files) - (ad-deactivate 'wdired-do-renames)))) + (progn + (advice-add 'dired-create-files :override #'dired-async-create-files) + (advice-add 'wdired-do-renames :around #'dired-async-wdired-do-renames)) + (progn + (advice-remove 'dired-create-files #'dired-async-create-files) + (advice-remove 'wdired-do-renames #'dired-async-wdired-do-renames)))) (defmacro dired-async--with-async-create-files (&rest body) "Evaluate BODY with ‘dired-create-files’ set to ‘dired-async-create-files’." diff --git a/elpa/async-20200809.501/smtpmail-async.el b/elpa/async-20220104.1222/smtpmail-async.el similarity index 82% rename from elpa/async-20200809.501/smtpmail-async.el rename to elpa/async-20220104.1222/smtpmail-async.el index ac269231..5a1c3205 100644 --- a/elpa/async-20200809.501/smtpmail-async.el +++ b/elpa/async-20220104.1222/smtpmail-async.el @@ -8,20 +8,18 @@ ;; Keywords: email async ;; X-URL: https://github.com/jwiegley/emacs-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 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 3 of the License, 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. +;; 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. +;; along with this program. If not, see . ;;; Commentary: -- 2.47.3