all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "DE BACKER Jurgen (EXT)" <jurgen.de-backer.ext@eurocontrol.int>
Cc: 67930@debbugs.gnu.org
Subject: bug#67930: 29.1; emacs 29.1 follows symlinks when a grep result is selected
Date: Sat, 23 Dec 2023 13:10:57 +0200	[thread overview]
Message-ID: <8334vtdvi6.fsf@gnu.org> (raw)
In-Reply-To: <AS2PR08MB1005345C1653E9D146C67FD0E9594A@AS2PR08MB10053.eurprd08.prod.outlook.com> (jurgen.de-backer.ext@eurocontrol.int)

> From: "DE BACKER Jurgen (EXT)" <jurgen.de-backer.ext@eurocontrol.int>
> CC: "67930@debbugs.gnu.org" <67930@debbugs.gnu.org>
> Date: Fri, 22 Dec 2023 16:20:42 +0000
> 
> > From: Eli Zaretskii <eliz@gnu.org>
> > Sent: Wednesday, December 20, 2023 7:47 PM
> > To: DE BACKER Jurgen (EXT) <jurgen.de-backer.ext@eurocontrol.int>
> > Cc: 67930@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.





  reply	other threads:[~2023-12-23 11:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 13:54 bug#67930: 29.1; emacs 29.1 follows symlinks when a grep result is selected Jurgen De Backer via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-20 18:46 ` Eli Zaretskii
2023-12-22 16:20   ` DE BACKER Jurgen (EXT) via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-23 11:10     ` Eli Zaretskii [this message]
2024-01-04 11:10       ` DE BACKER Jurgen (EXT) via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-06 10:35         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8334vtdvi6.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=67930@debbugs.gnu.org \
    --cc=jurgen.de-backer.ext@eurocontrol.int \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.