In Emacs 27, --eval now evaluates using lexical scoping. This change adds an
option to select dynamic scoping, by using a workaround proposed in
<https://bugs.gnu.org/39823>.
* guix/build/emacs-utils.scm (emacs-batch-eval): Add a DYNAMIC? keyword
argument. Wrap the EXPR with a call to EVAL that makes use of the argument
to select the scoping mode.
(emacs-generate-autoloads): Use it.
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
-;;; Copyright © 2018 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2018, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2019 Leo Prikler <leo.prikler@student.tugraz.at>
;;;
;;; This file is part of GNU Guix.
;;; Copyright © 2019 Leo Prikler <leo.prikler@student.tugraz.at>
;;;
;;; This file is part of GNU Guix.
(define-module (guix build emacs-utils)
#:use-module (guix build utils)
(define-module (guix build emacs-utils)
#:use-module (guix build utils)
+ #:use-module (ice-9 format)
#:export (%emacs
emacs-batch-eval
emacs-batch-edit-file
#:export (%emacs
emacs-batch-eval
emacs-batch-edit-file
expr
(format #f "~s" expr)))
expr
(format #f "~s" expr)))
-(define (emacs-batch-eval expr)
- "Run Emacs in batch mode, and execute the elisp code EXPR."
+(define* (emacs-batch-eval expr #:key dynamic?)
+ "Run Emacs in batch mode, and execute the Elisp code EXPR. If DYNAMIC? is
+true, evaluate using dynamic scoping."
(invoke (%emacs) "--quick" "--batch"
(invoke (%emacs) "--quick" "--batch"
- (string-append "--eval=" (expr->string expr))))
+ (format #f "--eval=(eval '~a ~:[t~;nil~])"
+ (expr->string expr) dynamic?)))
(define (emacs-batch-edit-file file expr)
"Load FILE in Emacs using batch mode, and execute the elisp code EXPR."
(define (emacs-batch-edit-file file expr)
"Load FILE in Emacs using batch mode, and execute the elisp code EXPR."
(expr `(let ((backup-inhibited t)
(generated-autoload-file ,file))
(update-directory-autoloads ,directory))))
(expr `(let ((backup-inhibited t)
(generated-autoload-file ,file))
(update-directory-autoloads ,directory))))
- (emacs-batch-eval expr)))
+ (emacs-batch-eval expr #:dynamic? #t)))
(define* (emacs-byte-compile-directory dir)
"Byte compile all files in DIR and its sub-directories."
(define* (emacs-byte-compile-directory dir)
"Byte compile all files in DIR and its sub-directories."