From 58d0453aa7772def4de8e6aee38212a29aa84978 Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Wed, 10 Aug 2022 13:37:09 -0400
Subject: build-system: emacs: Use new function for autoloads generation

* guix/build/emacs-utils.scm (emacs-generate-autoloads): Use
'loaddefs-generate' to create autoloads instead of
'update-directory-autoloads' if we are using a new enough Emacs

Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
 guix/build/emacs-utils.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'guix/build')

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index fdca05602e..b2280ae70c 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -106,7 +106,14 @@ true, evaluate using dynamic scoping."
   (let* ((file (string-append directory "/" name "-autoloads.el"))
          (expr `(let ((backup-inhibited t)
                       (generated-autoload-file ,file))
-                  (update-directory-autoloads ,directory))))
+                  (cond
+                   ((require 'loaddefs-gen nil t)
+                    ;; Emacs >= 29
+                    (loaddefs-generate ,directory ,file))
+                   ((fboundp 'make-directory-autoloads)
+                    ;; Emacs 28
+                    (make-directory-autoloads ,directory ,file))
+                   (t (update-directory-autoloads ,directory))))))
     (emacs-batch-eval expr #:dynamic? #t)))
 
 (define* (emacs-byte-compile-directory dir)
-- 
cgit v1.2.3