bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#67930: 29.1; emacs 29.1 follows symlinks when a grep result is selec


From: DE BACKER Jurgen (EXT)
Subject: bug#67930: 29.1; emacs 29.1 follows symlinks when a grep result is selected
Date: Thu, 4 Jan 2024 11:10:56 +0000

> -----Original Message-----
> From: Eli Zaretskii <eliz@gnu.org>
> Sent: Saturday, December 23, 2023 12:11 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
>
> > 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.

Hi,

Please find attached an updated patch which addresses your remarks.

All the best,
Jurgen
____

This message and any files transmitted with it are legally privileged and 
intended for the sole use of the individual(s) or entity to whom they are 
addressed. If you are not the intended recipient, please notify the sender by 
reply and delete the message and any attachments from your system. Any 
unauthorised use or disclosure of the content of this message is strictly 
prohibited and may be unlawful.

Nothing in this e-mail message amounts to a contractual or legal commitment on 
the part of EUROCONTROL, unless it is confirmed by appropriately signed hard 
copy.

Any views expressed in this message are those of the sender.

Attachment: emacs-29.1_expand_file_names.patch
Description: emacs-29.1_expand_file_names.patch


reply via email to

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