aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/package-vc.el43
1 files changed, 32 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index d475010eaaf..6134e6ed3da 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -513,17 +513,38 @@ the `:brach' attribute in PKG-SPEC."
513 513
514(defun package-vc-update (pkg-desc) 514(defun package-vc-update (pkg-desc)
515 "Attempt to update the packager PKG-DESC." 515 "Attempt to update the packager PKG-DESC."
516 (let* ((default-directory (package-desc-dir pkg-desc)) 516 ;; HACK: To run `package-vc-unpack-1' after checking out the new
517 (ret (with-demoted-errors "Error during package update: %S" 517 ;; revision, we insert a hook into `vc-post-command-functions', and
518 (vc-pull))) 518 ;; remove it right after it ran. To avoid running the hook multiple
519 (buf (cond 519 ;; times or even for the wrong repository (as `vc-pull' is often
520 ((processp ret) (process-buffer ret)) 520 ;; asynchronous), we extract the relevant arguments using a pseudo
521 ((bufferp ret) ret)))) 521 ;; filter for `vc-filter-command-function', executed only for the
522 (if buf 522 ;; side effect, and store them in the lexical scope. When the hook
523 (with-current-buffer buf 523 ;; is run, we check if the arguments are the same (`eq') as the ones
524 (vc-run-delayed 524 ;; previously extracted, and only in that case will be call
525 (package-vc-unpack-1 pkg-desc default-directory))) 525 ;; `package-vc-unpack-1'. Ugh...
526 (package-vc-unpack-1 pkg-desc default-directory)))) 526 ;;
527 ;; If there is a better way to do this, it should be done.
528 (letrec ((pkg-dir (package-desc-dir pkg-desc))
529 (empty (make-symbol empty))
530 (args (list empty empty empty))
531 (vc-filter-command-function
532 (lambda (command file-or-list flags)
533 (setf (nth 0 args) command
534 (nth 1 args) file-or-list
535 (nth 2 args) flags)
536 (list command file-or-list flags)))
537 (post-upgrade
538 (lambda (command file-or-list flags)
539 (when (and (memq (nth 0 args) (list command empty))
540 (memq (nth 1 args) (list file-or-list empty))
541 (memq (nth 2 args) (list flags empty)))
542 (with-demoted-errors "Failed to activate: %S"
543 (package-vc-unpack-1 pkg-desc pkg-dir))
544 (remove-hook 'vc-post-command-functions post-upgrade)))))
545 (add-hook 'vc-post-command-functions post-upgrade)
546 (with-demoted-errors "Failed to fetch: %S"
547 (vc-pull))))
527 548
528(defun package-vc--archives-initialize () 549(defun package-vc--archives-initialize ()
529 "Initialise package.el and fetch package specifications." 550 "Initialise package.el and fetch package specifications."