Subject: bug#63480: 30.0.50; [BUG] unimplemented logic regarding read-symbol-shorthands

From: João Távora <[email-masked]>
Date: Wed, 6 Sep 2023 15:02:31 +0100

On Wed, Sep 6, 2023, 12:03 Stefan Kangas <[email-masked]> wrote:

> João, could you take a look at the below bug?
>
> It seems to be related to the shorthands feature, and your package
> breadcrumb.
>

The bug report for breadcrumb in itself is no longer relevant since that
code isn't there anymore.  This is a duplicate of

   https://github.com/joaotavora/breadcrumb/issues/3

which has already been solved.  I updated the autoloads to use
longhand versions already a couple of months ago.

I'll leave it to you if this issue can be closed or not.

Anyway, the problem with shorthands and autoloads remains.
The GitHub user 'dickmao' proposed a patch there, which I
didn't test, but I attach here.

My idea for an alternative patch would be for the "autoload
extractor" (which I'm not familiar with) to see the shorthand
autoload but place it in longhand form in the generated
autoloads file.  I don't have a patch for that idea,
unfortunately.

João
From 8a5275afa57160f7b7a9d71af2342c06e0c0d652 Mon Sep 17 00:00:00 2001
From: dickmao <none>
Date: Fri, 12 May 2023 21:44:47 -0400
Subject: [PATCH] propagate shorthands to autoloads

---
 lisp/emacs-lisp/generate-lisp-file.el |  7 +++++--
 lisp/emacs-lisp/loaddefs-gen.el       | 15 ++++++++++-----
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/generate-lisp-file.el b/lisp/emacs-lisp/generate-lisp-file.el
index c6148003a5e..6d1e5292871 100644
--- a/lisp/emacs-lisp/generate-lisp-file.el
+++ b/lisp/emacs-lisp/generate-lisp-file.el
@@ -63,7 +63,8 @@ generate-lisp-file-heading
 
 (cl-defun generate-lisp-file-trailer (file &key version inhibit-provide
                                       (coding 'utf-8-emacs-unix) autoloads
-                                      compile provide inhibit-native-compile)
+                                      compile provide inhibit-native-compile
+                                      shorthands)
   "Insert a standard trailer for FILE.
 By default, this trailer inhibits version control, byte
 compilation, updating autoloads, and uses a `utf-8-emacs-unix'
@@ -81,7 +82,7 @@ generate-lisp-file-trailer
 If `standard-output' is bound to a buffer, insert in that buffer.
 If no, insert at point in the current buffer.
 
-If INHITBIT-NATIVE-COMPILE is non-nil, add a cookie to inhibit
+If INHIBIT-NATIVE-COMPILE is non-nil, add a cookie to inhibit
 native compilation.  (By default, a file will be native-compiled
 if it's also byte-compiled)."
   (with-current-buffer (if (bufferp standard-output)
@@ -110,6 +111,8 @@ generate-lisp-file-trailer
                       (if (eq coding t)
                           'utf-8-emacs-unix
                         coding))))
+    (when shorthands
+      (insert (format ";; read-symbol-shorthands: %S\n" shorthands)))
     (insert
      ";; End:\n\n"
      ";;; " (file-name-nondirectory file) " ends here\n")))
diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index 8fafb458438..f437a952606 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -494,7 +494,7 @@ loaddefs-generate--compute-prefixes
             (push name prefs)))))
     (loaddefs-generate--make-prefixes prefs load-name)))
 
-(defun loaddefs-generate--rubric (file &optional type feature compile)
+(defun loaddefs-generate--rubric (file &optional type feature compile shorthands)
   "Return a string giving the appropriate autoload rubric for FILE.
 TYPE (default \"autoloads\") is a string stating the type of
 information contained in FILE.  TYPE \"package\" acts like the default,
@@ -520,7 +520,8 @@ loaddefs-generate--rubric
        file :provide (and (stringp feature) feature)
        :compile compile
        :inhibit-native-compile t
-       :inhibit-provide (not feature))
+       :inhibit-provide (not feature)
+       :shorthands shorthands)
       (buffer-string))))
 
 ;;;###autoload
@@ -565,7 +566,7 @@ loaddefs-generate
                                                   t files-re))
 			       (if (consp dir) dir (list dir)))))
          (updating (and (file-exists-p output-file) (not generate-full)))
-         (defs nil))
+         defs shorthands)
 
     ;; Allow the excluded files to be relative.
     (setq excluded-files
@@ -594,7 +595,11 @@ loaddefs-generate
             (when (or package-data (not excluded))
               (setq defs (nconc (loaddefs-generate--parse-file
                                  file output-file package-data)
-                                defs))))))
+                                defs)
+                    shorthands (nconc (with-temp-buffer
+                                        (save-excursion (insert-file-contents file))
+                                        (hack-read-symbol-shorthands))
+                                      shorthands))))))
       (progress-reporter-done progress))
 
     ;; First group per output file.
@@ -606,7 +611,7 @@ loaddefs-generate
           (if (and updating (file-exists-p loaddefs-file))
               (insert-file-contents loaddefs-file)
             (insert (loaddefs-generate--rubric
-                     loaddefs-file nil t include-package-version))
+                     loaddefs-file nil t include-package-version shorthands))
             (search-backward "\f")
             (when extra-data
               (insert extra-data)
-- 
2.38.1