GNU bug report logs -
#78855
[PATCH] Expand DIR arg on `package-vc-install-from-checkout'
Previous Next
Reported by: Roi Martin <jroi.martin <at> gmail.com>
Date: Sat, 21 Jun 2025 11:55:02 UTC
Severity: normal
Tags: patch
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> From: Roi Martin <jroi.martin <at> gmail.com>
> Cc: 78855 <at> debbugs.gnu.org, philipk <at> posteo.net
> Date: Sat, 21 Jun 2025 20:28:17 +0200
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> (interactive (let* ((dir (read-directory-name "Directory: "))
> >> - (base (file-name-base (directory-file-name dir))))
> >> + (base (file-name-base (directory-file-name (expand-file-name dir)))))
> >> (list dir (and current-prefix-arg
> >> (read-string
> >> (format-prompt "Package name" base)
> >> nil nil base)))))
> >> (package-vc--archives-initialize)
> >> - (let* ((name (or name (file-name-base (directory-file-name dir))))
> >> + (let* ((dir (expand-file-name dir))
> >> + (name (or name (file-name-base (directory-file-name dir))))
> >
> > Can we avoid this duplicate call to expand-file-name in the
> > interactive invocation?
>
> I don't think so. If I'm not wrong, `interactive' must be located at
> top-level and be the first form in the body (not counting `declare').
> Additionally, we also want to expand the directory name when the command
> is called from Emacs Lisp. So, I don't see how to deduplicate that
> call.
But there are ways to know if the call was interactive, right?
> In fact,
>
> (file-name-base (directory-file-name ...))
>
> was already duplicated. Maybe because of the same reason? Any hint to
> avoid this?
It would be good to avoid that as well. However, while file-name-base
is a very simple function that just transforms its string argument,
expand-file-name is much more complex, and can be expensive,
especially if the file name is remote.
This bug report was last modified 19 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.