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

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

bug#4819: file-truename's undocumented behavior


From: Stefan Monnier
Subject: bug#4819: file-truename's undocumented behavior
Date: Wed, 28 Oct 2009 20:37:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> I assumed nil.

That would be very unexpected, since file-truename otherwise always
returns a string when passed a string.

> However, discarding the state of my "least surprisedness", I would
> _not_ expect that file-truename would step all over the match-data,
> and where it does so not before first:

Most functions don't preserve the match-data, and even more so for
functions that manipulate strings or buffers.

> b) Noting that it does so in the documention. i.e. as per `split-string'.

It's the other way around: the few functions that preserve the
match-data should be documented as such (better yet: the byte-compiler
should be taught about them, so it can detect when we use the
match-data after it got clobbered).

>>> I just spent 2 1/2 hours in a break-loop three functions away trying
>>> to debug _undocumented_ behavior.
>> Which part of the documentation do you think this behavior contradicts?

> This part:
>  (file-name-absolute-p "") ;=> nil
>  (file-symlink-p "")       ;=> nil

That's not a part of the documentation.

> Why not mention in the docs that on w32 `w32-long-file-name' may be
> a more suitable alternative esp. as it is a primitive and as it will
> expand "8.3 DOS" short name aliases in the process. (Again, per
> _existing_ comments in body of `file-truename's definition).

Elisp should generally not be w32-specific, so ratehr than use
w32-long-file-name we should maybe change
file-truename correspondingly.  That doesn't mean I think it's the right
thing to do: I know next to nothing about this issue.

> !         ((and (string= (substring filename 0 1) "~")
> !               (string-match-p "~[^/]*/?" filename))
> !          (string-match "~[^/]*/?" filename)
> !          (let ((first-part
> !                 (substring filename 0 (match-end 0)))
> !                (rest (substring filename (match-end 0))))

What's the point?  If you're going to use string-match in the end, you
might as well do it right away.


        Stefan





reply via email to

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