emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature/package-vc has been merged


From: Philip Kaludercic
Subject: Re: feature/package-vc has been merged
Date: Wed, 09 Nov 2022 08:15:52 +0000

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>      (loaddefs-generate
>> -     pkg-dir output-file
>> -     nil
>> -     "(add-to-list 'load-path (directory-file-name
>> -                         (or (file-name-directory #$) (car load-path))))")
>> +     (file-name-concat pkg-dir lisp-dir)
>> +     output-file nil
>> +     (prin1-to-string
>> +      `(add-to-list 'load-path
>> +                    (directory-file-name
>> +                     ,(file-name-concat pkg-dir lisp-dir)))))
>>      (let ((buf (find-buffer-visiting output-file)))
>>        (when buf (kill-buffer buf)))
>>      auto-name))
>> --8<---------------cut here---------------end--------------->8---
>>
>> Git tells me that Lars was wrote the "(or (file-name-directory #$) (car
>> load-path))" bit, so I've added him to the CC's: Can you explain what
>> the intention was here, and if my suggested replacement would break
>> anything?
>
> I suspect he just copy/pasted the code from elsewhere.
> The point is to make the file work regardless of where it is whereas
> your replacement makes it work only in the location we used to
> generate it.

I see, that makes sense.

> You can/should replace #$ with `load-file-name`, which will make it
> behave better w.r.t byte-compilation.

I suspected so much from lread.c, but wanted to make sure.

So in that case the following should suffice:

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 0881626e92..67ce30a93c 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1103,8 +1103,17 @@ package-generate-autoloads
      (package-lisp-dir pkg-desc)
      output-file nil
      (prin1-to-string
-      `(add-to-list 'load-path
-                    ,(package-lisp-dir pkg-desc))))
+      `(add-to-list
+        'load-path
+        (file-name-concat
+         ;; Add the directory that will contain the autoload file to
+         ;; the load path.  We don't hard-code `pkg-dir', to avoid
+         ;; issues if the package directory is moved around.
+         (or (and load-file-name (file-name-directory load-file-name))
+             (car load-path))
+         ;; In case the package specification indicates that the lisp
+         ;; files are found in a subdirectory, append that path.
+         ,(alist-get :lisp-dir (package-desc-extras pkg-desc))))))
     (let ((buf (find-buffer-visiting output-file)))
       (when buf (kill-buffer buf)))
     auto-name))
>
>         Stefan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]