GNU bug report logs -
#67930
29.1; emacs 29.1 follows symlinks when a grep result is selected
Previous Next
Full log
Message #14 received at 67930 <at> debbugs.gnu.org (full text, mbox):
> From: "DE BACKER Jurgen (EXT)" <jurgen.de-backer.ext <at> eurocontrol.int>
> CC: "67930 <at> debbugs.gnu.org" <67930 <at> debbugs.gnu.org>
> Date: Fri, 22 Dec 2023 16:20:42 +0000
>
> > From: Eli Zaretskii <eliz <at> gnu.org>
> > Sent: Wednesday, December 20, 2023 7:47 PM
> > To: DE BACKER Jurgen (EXT) <jurgen.de-backer.ext <at> eurocontrol.int>
> > Cc: 67930 <at> debbugs.gnu.org
> > Subject: Re: bug#67930: 29.1; emacs 29.1 follows symlinks when a grep result
> > is selected
> >
> > Thanks, but I don't think this is a matter of user preferences. We replaced
> > expand-file-name there by file-truename because in some cases the former
> > doesn't work: it expands to a file that doesn't exist. See bug#8035, where
> > such cases are presented. We cannot ask the user to set or reset this option
> > each time they need to work with these or those file names.
> >
> > So I don't think the fix you propose is the right one. I think we need to use
> > expand-file-name where it works, and file-truename where expand-file-
> > name doesn't work. Or maybe just try expand-file-name first, and if that
> > produces a file name that fails file-exists-p, try file-truename.
> >
> > Would you like to propose and test a patch along these lines?
>
> Hi Eli,
>
> Please find attached a patch that does this: first we try to expand the file name with expand-file-name
> and if this fails, retry with file-truename.
Thanks. I have a couple of minor comments:
> # In emacs 29.1, when clicking on a file link in the *grep* results buffer,
> # symlinks are resolved to the actual filename(s). In some cases this is not preferable.
> #
> # This patch -1 will first use the previous behaviour (using expand-file-name) to resolve a (relative) filename
> # -2 if this fails (i.e. the result is not an existing file), we try with the new behaviour
> # which uses function file-truename.
> #
> # In emacs 29.1 expand-file-name was replaced by file-truename to solve bug #8035,
> # because in specific cases expand-file-name returned a wrong/non existing file.
> # Unlike expand-file-name, file-truename follows symlinks.
Could you please reformat this log message using our style? The
details can be found in the file CONTRIBUTE in the Emacs Git
repository.
> --- lisp/progmodes/compile.el.orig 2023-02-11 12:06:09.000000000 +0000
> +++ lisp/progmodes/compile.el 2023-12-21 17:22:34.000688000 +0000
> @@ -3108,7 +3108,7 @@
> (spec-dir (if directory
> (expand-file-name directory)
> default-directory))
> - buffer thisdir fmts name)
> + buffer thisdir fmts expandedname name)
> (if (and filename
> (file-name-absolute-p filename))
> ;; The file name is absolute. Use its explicit directory as
> @@ -3122,8 +3122,10 @@
> fmts formats)
> ;; For each directory, try each format string.
> (while (and fmts (null buffer))
> - (setq name (file-truename
> - (file-name-concat thisdir (format (car fmts) filename)))
> + (setq expandedname (expand-file-name (format (car fmts) filename) thisdir)
> + name (if (file-exists-p expandedname) ;; See bug #8035 expand-file-name fails in specific cases
> + expandedname
> + (file-truename (file-name-concat thisdir (format (car fmts) filename))))
> buffer (and (file-exists-p name)
> (find-file-noselect name))
> fmts (cdr fmts)))
Your changes repeat the same pattern several times, so I think it
would be better to factor out this code into a separate function, and
then call that function in those places. Would you like to rewrite
the patch along these lines?
Thanks again for working on this.
This bug report was last modified 1 year and 230 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.