From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cufxJ-0002VM-3m for guix-patches@gnu.org; Sun, 02 Apr 2017 09:54:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cufxF-0000SF-MG for guix-patches@gnu.org; Sun, 02 Apr 2017 09:54:09 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:58372) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cufxF-0000SA-Ic for guix-patches@gnu.org; Sun, 02 Apr 2017 09:54:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cufxF-0000by-Bh for guix-patches@gnu.org; Sun, 02 Apr 2017 09:54:05 -0400 Subject: bug#26339: [PATCH 09/18] scripts: system: Move save-load-path-excursion and save-environment-excursion macros to the top. Resent-Message-ID: From: Mathieu Othacehe Date: Sun, 2 Apr 2017 15:52:33 +0200 Message-Id: <20170402135242.2958-9-m.othacehe@gmail.com> In-Reply-To: <20170402135242.2958-1-m.othacehe@gmail.com> References: <20170402135242.2958-1-m.othacehe@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 26339@debbugs.gnu.org * guix/scripts/system.scm (save-load-path-excursion, save-environment-excursion): Move definitions to the top of the file. It allows to use them in the whole file. --- guix/scripts/system.scm | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 04274919e..2ad210207 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès ;;; Copyright © 2016 Alex Kost ;;; Copyright © 2016 Chris Marusich +;;; Copyright © 2017 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. ;;; @@ -77,6 +78,29 @@ ;;; Installation. ;;; +(define-syntax-rule (save-load-path-excursion body ...) + "Save the current values of '%load-path' and '%load-compiled-path', run +BODY..., and restore them." + (let ((path %load-path) + (cpath %load-compiled-path)) + (dynamic-wind + (const #t) + (lambda () + body ...) + (lambda () + (set! %load-path path) + (set! %load-compiled-path cpath))))) + +(define-syntax-rule (save-environment-excursion body ...) + "Save the current environment variables, run BODY..., and restore them." + (let ((env (environ))) + (dynamic-wind + (const #t) + (lambda () + body ...) + (lambda () + (environ env))))) + (define topologically-sorted* (store-lift topologically-sorted)) @@ -201,29 +225,6 @@ the ownership of '~a' may be incorrect!~%") ;; The system profile. (string-append %state-directory "/profiles/system")) -(define-syntax-rule (save-environment-excursion body ...) - "Save the current environment variables, run BODY..., and restore them." - (let ((env (environ))) - (dynamic-wind - (const #t) - (lambda () - body ...) - (lambda () - (environ env))))) - -(define-syntax-rule (save-load-path-excursion body ...) - "Save the current values of '%load-path' and '%load-compiled-path', run -BODY..., and restore them." - (let ((path %load-path) - (cpath %load-compiled-path)) - (dynamic-wind - (const #t) - (lambda () - body ...) - (lambda () - (set! %load-path path) - (set! %load-compiled-path cpath))))) - (define-syntax-rule (with-shepherd-error-handling mbody ...) "Catch and report Shepherd errors that arise when binding MBODY, a monadic expression in %STORE-MONAD." -- 2.12.2