unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* paths are sensative to double separators
@ 2009-03-19  1:50 Mike Mattie
  2009-03-19  2:50 ` xah lee
  2009-03-19  3:09 ` Miles Bader
  0 siblings, 2 replies; 35+ messages in thread
From: Mike Mattie @ 2009-03-19  1:50 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

Hi,

I have noticed that paths in Emacs are sensitive to double separators e.g:

(load /foo/bar/baz.el)  ;; works
(load /foo/bar//baz.el) ;; broken

The same behavior occurs with (find-file).

This doesn't seem like a good thing. Is there a good reason for
it that I am not aware of ?

GNU Emacs 23.0.91.1 (i686-pc-linux-gnu, X toolkit) of 2009-03-07 on localhost

Cheers,
Mike Mattie

-- 
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  1:50 paths are sensative to double separators Mike Mattie
@ 2009-03-19  2:50 ` xah lee
  2009-03-19  5:42   ` Harald Hanche-Olsen
                     ` (2 more replies)
  2009-03-19  3:09 ` Miles Bader
  1 sibling, 3 replies; 35+ messages in thread
From: xah lee @ 2009-03-19  2:50 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 793 bytes --]

in unix-like OSes, double slash is effectively taken to mean root.
e.g. /foo/bar//baz.el would mean /baz.el
This convention is somewhat rooted in unixes.

 Xah

On Wed, Mar 18, 2009 at 6:50 PM, Mike Mattie <codermattie@gmail.com> wrote:

> Hi,
>
> I have noticed that paths in Emacs are sensitive to double separators e.g:
>
> (load /foo/bar/baz.el)  ;; works
> (load /foo/bar//baz.el) ;; broken
>
> The same behavior occurs with (find-file).
>
> This doesn't seem like a good thing. Is there a good reason for
> it that I am not aware of ?
>
> GNU Emacs 23.0.91.1 (i686-pc-linux-gnu, X toolkit) of 2009-03-07 on
> localhost
>
> Cheers,
> Mike Mattie
>
> --
> GnuPG Key: B9012279 is available from HKP server pgp.mit.edu
>



-- 
 Xah
∑ http://xahlee.org/

[-- Attachment #2: Type: text/html, Size: 1265 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  1:50 paths are sensative to double separators Mike Mattie
  2009-03-19  2:50 ` xah lee
@ 2009-03-19  3:09 ` Miles Bader
  2009-03-19 10:26   ` Sebastian Rose
  2009-03-19 13:33   ` Stefan Monnier
  1 sibling, 2 replies; 35+ messages in thread
From: Miles Bader @ 2009-03-19  3:09 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs-devel

Mike Mattie <codermattie@gmail.com> writes:
> I have noticed that paths in Emacs are sensitive to double separators e.g:
>
> (load /foo/bar/baz.el)  ;; works
> (load /foo/bar//baz.el) ;; broken
>
> The same behavior occurs with (find-file).
>
> This doesn't seem like a good thing. Is there a good reason for
> it that I am not aware of ?

It's a feature, as it makes filename entry more convenient, as you can
enter absolute filenames without erasing the existing path when entering
a filename.

Perhaps if Emacs were designed today, it might not do this pervasively,
and instead might just restrict this behavior to the filename prompting
functions (see, e.g. file-name-shadow-mode).

However, the current behavior has not been a problem in practice, as far
as I'm aware; the only place doubled slashes seem common is at the
beginning of a filename (because of naive DIR "/" REL_NAME concatention,
 with DIR == "/") , in which case the emacs behavior causes no change.

-Miles

-- 
Fast, small, soon; pick any 2.




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  2:50 ` xah lee
@ 2009-03-19  5:42   ` Harald Hanche-Olsen
  2009-03-19  6:54     ` Miles Bader
                       ` (3 more replies)
  2009-03-19  9:48   ` Sebastian Rose
  2009-03-19 11:16   ` Giorgos Keramidas
  2 siblings, 4 replies; 35+ messages in thread
From: Harald Hanche-Olsen @ 2009-03-19  5:42 UTC (permalink / raw)
  To: emacs-devel

+ xah lee <xahlee@gmail.com>:

> in unix-like OSes, double slash is effectively taken to mean root.
> e.g. /foo/bar//baz.el would mean /baz.el
> This convention is somewhat rooted in unixes.

Actually, I believe posix says the exact opposite: Multiple slashes
are equivalent to a single slash, except at the head of the path,
where a double slash may have a different meaning. (On the Apollo
machines of old, running domain/os, a leading double slash indicated
the "network root", so you could specify //hostname/foo/bar to get
/foo/bar on the host named hostname. It seems they took the Sun slogan
"the network is the computer" to its logical conclusion.)

Miles Bader gave a different explanation for emacs's behaviour. It
seems odd to me that an interactive feature (a good one, too) should
influence how path names are interpreted in code, however.

- Harald

PS. On those old Apollos, we changed root's home directory from / to
/. in order to avoid being surprised by programs that constructed
paths as $HOME/foo/bar.




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  5:42   ` Harald Hanche-Olsen
@ 2009-03-19  6:54     ` Miles Bader
  2009-03-19 16:33     ` David De La Harpe Golden
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 35+ messages in thread
From: Miles Bader @ 2009-03-19  6:54 UTC (permalink / raw)
  To: Harald Hanche-Olsen; +Cc: emacs-devel

Harald Hanche-Olsen <hanche@math.ntnu.no> writes:
> Miles Bader gave a different explanation for emacs's behaviour. It
> seems odd to me that an interactive feature (a good one, too) should
> influence how path names are interpreted in code, however.

I agree with you, but I'm not sure that it's reasonable to change it
now, given how long Emacs has behaved this way...

-Miles

-- 
x
y
Z!




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  2:50 ` xah lee
  2009-03-19  5:42   ` Harald Hanche-Olsen
@ 2009-03-19  9:48   ` Sebastian Rose
  2009-03-19 11:16   ` Giorgos Keramidas
  2 siblings, 0 replies; 35+ messages in thread
From: Sebastian Rose @ 2009-03-19  9:48 UTC (permalink / raw)
  To: xah; +Cc: Mike Mattie, emacs-devel

xah lee <xahlee@gmail.com> writes:
> in unix-like OSes, double slash is effectively taken to mean root.
> e.g. /foo/bar//baz.el would mean /baz.el
> This convention is somewhat rooted in unixes.


ls /usr//bin



-- 
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http:  www.emma-stil.de




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  3:09 ` Miles Bader
@ 2009-03-19 10:26   ` Sebastian Rose
  2009-03-19 15:46     ` Miles Bader
  2009-03-19 20:32     ` Stefan Monnier
  2009-03-19 13:33   ` Stefan Monnier
  1 sibling, 2 replies; 35+ messages in thread
From: Sebastian Rose @ 2009-03-19 10:26 UTC (permalink / raw)
  To: Miles Bader; +Cc: Mike Mattie, emacs-devel

Miles Bader <miles@gnu.org> writes:
> Mike Mattie <codermattie@gmail.com> writes:
>> I have noticed that paths in Emacs are sensitive to double separators e.g:
>>
>> (load /foo/bar/baz.el)  ;; works
>> (load /foo/bar//baz.el) ;; broken
>>
>> The same behavior occurs with (find-file).
>>
>> This doesn't seem like a good thing. Is there a good reason for
>> it that I am not aware of ?
>
> It's a feature, as it makes filename entry more convenient, as you can
> enter absolute filenames without erasing the existing path when entering
> a filename.


Maybe stick with the current behaviuor of the filename prompting
functions (convenience), but instead of greying out the `/home/' part,
remove it from the prompt?



As for the rest, I feel it's sick to stick with behaviours different
from all the rest of OSs and applications around.

While I would have agreed to weeks ago, that this never was an issue, I
now changed my mind completely. It's the first time I collided with this
issue when working on org-protocol.el. There are some odd differences
between find-file versus server-visit-files, find-file versus `ls',
emacs versus posix, emacs versus other applications in general.

Could someone please enlighten me why to stick with this? It's soo
non-standard:



Case 1:

     sh$ ls /home/sebastian//xy.txt
     sh$ gedit /home/sebastian//xy.txt

  versus

     C-x C-f /home//sebastian//xy.txt

  (OK, convenience, agreed, adjust it a little and it's fine.)



Case 2:

     sh$ emacsclient file:///home/sebastian/xy.txt

   versus

     C-x C-f file:///home/sebastian/xy.txt


   What we get in server-visit-files is this:

     `/home/sebastian/file:/home/sebastian/xy.txt'

   Completely odd, isn't it?
   The `/home/sebastian/' part of it is completly weired and just
   guessing.


   Please compare:

     sh$ gedit file:///home/sebastian/xy.txt
     sh$ mozilla file:///home/sebastian/xy.txt
     ... nautilus and _all_ the others but some GNU tools (ls...)

   Clearly an URL is reuested here, and the scheme is "file". But
   URL-schemes are completely ignored when it comes to emacsclient (and
   other GNU tools like `ls').


Resolving URL schemes would solve many problems (think of the scheme "c"
in "c:/autoexec.bat") and make emacs more usable (emacsclient "ftp://...").



Regards,

   Sebastian


--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http:  www.emma-stil.de




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  2:50 ` xah lee
  2009-03-19  5:42   ` Harald Hanche-Olsen
  2009-03-19  9:48   ` Sebastian Rose
@ 2009-03-19 11:16   ` Giorgos Keramidas
  2009-03-19 14:20     ` Stephen J. Turnbull
                       ` (2 more replies)
  2 siblings, 3 replies; 35+ messages in thread
From: Giorgos Keramidas @ 2009-03-19 11:16 UTC (permalink / raw)
  To: xah; +Cc: Mike Mattie, emacs-devel

On Wed, 18 Mar 2009 19:50:37 -0700, xah lee <xahlee@gmail.com> wrote:
> in unix-like OSes, double slash is effectively taken to mean root.
> e.g. /foo/bar//baz.el would mean /baz.el
> This convention is somewhat rooted in unixes.

Not really, no:

  keramida@kobe:/home/keramida$ cd /etc//security
  keramida@kobe:/etc/security$ pwd
  /etc/security

Having said that, I see that a double slash in find-file's prompt starts
over from the filesystem root.  That's slightly annoying when trying to
open a filename with double slashes, but it's also helpful when one
really *wants* to start over from the root of the filesystem :/





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  3:09 ` Miles Bader
  2009-03-19 10:26   ` Sebastian Rose
@ 2009-03-19 13:33   ` Stefan Monnier
  2009-03-19 17:50     ` Mike Mattie
  1 sibling, 1 reply; 35+ messages in thread
From: Stefan Monnier @ 2009-03-19 13:33 UTC (permalink / raw)
  To: Miles Bader; +Cc: Mike Mattie, emacs-devel

> It's a feature, as it makes filename entry more convenient, as you can
> enter absolute filenames without erasing the existing path when entering
> a filename.

Yes, it's a feature in find-file (actually in the underlying
`read-file-name' function).  It's normally only used for interactive
filename entry, with one historical exception: `load'.
It's implemented by `substitute-in-file-name' which additionally does
expansion of envvars, so (load "$FOOBAR/lisp/toto.el") also works.

This `load' exception is undesirable, but at this point, it's not clear
whether it's best to fix it or to preserve compatibility.


        Stefan




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 11:16   ` Giorgos Keramidas
@ 2009-03-19 14:20     ` Stephen J. Turnbull
  2009-03-19 15:33       ` Giorgos Keramidas
  2009-03-19 15:47     ` Stefan Monnier
  2009-03-19 23:59     ` Byung-Hee HWANG
  2 siblings, 1 reply; 35+ messages in thread
From: Stephen J. Turnbull @ 2009-03-19 14:20 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: xah, Mike Mattie, emacs-devel

Giorgos Keramidas writes:

 > Having said that, I see that a double slash in find-file's prompt starts
 > over from the filesystem root.  That's slightly annoying when trying to
 > open a filename with double slashes,

Which is rather uncommon and has an obvious, Emacs-wide solution: C-q /.

 > but it's also helpful when one really *wants* to start over from
 > the root of the filesystem :/

Which is much more common and deserves a one-keystroke solution.




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 14:20     ` Stephen J. Turnbull
@ 2009-03-19 15:33       ` Giorgos Keramidas
  2009-03-20  5:48         ` Stephen J. Turnbull
  0 siblings, 1 reply; 35+ messages in thread
From: Giorgos Keramidas @ 2009-03-19 15:33 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: xah, Mike Mattie, emacs-devel

On Thu, 19 Mar 2009 23:20:04 +0900, "Stephen J. Turnbull" <stephen@xemacs.org> wrote:
>Giorgos Keramidas writes:
>> Having said that, I see that a double slash in find-file's prompt starts
>> over from the filesystem root.  That's slightly annoying when trying to
>> open a filename with double slashes,
>
> Which is rather uncommon and has an obvious, Emacs-wide solution: C-q /.

Unfortunately, quoting either slash of the double slash parts in
something like `C-x C-f /etc//foo' still restarts the search from the
filesystem root here, in GNU Emacs 23.0.91.1 (i386-unknown-freebsd8.0,
GTK+ Version 2.14.7) of 2009-03-14.

I think if `C-x C-f /etc/ C-q / foo' really passed "/etc//foo" as the
file path name to the find-file function, it might be a nice change that
doesn't feel too surprising to someone who relies on the current behavior.

>> but it's also helpful when one really *wants* to start over from
>> the root of the filesystem :/
>
> Which is much more common and deserves a one-keystroke solution.

Certainly :)





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 10:26   ` Sebastian Rose
@ 2009-03-19 15:46     ` Miles Bader
  2009-03-19 20:32     ` Stefan Monnier
  1 sibling, 0 replies; 35+ messages in thread
From: Miles Bader @ 2009-03-19 15:46 UTC (permalink / raw)
  To: emacs-devel

Sebastian Rose <sebastian_rose@gmx.de> writes:
>> It's a feature, as it makes filename entry more convenient, as you can
>> enter absolute filenames without erasing the existing path when entering
>> a filename.
>
> Maybe stick with the current behaviuor of the filename prompting
> functions (convenience), but instead of greying out the `/home/' part,
> remove it from the prompt?

You can customize it to your liking; see the variable
`file-name-shadow-properties'.

-Miles

-- 
Bore, n. A person who talks when you wish him to listen.





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 11:16   ` Giorgos Keramidas
  2009-03-19 14:20     ` Stephen J. Turnbull
@ 2009-03-19 15:47     ` Stefan Monnier
  2009-03-19 19:08       ` Giorgos Keramidas
  2009-03-19 23:59     ` Byung-Hee HWANG
  2 siblings, 1 reply; 35+ messages in thread
From: Stefan Monnier @ 2009-03-19 15:47 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: xah, Mike Mattie, emacs-devel

> Having said that, I see that a double slash in find-file's prompt starts
> over from the filesystem root.  That's slightly annoying when trying to
> open a filename with double slashes, but it's also helpful when one
> really *wants* to start over from the root of the filesystem :/

In normal Unix file systems, there cannot be a "filename with double
slashes".  Emacs is already careful to preserve double slashes in the
few known cases where they can appear (mostly in
"//<share>/<filename>"), so if you find more such cases, please report
them here so we can try and teach Emacs about them.


        Stefan




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  5:42   ` Harald Hanche-Olsen
  2009-03-19  6:54     ` Miles Bader
@ 2009-03-19 16:33     ` David De La Harpe Golden
  2009-03-19 19:37     ` Richard M Stallman
  2009-03-20  0:38     ` xah lee
  3 siblings, 0 replies; 35+ messages in thread
From: David De La Harpe Golden @ 2009-03-19 16:33 UTC (permalink / raw)
  To: Harald Hanche-Olsen; +Cc: emacs-devel

Harald Hanche-Olsen wrote:


> 
> Actually, I believe posix says the exact opposite: Multiple slashes
> are equivalent to a single slash, except at the head of the path,
> where a double slash may have a different meaning. 


> (On the Apollo
> machines of old, running domain/os, a leading double slash indicated
> the "network root",



On ammig // is also meaningful, not just leading in leading positions, 
as the amiga "parent directory" syntax.

i.e.
unix
foo/bar/../baz

amiga

foo/bar//baz



Emacs used to have an amiga port, but not sure whether it used 
ixemul.library  (analogous to cygwin) or was native. In the latter case, 
it would have mattered.




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 13:33   ` Stefan Monnier
@ 2009-03-19 17:50     ` Mike Mattie
  2009-03-19 20:34       ` Stefan Monnier
  0 siblings, 1 reply; 35+ messages in thread
From: Mike Mattie @ 2009-03-19 17:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Miles Bader

[-- Attachment #1: Type: text/plain, Size: 1499 bytes --]

On Thu, Mar 19, 2009 at 09:33:56AM -0400, Stefan Monnier wrote:
> > It's a feature, as it makes filename entry more convenient, as you can
> > enter absolute filenames without erasing the existing path when entering
> > a filename.
> 
> Yes, it's a feature in find-file (actually in the underlying
> `read-file-name' function).  It's normally only used for interactive
> filename entry, with one historical exception: `load'.
> It's implemented by `substitute-in-file-name' which additionally does
> expansion of envvars, so (load "$FOOBAR/lisp/toto.el") also works.
> 
> This `load' exception is undesirable, but at this point, it's not clear
> whether it's best to fix it or to preserve compatibility.

I can certianly understand when find-file has interesting behavior, in
fact I expect that sort of thing from Emacs. Especially from the "Emacs still
runs on my steam powered dinosaur" angle.

the 'load' case is what spurred me to bring up the issue. I cannot
be sure that some path set by the user contains a trailing '/',
and so I need to append one.

I can, and do now check for this:

(replace-regexp-in-string "/+" "/" path)

but having to gaurd every path is simply begging for errors.
When the beta period is over I would like to revisit the
issue with a patch.

Thank you for expanding on my question so thoroughly,
it was educational.

Cheers,
Mike Mattie


> 
>         Stefan

-- 
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 15:47     ` Stefan Monnier
@ 2009-03-19 19:08       ` Giorgos Keramidas
  0 siblings, 0 replies; 35+ messages in thread
From: Giorgos Keramidas @ 2009-03-19 19:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: xah, Mike Mattie, emacs-devel

On Thu, 19 Mar 2009 11:47:26 -0400, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> Having said that, I see that a double slash in find-file's prompt starts
>> over from the filesystem root.  That's slightly annoying when trying to
>> open a filename with double slashes, but it's also helpful when one
>> really *wants* to start over from the root of the filesystem :/
>
> In normal Unix file systems, there cannot be a "filename with double
> slashes".  Emacs is already careful to preserve double slashes in the
> few known cases where they can appear (mostly in
> "//<share>/<filename>"), so if you find more such cases, please report
> them here so we can try and teach Emacs about them.

I will, thanks :)





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  5:42   ` Harald Hanche-Olsen
  2009-03-19  6:54     ` Miles Bader
  2009-03-19 16:33     ` David De La Harpe Golden
@ 2009-03-19 19:37     ` Richard M Stallman
  2009-03-20  0:38     ` xah lee
  3 siblings, 0 replies; 35+ messages in thread
From: Richard M Stallman @ 2009-03-19 19:37 UTC (permalink / raw)
  To: Harald Hanche-Olsen; +Cc: emacs-devel

    Miles Bader gave a different explanation for emacs's behaviour. It
    seems odd to me that an interactive feature (a good one, too) should
    influence how path names are interpreted in code, however.

This conversion concerns entering file names in the minibuffer,
and does not occur in most functions when they are called from Lisp code.

In particular, I find that find-file called from Lisp converts //
equivalent to one /.  However, strangely there is a difference between
(find-file "~/xmail/stallman.xmail") and (find-file "~/xmail//stallman.xmail").
The former asks me whether to convert the Babyl file to mbox.
The latter just visits the Babyl file in Rmail without conversion.
This seems to be a bug.




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 10:26   ` Sebastian Rose
  2009-03-19 15:46     ` Miles Bader
@ 2009-03-19 20:32     ` Stefan Monnier
  2009-03-19 21:18       ` Sebastian Rose
  1 sibling, 1 reply; 35+ messages in thread
From: Stefan Monnier @ 2009-03-19 20:32 UTC (permalink / raw)
  To: Sebastian Rose; +Cc: Mike Mattie, emacs-devel, Miles Bader

>    What we get in server-visit-files is this:
>      `/home/sebastian/file:/home/sebastian/xy.txt'

This bug was fixed a few days ago.  Of course, to really work, you need
to (url-handler-mode 1) in order to tell Emacs that it should try and
understand URLs.


        Stefan





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 17:50     ` Mike Mattie
@ 2009-03-19 20:34       ` Stefan Monnier
  2009-03-19 21:32         ` Mike Mattie
  0 siblings, 1 reply; 35+ messages in thread
From: Stefan Monnier @ 2009-03-19 20:34 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs-devel, Miles Bader

> the 'load' case is what spurred me to bring up the issue.  I cannot
> be sure that some path set by the user contains a trailing '/',
> and so I need to append one.

My crystal ball tells me you shouldn't worry about such details and use
higher-level functions such as expand-file-name.


        Stefan




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 20:32     ` Stefan Monnier
@ 2009-03-19 21:18       ` Sebastian Rose
  0 siblings, 0 replies; 35+ messages in thread
From: Sebastian Rose @ 2009-03-19 21:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Mike Mattie, Miles Bader, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>    What we get in server-visit-files is this:
>>      `/home/sebastian/file:/home/sebastian/xy.txt'
>
> This bug was fixed a few days ago.  Of course, to really work, you need
> to (url-handler-mode 1) in order to tell Emacs that it should try and
> understand URLs.

I learn something every day I read here :-)


Thanks,

  Sebastian




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
@ 2009-03-19 21:25 Xavier Maillard
  0 siblings, 0 replies; 35+ messages in thread
From: Xavier Maillard @ 2009-03-19 21:25 UTC (permalink / raw)
  To: Miles Bader; +Cc: hanche, emacs-devel


   Harald Hanche-Olsen <hanche@math.ntnu.no> writes:
   > Miles Bader gave a different explanation for emacs's behaviour. It
   > seems odd to me that an interactive feature (a good one, too) should
   > influence how path names are interpreted in code, however.

   I agree with you, but I'm not sure that it's reasonable to change it
   now, given how long Emacs has behaved this way...

I agree with Miles here although the "posix way" should be also
supported (at the user discretion -i.e. via a defcustom).

	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 20:34       ` Stefan Monnier
@ 2009-03-19 21:32         ` Mike Mattie
  0 siblings, 0 replies; 35+ messages in thread
From: Mike Mattie @ 2009-03-19 21:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

On Thu, Mar 19, 2009 at 04:34:26PM -0400, Stefan Monnier wrote:
> > the 'load' case is what spurred me to bring up the issue.  I cannot
> > be sure that some path set by the user contains a trailing '/',
> > and so I need to append one.
> 
> My crystal ball tells me you shouldn't worry about such details and use
> higher-level functions such as expand-file-name.
> 
> 
>         Stefan

Thank you for the suggestion. Finding the equivalant distributed Emacs functions
for my home-brew defuns is a perrenial quest.


-- 
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 11:16   ` Giorgos Keramidas
  2009-03-19 14:20     ` Stephen J. Turnbull
  2009-03-19 15:47     ` Stefan Monnier
@ 2009-03-19 23:59     ` Byung-Hee HWANG
  2 siblings, 0 replies; 35+ messages in thread
From: Byung-Hee HWANG @ 2009-03-19 23:59 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: xah, Mike Mattie, emacs-devel

Giorgos Keramidas <keramida@ceid.upatras.gr> writes:

> On Wed, 18 Mar 2009 19:50:37 -0700, xah lee <xahlee@gmail.com> wrote:
>> in unix-like OSes, double slash is effectively taken to mean root.
>> e.g. /foo/bar//baz.el would mean /baz.el
>> This convention is somewhat rooted in unixes.
>
> Not really, no:
>
>   keramida@kobe:/home/keramida$ cd /etc//security
>   keramida@kobe:/etc/security$ pwd
>   /etc/security

SunOS's screenshot:

$ uname -a
SunOS rose0 5.9 Generic_122300-13 sun4u sparc SUNW,Sun-Fire-880
$ pwd
/user2/hak/z9618029
$ cd /etc//security
$ pwd
/etc/security
$

> Having said that, I see that a double slash in find-file's prompt starts
> over from the filesystem root.  That's slightly annoying when trying to
> open a filename with double slashes, but it's also helpful when one
> really *wants* to start over from the root of the filesystem :/

Sincerely,

-- 
Byung-Hee HWANG, KNU 
∑ WWW: http://izb.knu.ac.kr/~bh/




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19  5:42   ` Harald Hanche-Olsen
                       ` (2 preceding siblings ...)
  2009-03-19 19:37     ` Richard M Stallman
@ 2009-03-20  0:38     ` xah lee
  3 siblings, 0 replies; 35+ messages in thread
From: xah lee @ 2009-03-20  0:38 UTC (permalink / raw)
  To: Harald Hanche-Olsen; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

Thanks all for the correction.
 Xah

On Wed, Mar 18, 2009 at 10:42 PM, Harald Hanche-Olsen
<hanche@math.ntnu.no>wrote:

> + xah lee <xahlee@gmail.com>:
>
> > in unix-like OSes, double slash is effectively taken to mean root.
> > e.g. /foo/bar//baz.el would mean /baz.el
> > This convention is somewhat rooted in unixes.
>
> Actually, I believe posix says the exact opposite: Multiple slashes
> are equivalent to a single slash, except at the head of the path,
> where a double slash may have a different meaning. (On the Apollo
> machines of old, running domain/os, a leading double slash indicated
> the "network root", so you could specify //hostname/foo/bar to get
> /foo/bar on the host named hostname. It seems they took the Sun slogan
> "the network is the computer" to its logical conclusion.)
>
> Miles Bader gave a different explanation for emacs's behaviour. It
> seems odd to me that an interactive feature (a good one, too) should
> influence how path names are interpreted in code, however.
>
> - Harald
>
> PS. On those old Apollos, we changed root's home directory from / to
> /. in order to avoid being surprised by programs that constructed
> paths as $HOME/foo/bar.
>

[-- Attachment #2: Type: text/html, Size: 1650 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-19 15:33       ` Giorgos Keramidas
@ 2009-03-20  5:48         ` Stephen J. Turnbull
  2009-03-20 12:57           ` Stefan Monnier
  0 siblings, 1 reply; 35+ messages in thread
From: Stephen J. Turnbull @ 2009-03-20  5:48 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: xah, Mike Mattie, emacs-devel

Giorgos Keramidas writes:

 > > Which is rather uncommon and has an obvious, Emacs-wide solution: C-q /.
 > 
 > Unfortunately, quoting either slash of the double slash parts in
 > something like `C-x C-f /etc//foo' still restarts the search from the
 > filesystem root here

To me quoting the first slash would be a no-op, but quoting the second
slash should work.  But it does the same thing you observe in 22.1.1
here.  So I guess that's intentional.

I think it's astonishing that Emacs overrides the user's explicit
intent, and it should be changed.

 > I think if `C-x C-f /etc/ C-q / foo' really passed "/etc//foo" as
 > the file path name to the find-file function, it might be a nice
 > change that doesn't feel too surprising to someone who relies on
 > the current behavior.

I can't imagine anyone relies on having Emacs deliberately disobey
"/foo/" C-q "/" and convert it to "/".

Hm, interesting.  In the minibuffer, XEmacs takes C-q at its word, but
find-file (and completion) indeed converts "/foo/bar//" to "/".  This
is really ugly IMO.  I wonder what it takes to fix.  Interestingly,
"/etc/./foo" and "/etc/bar/../foo" work as expected, but both XEmacs
and Emacs 22.1.1 canonicalize the path to "/etc/foo".

N.B.  This matters if you want to use URLs, because not only do you
need the colon-double-slash to define the authority (which could be
special-cased in the function that canonicalizes paths, I guess), but
the RFCs don't define the semantics of double slash (and the Mercurial
URL hg://foo/bar means something different from hg://foo//bar).





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20  5:48         ` Stephen J. Turnbull
@ 2009-03-20 12:57           ` Stefan Monnier
  2009-03-20 14:55             ` Stephen J. Turnbull
  2009-03-20 15:01             ` Eli Zaretskii
  0 siblings, 2 replies; 35+ messages in thread
From: Stefan Monnier @ 2009-03-20 12:57 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: Giorgos Keramidas, xah, emacs-devel, Mike Mattie

> I can't imagine anyone relies on having Emacs deliberately disobey
> "/foo/" C-q "/" and convert it to "/".

C-q / doesn't say "mark this slash as a special slash that shouldn't
be magical.  It only says "don't use the command bound to slash, but
instead just insert a slash char".

The "/foo// -> /" conversion is done much later (as can be seen since
hitting DEL after having hit / gets you back to /foo/).

> N.B.  This matters if you want to use URLs, because not only do you

find-file does not work for URLs unless you enable url-handler-mode.
If you enable url-handler-mode, then "file:///foo" will not be converted
to "/foo".  I.e. I think it works correctly, including for URLs.


        Stefan





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 12:57           ` Stefan Monnier
@ 2009-03-20 14:55             ` Stephen J. Turnbull
  2009-03-20 20:19               ` Stefan Monnier
  2009-03-20 15:01             ` Eli Zaretskii
  1 sibling, 1 reply; 35+ messages in thread
From: Stephen J. Turnbull @ 2009-03-20 14:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Giorgos Keramidas, xah, Mike Mattie, emacs-devel

Stefan Monnier writes:

 > > I can't imagine anyone relies on having Emacs deliberately disobey
 > > "/foo/" C-q "/" and convert it to "/".
 > 
 > C-q / doesn't say "mark this slash as a special slash that shouldn't
 > be magical.  It only says "don't use the command bound to slash, but
 > instead just insert a slash char".

My opinion is that slashes should not be magical at all, except as
electric key strokes in UI.  If the facility were implemented that
way, I would automatically get the behavior I prefer (and at least
some others seem to agree).

 > > N.B.  This matters if you want to use URLs, because not only do you
 > 
 > find-file does not work for URLs unless you enable url-handler-mode.
 > If you enable url-handler-mode, then "file:///foo" will not be converted
 > to "/foo".  I.e. I think it works correctly, including for URLs.

The question I asked is, will "hg://authority//foo" be converted to
"hg://authority/foo"?  Url-handler-mode is clearly broken in 22.1.1.
It doesn't understand the hg: scheme, so after enabling url handler
mode, C-x C-f C-a C-k "hg://" ==> "/" in the minibuffer, and even
worse, C-x C-f C-a C-k "file:///Users/steve//.zshrc" RET ==> wrong
type argument: stringp, nil.  I hope/assume this works better in 23,
but maybe you should check.





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 12:57           ` Stefan Monnier
  2009-03-20 14:55             ` Stephen J. Turnbull
@ 2009-03-20 15:01             ` Eli Zaretskii
  2009-03-20 20:14               ` Stefan Monnier
  1 sibling, 1 reply; 35+ messages in thread
From: Eli Zaretskii @ 2009-03-20 15:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: keramida, xah, stephen, codermattie, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Fri, 20 Mar 2009 08:57:45 -0400
> Cc: Giorgos Keramidas <keramida@ceid.upatras.gr>, xah@xahlee.org,
> 	emacs-devel@gnu.org, Mike Mattie <codermattie@gmail.com>
> 
> > I can't imagine anyone relies on having Emacs deliberately disobey
> > "/foo/" C-q "/" and convert it to "/".
> 
> C-q / doesn't say "mark this slash as a special slash that shouldn't
> be magical.  It only says "don't use the command bound to slash, but
> instead just insert a slash char".

Right.  If one wants to quote a file name, start it with a "/:"; see
the node "Quoted File Names" in the Emacs manual.  I don't think that
it will defeat the "//" case, but I have no system to check that
myself.




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 15:01             ` Eli Zaretskii
@ 2009-03-20 20:14               ` Stefan Monnier
  0 siblings, 0 replies; 35+ messages in thread
From: Stefan Monnier @ 2009-03-20 20:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: keramida, xah, stephen, codermattie, emacs-devel

>> > I can't imagine anyone relies on having Emacs deliberately disobey
>> > "/foo/" C-q "/" and convert it to "/".
>> 
>> C-q / doesn't say "mark this slash as a special slash that shouldn't
>> be magical.  It only says "don't use the command bound to slash, but
>> instead just insert a slash char".

> Right.  If one wants to quote a file name, start it with a "/:"; see
> the node "Quoted File Names" in the Emacs manual.  I don't think that
> it will defeat the "//" case,

Depends what you mean by "defeat".  E.g. C-x C-f /:/foo///bar RET
will open /foo/bar.


        Stefan




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 14:55             ` Stephen J. Turnbull
@ 2009-03-20 20:19               ` Stefan Monnier
  2009-03-20 21:24                 ` Giorgos Keramidas
  0 siblings, 1 reply; 35+ messages in thread
From: Stefan Monnier @ 2009-03-20 20:19 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: Giorgos Keramidas, xah, Mike Mattie, emacs-devel

> The question I asked is, will "hg://authority//foo" be converted to
> "hg://authority/foo"?

Assuming that the URL library is extended to understand the `hg'
protocol, and that url-handler-mode is modified to provide access to it:
no, such a conversion will not take place.

> Url-handler-mode is clearly broken in 22.1.1.

It's not very reliable in Emacs-23 either, to tell you the truth, which
is why it's not enabled by default.

> It doesn't understand the hg: scheme, so after enabling url handler
> mode, C-x C-f C-a C-k "hg://" ==> "/" in the minibuffer, and even

Indeed, there is no support for the `hg' protocol in the URL library.

> worse, C-x C-f C-a C-k "file:///Users/steve//.zshrc" RET ==> wrong
> type argument: stringp, nil.  I hope/assume this works better in 23,
> but maybe you should check.

Just checked: got the same error (plus a few other odd things along the
way).  Thanks for bringing it up,


        Stefan




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 20:19               ` Stefan Monnier
@ 2009-03-20 21:24                 ` Giorgos Keramidas
  2009-03-20 22:56                   ` Sebastian Rose
  2009-03-21  4:43                   ` Stephen J. Turnbull
  0 siblings, 2 replies; 35+ messages in thread
From: Giorgos Keramidas @ 2009-03-20 21:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: xah, Mike Mattie, Stephen J. Turnbull, emacs-devel

On Fri, 20 Mar 2009 16:19:18 -0400, Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:
>> The question I asked is, will "hg://authority//foo" be converted to
>> "hg://authority/foo"?
>
> Assuming that the URL library is extended to understand the `hg'
> protocol, and that url-handler-mode is modified to provide access to it:
> no, such a conversion will not take place.
>
>> Url-handler-mode is clearly broken in 22.1.1.
>
> It's not very reliable in Emacs-23 either, to tell you the truth, which
> is why it's not enabled by default.
>
>> It doesn't understand the hg: scheme, so after enabling url handler
>> mode, C-x C-f C-a C-k "hg://" ==> "/" in the minibuffer, and even
>
> Indeed, there is no support for the `hg' protocol in the URL library.

The double slash in Mercurial repositories is actually a semi-standard
way of referring to pathnames rooted at the `filesystem root' instead of
the default starting directory for the particular URI authority.

RFC 2396 section 5.2 defines an _example_ scheme of resolving relative
URI based on an application-specific base URI.  Part of that example
scheme states:

   5) If the path component begins with a slash character ("/"), then
      the reference is an absolute-path and we skip to step 7.

Based on an interpretation of this RFC example, Mercurial (and possibly
other systems too) interpret URIs using a scheme that maps:

    ssh://user@host/foo         The file `foo' under the HOME directory
                                of `user'.

    ssh://user@host//foo        The file `foo' at the file system root.

This interpretation of URIs is not specific to `hg://' URIs, so if we do
something that parses this sort of double-slash path in the URL library,
it may be nice if we enable it at least for the first path delimiting
slash after the URI authority for most schemes.  Or at least if we can
make it configurable which schemes support this sort of thing.  A list
of URI schemes that support this sort of path-parsing would be really
nice to have as a customizable option :-)





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 21:24                 ` Giorgos Keramidas
@ 2009-03-20 22:56                   ` Sebastian Rose
  2009-03-21  0:12                     ` Miles Bader
  2009-03-21  4:43                   ` Stephen J. Turnbull
  1 sibling, 1 reply; 35+ messages in thread
From: Sebastian Rose @ 2009-03-20 22:56 UTC (permalink / raw)
  To: Giorgos Keramidas
  Cc: xah, Mike Mattie, Stephen J. Turnbull, Stefan Monnier,
	emacs-devel

Giorgos Keramidas <keramida@ceid.upatras.gr> writes:
>     ssh://user@host//foo        The file `foo' at the file system root.
>
> This interpretation of URIs is not specific to `hg://' URIs, so if we do
> something that parses this sort of double-slash path in the URL library,
> it may be nice if we enable it at least for the first path delimiting
> slash after the URI authority for most schemes.  Or at least if we can
> make it configurable which schemes support this sort of thing.  A list
> of URI schemes that support this sort of path-parsing would be really
> nice to have as a customizable option :-)

+1

Accepting URIs is the standard everywhere.

Far the most applications accept URIs. Either a path is absolute,
relative or an URI. It should be supported by default.

  Sebastian




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 22:56                   ` Sebastian Rose
@ 2009-03-21  0:12                     ` Miles Bader
  0 siblings, 0 replies; 35+ messages in thread
From: Miles Bader @ 2009-03-21  0:12 UTC (permalink / raw)
  To: emacs-devel

Sebastian Rose <sebastian_rose@gmx.de> writes:
> Far the most applications accept URIs.

Er, I suspect that's not actually true...

Many recently written "big momma" apps accept URIs.

The majority of apps, probably not.

-Miles

-- 
Run away!  Run away!





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-20 21:24                 ` Giorgos Keramidas
  2009-03-20 22:56                   ` Sebastian Rose
@ 2009-03-21  4:43                   ` Stephen J. Turnbull
  2009-03-21 16:04                     ` Giorgos Keramidas
  1 sibling, 1 reply; 35+ messages in thread
From: Stephen J. Turnbull @ 2009-03-21  4:43 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: xah, Mike Mattie, Stefan Monnier, emacs-devel

Giorgos Keramidas writes:

 > The double slash in Mercurial repositories is actually a semi-standard
 > way of referring to pathnames rooted at the `filesystem root' instead of
 > the default starting directory for the particular URI authority.

This is (or should be) defined by the scheme.  Emacs should only do
canonicalization when the scheme defines it, or there's clear user
demand for canonicalization in a widely used scheme.

 > RFC 2396

... is obsolete.  Cf. RFC 3986, which probably says the same thing but
I don't have time to check the details.

 > A list of URI schemes that support this sort of path-parsing would
 > be really nice to have as a customizable option :-)

Other way around.  See above.





^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: paths are sensative to double separators
  2009-03-21  4:43                   ` Stephen J. Turnbull
@ 2009-03-21 16:04                     ` Giorgos Keramidas
  0 siblings, 0 replies; 35+ messages in thread
From: Giorgos Keramidas @ 2009-03-21 16:04 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: xah, Mike Mattie, Stefan Monnier, emacs-devel

On Sat, 21 Mar 2009 13:43:41 +0900, "Stephen J. Turnbull" <stephen@xemacs.org> wrote:
> Giorgos Keramidas writes:
>
>  > The double slash in Mercurial repositories is actually a semi-standard
>  > way of referring to pathnames rooted at the `filesystem root' instead of
>  > the default starting directory for the particular URI authority.
>
> This is (or should be) defined by the scheme.  Emacs should only do
> canonicalization when the scheme defines it, or there's clear user
> demand for canonicalization in a widely used scheme.

Yes, that seems to make more sense :)





^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2009-03-21 16:04 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-19  1:50 paths are sensative to double separators Mike Mattie
2009-03-19  2:50 ` xah lee
2009-03-19  5:42   ` Harald Hanche-Olsen
2009-03-19  6:54     ` Miles Bader
2009-03-19 16:33     ` David De La Harpe Golden
2009-03-19 19:37     ` Richard M Stallman
2009-03-20  0:38     ` xah lee
2009-03-19  9:48   ` Sebastian Rose
2009-03-19 11:16   ` Giorgos Keramidas
2009-03-19 14:20     ` Stephen J. Turnbull
2009-03-19 15:33       ` Giorgos Keramidas
2009-03-20  5:48         ` Stephen J. Turnbull
2009-03-20 12:57           ` Stefan Monnier
2009-03-20 14:55             ` Stephen J. Turnbull
2009-03-20 20:19               ` Stefan Monnier
2009-03-20 21:24                 ` Giorgos Keramidas
2009-03-20 22:56                   ` Sebastian Rose
2009-03-21  0:12                     ` Miles Bader
2009-03-21  4:43                   ` Stephen J. Turnbull
2009-03-21 16:04                     ` Giorgos Keramidas
2009-03-20 15:01             ` Eli Zaretskii
2009-03-20 20:14               ` Stefan Monnier
2009-03-19 15:47     ` Stefan Monnier
2009-03-19 19:08       ` Giorgos Keramidas
2009-03-19 23:59     ` Byung-Hee HWANG
2009-03-19  3:09 ` Miles Bader
2009-03-19 10:26   ` Sebastian Rose
2009-03-19 15:46     ` Miles Bader
2009-03-19 20:32     ` Stefan Monnier
2009-03-19 21:18       ` Sebastian Rose
2009-03-19 13:33   ` Stefan Monnier
2009-03-19 17:50     ` Mike Mattie
2009-03-19 20:34       ` Stefan Monnier
2009-03-19 21:32         ` Mike Mattie
  -- strict thread matches above, loose matches on Subject: below --
2009-03-19 21:25 Xavier Maillard

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).