Radon Rosborough <radon.n...@gmail.com> writes:

> When I perform a fresh build of AUCTeX from Git, I get the following
> code as part of tex-site.el:
>
>     (defvar TeX-lisp-directory
>       (expand-file-name "auctex" (file-name-directory load-file-name))
>       "The directory where most of the AUCTeX lisp files are located.
>     For the location of lisp files associated with
>     styles, see the variables TeX-style-* (hand-generated lisp) and
>     TeX-auto-* (automatically generated lisp).")
>
>     (add-to-list 'load-path TeX-lisp-directory)
>
> This is problematic. As the documentation for `load-path' states:
>
>     Use ‘directory-file-name’ when adding items to this path.
>
> But `TeX-lisp-directory' has a trailing slash. This seems like a bug
> to me. Can it be fixed?
Thank you for the report.
I see in the sources of this package the following address to submit bug
reports: bug-auctex@gnu.org (`TeX-submit-bug-report').


> The reason this came up is that I maintain an Emacs package manager,
> straight.el. Once straight.el builds a package, it adds the directory
> to `load-path', using `directory-file-name' as specified by the
> documentation of `load-path'. But since AUCTeX insists on also adding
> its own entry to `load-path', and does so with a superfluous trailing
> slash, we end up with two duplicate entries. Under some
> configurations, this causes duplicate entries to appear when using M-x
> find-library.
You could find this problem again with other packages in the future.
Maybe it's good idea to add some defensive code, for instance:
--8<-----------------------------cut here---------------start------------->8---
commit 3e1e25c888a28971d818d82270ce1116feb6fb75
Author: Tino Calancha <tino.calan...@gmail.com>
Date:   Sat Apr 14 21:35:49 2018 +0900

    Prevent from adding a dir with trailing slashes into load-path
    
    (straight--drop-trailing-slashes-from-load-path): New defun.
    (straight--add-package-to-load-path): Use it.

diff --git a/straight.el b/straight.el
index 3459057..e62a590 100644
--- a/straight.el
+++ b/straight.el
@@ -3300,12 +3300,25 @@ the reason this package is being built."
 
 ;;;; Loading packages
 
+(defun straight--drop-trailing-slashes-from-load-path ()
+  "Return a copy of `load-path' with stripped trailing slashes.
+For instance, change the directory `/foo/bar/' into `/foo/bar'."
+  (delete-dups
+   (mapcar
+    (lambda (dir)
+      (let ((len (length dir)))
+        (while (and (> len 0) (eq ?/ (aref dir (1- len))))
+          (setq dir (substring dir 0 -1)
+                len (1- len)))
+        dir)) load-path)))
+
 (defun straight--add-package-to-load-path (recipe)
   "Add the package specified by RECIPE to the `load-path'.
 RECIPE is a straight.el-style plist. It is assumed that the
 package has already been built."
   (straight--with-plist recipe
       (package)
+    (setf load-path (straight--drop-trailing-slashes-from-load-path))
     (add-to-list 'load-path (straight--build-dir package))))
 
 (defun straight--add-package-to-info-path (recipe)

--8<-----------------------------cut here---------------end--------------->8---



_______________________________________________
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex

Reply via email to