unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: lekktu@gmail.com, 21816@debbugs.gnu.org, dgutov@yandex.ru
Subject: bug#21816: elisp-mode-tests fails on a case-preserving filesystem
Date: Wed, 04 Nov 2015 04:00:58 -0600	[thread overview]
Message-ID: <86y4eexew5.fsf@stephe-leake.org> (raw)
In-Reply-To: <83d1vqv3af.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 04 Nov 2015 05:42:16 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Stephen Leake <stephen_leake@stephe-leake.org>
>> Cc: dgutov@yandex.ru,  lekktu@gmail.com,  21816@debbugs.gnu.org
>> Date: Tue, 03 Nov 2015 15:58:49 -0600
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >> From: Stephen Leake <stephen_leake@stephe-leake.org>
>> >> Cc: Juanma Barranquero <lekktu@gmail.com>, Eli Zaretskii
>> >> <eliz@gnu.org>, 21816@debbugs.gnu.org
>> >> Date: Tue, 03 Nov 2015 13:54:21 -0600
>> >> 
>> >>    If the file name identifies an existing file, convert the file name
>> >>    casing to match the actual file name casing. If not, no case
>> >>    conversion is done.
>> >
>> > For existing files we have file-equal-p, which is more general.  
>> 
>> You missed the context; we have switched from discussing how to compare
>> file names to how to canonicalize a file name, in order to simplify the
>> comparison.
>
> I'm still trying to convince you that this is a dead end: you cannot
> trust user-extensible code to comply with such requirements, on
> filesystems where "canonicalized file name" is not well defined.

We can provide a `file-canonical-name' that does something useful on all
systems.

I believe the notion of "canonical file name" is well defined for
existing files on all systems we care about; is that not true?

For non-existing files, I don't think there is a real problem in
practice (see other email); can you present a use case where there is?


The file-equal-p option does not fix the problem in xref--analyze, since
that is comparing the result of `xref-location-group', which is yet more
user-extensible code; for xref-elisp-location, that is the file name
slot of the location. Using file-canonical-name in xref-location-group
implemetations would fix this; using it in make-xref-location fixes it
in a more robust and consistent way.


To summarize:

The problem is comparing xrefs directly (for sorting and testing),
comparing the result of xref-location-group (for sorting), and possibly
comparing results of other xref access functions in the future. Note
that any filenames in xrefs identify existing files, except in
artifically constructed tests.

I believe the two alternatives being proposed are:

1) Use `file-equal-p'

- Provide a cl-defgeneric `xref-location-equal-p' for the root
  xref-location type.

- For each type that inherits from xref-location, provide an
  implementation of `xref-location-equal-p' that uses `file-equal-p' for
  each file name.

- Provide a cl-defmethod `xref-equal-p' for the root xref type that uses
  `xref-location-equal-p' for the location.

- For each type that inherits from xref, provide an implementation of
  `xref-equal-p' that uses `xref-location-equal-p' for each location.


2) Use `file-canonical-name'

- A canonical file name has the following features:

  It contains forward slashes for directory separators.

  If the file name identifies an existing file, the canonical file name
  casing matches the actual file name casing. If not, the case of the
  portions of the canonical file name that do not exist is arbitrary.
  Note that this matters only on case-insensitive file systems.

  Two different non-canonical names for an existing file convert to the
  same canonical file name. Note that this means symlinks are resolved.

  Canonical file names may be compared with `string-equal' and
  `string-lessp'.

- Provide a system-dependent `file-canonical-name' that converts
  user-provided file names to a canonical file name.

- Require each variant of make-xref-location to use it for file name
  slots.


Option 1) solves the problem of comparing xrefs and xref-locations, but
does not solve the problem of comparing results of xref-location-group.

Option 2) solves the problems of comparing xrefs, xref-locations,
results of xref-location-group, and results of future xref access
functions.

So far, `file-truename' seems adequate for `file-canonical-name', but it
might be best to define the alias, in case we find problems in the
future.

One problem with canonical file names is that the user can construct two
names for a non-existing file that differ only in case; they are
supposed to convert to the same canonical file name on a
case-insensitive file system, but `file-canonical-name' has no way to
know which might represent an actual file in the future. One solution is
for `file-canonical-name' to downcase the portions of the file name that
do not exist, but that's not very user-friendly (`file-truename' does
not do this). This problem does not seem likely to occur in practice.


Option 2) seems better to me. 

-- 
-- Stephe





  reply	other threads:[~2015-11-04 10:00 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 16:41 bug#21816: elisp-mode-tests fails on a case-preserving filesystem Juanma Barranquero
2015-11-02 17:57 ` Eli Zaretskii
2015-11-02 18:20   ` Juanma Barranquero
2015-11-03  1:19     ` Juanma Barranquero
2015-11-03  3:42       ` Eli Zaretskii
2015-11-03  9:17 ` Stephen Leake
2015-11-03 10:06   ` Juanma Barranquero
2015-11-03 14:51     ` Stephen Leake
2015-11-03 14:58       ` Juanma Barranquero
2015-11-03 19:43         ` Stephen Leake
2015-11-03 22:24           ` Stephen Leake
2015-11-04  8:48           ` Juanma Barranquero
2015-11-09  3:38           ` Dmitry Gutov
2019-10-02  0:57             ` Juanma Barranquero
2015-11-03 15:40       ` Eli Zaretskii
2015-11-03 15:45         ` Juanma Barranquero
2015-11-03 15:52           ` Dmitry Gutov
2015-11-03 16:04             ` Juanma Barranquero
2015-11-03 16:18               ` Dmitry Gutov
2015-11-03 16:33                 ` Juanma Barranquero
2015-11-03 18:12                   ` Dmitry Gutov
2015-11-04  8:40                     ` Juanma Barranquero
2015-11-03 16:34                 ` Eli Zaretskii
2015-11-03 16:42                   ` Juanma Barranquero
2015-11-03 16:53                     ` Eli Zaretskii
2015-11-03 18:13                       ` Dmitry Gutov
2015-11-03 19:54                         ` Random832
2015-11-03 20:03                           ` Dmitry Gutov
2015-11-03 20:25                             ` Random832
2015-11-03 21:25                               ` Dmitry Gutov
2015-11-03 20:51                         ` Eli Zaretskii
2015-11-04  8:19                       ` Juanma Barranquero
2015-11-03 18:18                   ` Dmitry Gutov
2015-11-03 20:56                     ` Eli Zaretskii
2015-11-04  8:53                       ` Juanma Barranquero
2015-11-03 19:50                   ` Random832
2015-11-03 21:02                     ` Eli Zaretskii
2015-11-03 21:17                       ` Random832
2015-11-03 21:22                         ` Eli Zaretskii
2015-11-03 19:54                 ` Stephen Leake
2015-11-03 20:05                   ` Dmitry Gutov
2015-11-03 21:07                     ` Eli Zaretskii
2015-11-03 21:52                     ` Stephen Leake
2015-11-03 22:07                       ` Stephen Leake
2015-11-03 22:18                         ` Dmitry Gutov
2015-11-03 22:20                         ` Stephen Leake
2015-11-04  3:46                         ` Eli Zaretskii
2015-11-04  8:28                           ` Stephen Leake
2015-11-04  5:24                         ` Alexis
2015-11-04  6:33                           ` Random832
2015-11-04  6:52                             ` Alexis
2015-11-04 15:35                               ` Eli Zaretskii
2015-11-04 15:38                             ` Eli Zaretskii
2015-11-04  9:04                           ` Stephen Leake
2015-11-04 10:37                             ` Alexis
2015-11-04 16:08                             ` Eli Zaretskii
2015-11-04 15:34                           ` Eli Zaretskii
2015-11-03 21:05                   ` Eli Zaretskii
2015-11-03 21:58                     ` Stephen Leake
2015-11-04  3:42                       ` Eli Zaretskii
2015-11-04 10:00                         ` Stephen Leake [this message]
2015-11-04 19:14                           ` Stephen Leake
2015-11-03 19:24         ` Stephen Leake
2015-11-03 21:00           ` Eli Zaretskii
2015-11-04 15:29     ` Stephen Leake
2015-11-05 12:26       ` Juanma Barranquero
2015-11-05 13:23         ` Stephen Leake

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=86y4eexew5.fsf@stephe-leake.org \
    --to=stephen_leake@stephe-leake.org \
    --cc=21816@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=lekktu@gmail.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).