emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 783af29: * packages/async: Use cl-lib an nadvice


From: Stefan Monnier
Subject: [elpa] master 783af29: * packages/async: Use cl-lib an nadvice
Date: Tue, 23 Jul 2019 12:22:26 -0400 (EDT)

branch: master
commit 783af291680dbb20554d6ff4dbacf640d85df797
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * packages/async: Use cl-lib an nadvice
    
    * packages/async/async-bytecomp.el: (async--package-compile):
    New function, extracted from the old defadvice.
    (package-compile): Remove defadvice.
    (async-bytecomp-package-mode): Advise/Unadvise package--compile.
    
    * packages/async/async-test.el: Don't needlessly require `cl`.
    Use lexical-binding.
    
    * packages/async/async.el: Require cl-lib and nadvice.
    (async--receive-sexp): Consistently use lexical-binding.
    
    * packages/async/dired-async.el : Remove redundant :groups.
    (dired-async-mode): Simplify.
---
 packages/async/async-bytecomp.el | 12 +++++++-----
 packages/async/async-test.el     | 11 ++---------
 packages/async/async.el          |  8 +++++---
 packages/async/dired-async.el    | 32 ++++++++------------------------
 4 files changed, 22 insertions(+), 41 deletions(-)

diff --git a/packages/async/async-bytecomp.el b/packages/async/async-bytecomp.el
index 9ee3071..082b31a 100644
--- a/packages/async/async-bytecomp.el
+++ b/packages/async/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 <address@hidden>
 ;;          Thierry Volpiatto <address@hidden>
@@ -143,12 +143,14 @@ All *.elc files are systematically deleted before 
proceeding."
                   (append async-bytecomp-allowed-packages reqs)))
         async-bytecomp-allowed-packages)))
 
-(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 (equal async-bytecomp-allowed-packages '(all))
             (memq cur-package (async-bytecomp-get-allowed-pkgs)))
         (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
@@ -159,7 +161,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
@@ -169,8 +171,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)))
 
 (provide 'async-bytecomp)
 
diff --git a/packages/async/async-test.el b/packages/async/async-test.el
index 76d6a3a..5387aa0 100644
--- a/packages/async/async-test.el
+++ b/packages/async/async-test.el
@@ -1,6 +1,6 @@
-;;; async-test.el --- async.el-related tests
+;;; async-test.el --- async.el-related tests  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Created: 10 Jul 2012
@@ -32,9 +32,6 @@
 (require 'async)
 
 
-(eval-when-compile
-  (require 'cl))
-
 (defun async-test-1 ()
   (interactive)
   (message "Starting async-test-1...")
@@ -134,7 +131,3 @@
 (provide 'async-test)
 
 ;;; async-test.el ends here
-
-;; Local Variables:
-;; no-byte-compile: t
-;; End:
diff --git a/packages/async/async.el b/packages/async/async.el
index dfe97f6..ce651de 100644
--- a/packages/async/async.el
+++ b/packages/async/async.el
@@ -1,10 +1,11 @@
 ;;; 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 <address@hidden>
 ;; Created: 18 Jun 2012
 ;; Version: 1.9.2
+;; Package-Requires: ((cl-lib "0.5") (nadvice "0.3"))
 
 ;; Keywords: async
 ;; X-URL: https://github.com/jwiegley/emacs-async
@@ -121,7 +122,8 @@ as follows:
 
 (defun async--receive-sexp (&optional stream)
   (let ((sexp (decode-coding-string (base64-decode-string
-                                     (read stream)) 'utf-8-unix))
+                                     (read stream))
+                                    'utf-8-unix))
        ;; Parent expects UTF-8 encoded text.
        (coding-system-for-write 'utf-8-unix))
     (if async-debug
@@ -129,7 +131,7 @@ 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
diff --git a/packages/async/dired-async.el b/packages/async/dired-async.el
index ed37953..dd3c50f 100644
--- a/packages/async/dired-async.el
+++ b/packages/async/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 <address@hidden>
 ;;          Thierry Volpiatto <address@hidden>
@@ -52,38 +52,31 @@
 (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)
 
 (defface dired-async-message
     '((t (:foreground "yellow")))
-  "Face used for mode-line message."
-  :group 'dired-async)
+  "Face used for mode-line message.")
 
 (defface dired-async-failures
     '((t (:foreground "red")))
-  "Face used for mode-line message."
-  :group 'dired-async)
+  "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)
+  "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
   :global t
   :lighter (:eval (propertize (format " [%s Async job(s) running]"
                                       (length (dired-async-processes)))
@@ -310,22 +303,13 @@ ESC or `q' to not overwrite any of the remaining files,
       (dired-async--modeline-mode 1)
       (message "%s proceeding asynchronously..." operation))))
 
-(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
+  "Do dired actions asynchronously."
   :global t
   (if dired-async-mode
-      (if (fboundp 'advice-add)
-          (advice-add 'dired-create-files :override #'dired-async-create-files)
-          (ad-activate 'dired-create-files))
-      (if (fboundp 'advice-remove)
-          (advice-remove 'dired-create-files #'dired-async-create-files)
-          (ad-deactivate 'dired-create-files))))
+      (advice-add 'dired-create-files :override #'dired-async-create-files)
+    (advice-remove 'dired-create-files #'dired-async-create-files)))
 
 
 (provide 'dired-async)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]