Subject: bug#65023: 29.1.50; Tramp 2.6.1.1 cannot be installed as ELPA package

From: Jim Porter <[email-masked]>
Date: Fri, 4 Aug 2023 09:40:12 -0700

On 8/2/2023 7:16 AM, Michael Albinus wrote:
> With Emacs 29.1, ELPA package Tramp 2.6.1.1 cannot be installed. See the
> *Compile-Log* buffer appended. It looks like the problem is due to
> changes in generation of autoloads.
> 
> Since I'm not familiar with the changes, I don't know how to fix
> this. Note, that the same package installs w/o problems in Emacs 28.

(See also the tramp-devel discussion[1].)

Ok, I figured this out. The new loaddefs code was clobbering a regexp 
internally when doing some additional checks while scanning for autoload 
cookies in external package code. That resulted in some autoloads ending 
up in the wrong file. The fix is just to call 'save-match-data' at the 
right spot.

Eli, is this ok for 29.2? It's a small change, and I think is a fairly 
serious regression from 28.

[1] https://lists.gnu.org/archive/html/tramp-devel/2023-07/msg00009.html

From 5252362cd13c381fea07129f99808c50cd03e1ab Mon Sep 17 00:00:00 2001
From: Jim Porter <[email-masked]>
Date: Fri, 4 Aug 2023 09:31:59 -0700
Subject: [PATCH] Fix loaddef generation with ";;;foo-autoload" cookies in
 external packages

This caused an issue where package-specific autoload cookies weren't
being correctly recognized, so they got dumped into the package's main
"<pkg>-autoloads.el" file, instead of "<pkg>-loaddefs.el" as they
should (bug#65023).

* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--parse-file):
Save match data when checking syntax.
---
 lisp/emacs-lisp/loaddefs-gen.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index 5db9af21508..d7b9b131bc8 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -431,7 +431,8 @@ loaddefs-generate--parse-file
                     ;; have an autoload cookie on the first column of a
                     ;; doc string or the like.  (The Emacs tree
                     ;; shouldn't contain any such instances.)
-                    (not (ppss-string-terminator (syntax-ppss))))
+                    (not (ppss-string-terminator
+                          (save-match-data (syntax-ppss)))))
             ;; ... and if we have one of these names, then alter outfile.
             (let* ((aname (match-string 2))
                    (to-file (if aname
-- 
2.25.1