unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#39349: browse-url-of-dired-file should respect directory symlinks
@ 2020-01-29  8:40 積丹尼 Dan Jacobson
  2020-07-19 19:48 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-01-29  8:40 UTC (permalink / raw)
  To: 39349

browse-url-of-dired-file should respect directory symlinks.
E.g.,
$ emacs -q
C-x d /cf/updates/
SPC SPC SPC
M-x browse-url-of-dired-file
should call the browser on
file:///cf/updates/52.html
not the absolute path
file:///mnt/usb/cf/updates/52.html
Else what is the point of symlinks?
emacs-version "26.3"





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-01-29  8:40 bug#39349: browse-url-of-dired-file should respect directory symlinks 積丹尼 Dan Jacobson
@ 2020-07-19 19:48 ` Lars Ingebrigtsen
  2020-07-20 14:54   ` 積丹尼 Dan Jacobson
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-19 19:48 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 39349

積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:

> browse-url-of-dired-file should respect directory symlinks.
> E.g.,
> $ emacs -q
> C-x d /cf/updates/
> SPC SPC SPC
> M-x browse-url-of-dired-file
> should call the browser on
> file:///cf/updates/52.html
> not the absolute path
> file:///mnt/usb/cf/updates/52.html

So /cf is a symlink in your setup?

The reason for this behaviour is a patch from 2011 which attempted to
make this command work on the "." and ".." directories:

  (let ((tem (dired-get-filename t t)))
    (if tem
	(browse-url-of-file (expand-file-name tem))

So we want to call with (browse-url-of-file "/") instead of
(browse-url-of-file "/tmp/.."), for instance, and use expand-file-name
to achieve that.  However, that function also resolves any symlinks...

This function just needs to do the ../. thing.  Does Emacs have a
function that just does the right thing the ".." and "/" and does
absolutely nothing else?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-19 19:48 ` Lars Ingebrigtsen
@ 2020-07-20 14:54   ` 積丹尼 Dan Jacobson
  2020-07-23 14:05     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-07-20 14:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 39349

>>>>> "LI" == Lars Ingebrigtsen <larsi@gnus.org> writes:
LI> So /cf is a symlink in your setup?

Yup.

LI> This function just needs to do the ../. thing.  Does Emacs have a
LI> function that just does the right thing the ".." and "/" and does
LI> absolutely nothing else?

Not sure.





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-20 14:54   ` 積丹尼 Dan Jacobson
@ 2020-07-23 14:05     ` Lars Ingebrigtsen
  2020-07-23 14:19       ` Andreas Schwab
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-23 14:05 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 39349

積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:

> LI> This function just needs to do the ../. thing.  Does Emacs have a
> LI> function that just does the right thing the ".." and "/" and does
> LI> absolutely nothing else?
>
> Not sure.

I couldn't find one, either.

Eli, the use case here is that we don't want to chase/resolve symlinks,
but we do want to have "/foo/bar/." -> "/foo/bar" and "/foo/bar/.." ->
"/foo".  Do you know whether such a utility function exists, by any
chance?  If not, would it make sense to add such a function?  (For all
other file names, the function would just return the parameter as is.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-23 14:05     ` Lars Ingebrigtsen
@ 2020-07-23 14:19       ` Andreas Schwab
  2020-07-23 14:32         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Andreas Schwab @ 2020-07-23 14:19 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 39349, 積丹尼 Dan Jacobson

On Jul 23 2020, Lars Ingebrigtsen wrote:

> Eli, the use case here is that we don't want to chase/resolve symlinks,
> but we do want to have "/foo/bar/." -> "/foo/bar" and "/foo/bar/.." ->
> "/foo".

Isn't that what expand-file-name does?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-23 14:19       ` Andreas Schwab
@ 2020-07-23 14:32         ` Lars Ingebrigtsen
  2020-07-23 14:33           ` Andreas Schwab
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-23 14:32 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 39349, 積丹尼 Dan Jacobson

Andreas Schwab <schwab@linux-m68k.org> writes:

> On Jul 23 2020, Lars Ingebrigtsen wrote:
>
>> Eli, the use case here is that we don't want to chase/resolve symlinks,
>> but we do want to have "/foo/bar/." -> "/foo/bar" and "/foo/bar/.." ->
>> "/foo".
>
> Isn't that what expand-file-name does?

No, it resolves symlinks:

---
Convert filename NAME to absolute, and canonicalize it.
---

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-23 14:32         ` Lars Ingebrigtsen
@ 2020-07-23 14:33           ` Andreas Schwab
  2020-07-23 14:39             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Andreas Schwab @ 2020-07-23 14:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 39349, 積丹尼 Dan Jacobson

On Jul 23 2020, Lars Ingebrigtsen wrote:

> Andreas Schwab <schwab@linux-m68k.org> writes:
>
>> On Jul 23 2020, Lars Ingebrigtsen wrote:
>>
>>> Eli, the use case here is that we don't want to chase/resolve symlinks,
>>> but we do want to have "/foo/bar/." -> "/foo/bar" and "/foo/bar/.." ->
>>> "/foo".
>>
>> Isn't that what expand-file-name does?
>
> No, it resolves symlinks:

No, that's what file-truename does.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-23 14:33           ` Andreas Schwab
@ 2020-07-23 14:39             ` Lars Ingebrigtsen
  2020-07-30 12:39               ` 積丹尼 Dan Jacobson
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-23 14:39 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 39349, 積丹尼 Dan Jacobson

Andreas Schwab <schwab@linux-m68k.org> writes:

> On Jul 23 2020, Lars Ingebrigtsen wrote:
>
>> Andreas Schwab <schwab@linux-m68k.org> writes:
>>
>>> On Jul 23 2020, Lars Ingebrigtsen wrote:
>>>
>>>> Eli, the use case here is that we don't want to chase/resolve symlinks,
>>>> but we do want to have "/foo/bar/." -> "/foo/bar" and "/foo/bar/.." ->
>>>> "/foo".
>>>
>>> Isn't that what expand-file-name does?
>>
>> No, it resolves symlinks:
>
> No, that's what file-truename does.

Oh, yeah; sorry.  Thanks.

Then...  I don't know what Dan is reporting here.  :-/

I've now set up a proper test case, and I can't reproduce the bug, Dan.
Could you explain more closely what you're seeing and what you're
expecting to see?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-23 14:39             ` Lars Ingebrigtsen
@ 2020-07-30 12:39               ` 積丹尼 Dan Jacobson
  2020-07-31  2:47                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-07-30 12:39 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 39349, Andreas Schwab

LI> Then...  I don't know what Dan is reporting here.  :-/

LI> I've now set up a proper test case, and I can't reproduce the bug, Dan.
LI> Could you explain more closely what you're seeing and what you're
LI> expecting to see?

$ ls -ogd /cf
lrwxrwxrwx 1 11 2016-12-24  /cf -> /mnt/usb/cf
$ ls -ogd /cf/updates
drwxr-xr-x 49 37888 07-30 19:00 /cf/updates
$ ls -ogd /cf/updates/0952053635.html
-rw------- 1 784 2017-12-15  /cf/updates/0952053635.html
$ chromium /cf/updates/0952053635.html        # Browses file:///mnt/usb/cf/updates/0952053635.html as seen in the URL bar
$ chromium file:///cf/updates/0952053635.html # Browses file:///cf/updates/0952053635.html as seen in the URL bar
$ w3m /cf/updates/0952053635.html             # Browses file:///cf/updates/0952053635.html as seen with the "=" command
$ w3m file:///cf/updates/0952053635.html      # Browses file:///cf/updates/0952053635.html as seen with the "=" command

(Firefox acts like chromium.)

$ emacs /cf/updates
then there do browse-url-of-dired-file on 0952053635.html

Well that calls chromium or emacs-w3m on
file:///mnt/usb/cf/updates/0952053635.html
as seen in chromium's URL bar, or emacs-w3m's "c" or "=" commands.

Anyways, I'm saying that the user doesn't want to be made forcibly aware
of the real URL. So browse-url-of-dired-file should probably put a
"file://" in front of what "0 w" (w runs the command dired-copy-filename-as-kill)
returns, when invoking the browser.

0 w (0 dired-copy-filename-as-kill) uses the symlink path reliably.





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-30 12:39               ` 積丹尼 Dan Jacobson
@ 2020-07-31  2:47                 ` Lars Ingebrigtsen
  2020-07-31 11:58                   ` 積丹尼 Dan Jacobson
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-31  2:47 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 39349

積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:

> $ emacs /cf/updates
> then there do browse-url-of-dired-file on 0952053635.html
>
> Well that calls chromium or emacs-w3m on
> file:///mnt/usb/cf/updates/0952053635.html
> as seen in chromium's URL bar, or emacs-w3m's "c" or "=" commands.

I've now tried reproducing this bug in both emacs-26.3 and 28.1, and I'm
unable to.  My setup isn't identical to yours, but I'm also using
symlinks to directories, and the symlinked form is always passed to the
browser as is without dereferencing.

Are you seeing this problem if you start emacs with -Q and just

(setq browse-url-browser-function 'browse-url-chromium)  

?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-31  2:47                 ` Lars Ingebrigtsen
@ 2020-07-31 11:58                   ` 積丹尼 Dan Jacobson
  2020-07-31 12:04                     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-07-31 11:58 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 39349

>>>>> "LI" == Lars Ingebrigtsen <larsi@gnus.org> writes:

LI> Are you seeing this problem if you start emacs with -Q and just

LI> (setq browse-url-browser-function 'browse-url-chromium)  

LI> ?

Indeed, doing that setq makes all the difference.
With identical runs of
$ emacs -nw -Q /cf/updates
apparently without that setq, BROWSER=chromium gets invoked via the
shell or something, causing the guts of the URL to show.





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-31 11:58                   ` 積丹尼 Dan Jacobson
@ 2020-07-31 12:04                     ` Lars Ingebrigtsen
  2020-07-31 16:14                       ` 積丹尼 Dan Jacobson
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-31 12:04 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 39349

積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:

>>>>>> "LI" == Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> LI> Are you seeing this problem if you start emacs with -Q and just
>
> LI> (setq browse-url-browser-function 'browse-url-chromium)  
>
> LI> ?
>
> Indeed, doing that setq makes all the difference.
> With identical runs of
> $ emacs -nw -Q /cf/updates
> apparently without that setq, BROWSER=chromium gets invoked via the
> shell or something, causing the guts of the URL to show.

Ah!  Now I can reproduce it, too, by just not setting
browse-url-browser-function at all.

In my case, that means that 

xdg-open file:///tmp/foo/a.html

but xdg-open then rewrites the URL to chase links before handing it over
to the browser.

*phew*  :-)

But that does mean that this isn't an Emacs bug, so I'm closing this bug
report.  You may want to take up up with whoever is responsible for
xdg-open, perhaps...  Or just set the variable.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#39349: browse-url-of-dired-file should respect directory symlinks
  2020-07-31 12:04                     ` Lars Ingebrigtsen
@ 2020-07-31 16:14                       ` 積丹尼 Dan Jacobson
  0 siblings, 0 replies; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-07-31 16:14 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 39349

OK, filed https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues/176 .





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

end of thread, other threads:[~2020-07-31 16:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-29  8:40 bug#39349: browse-url-of-dired-file should respect directory symlinks 積丹尼 Dan Jacobson
2020-07-19 19:48 ` Lars Ingebrigtsen
2020-07-20 14:54   ` 積丹尼 Dan Jacobson
2020-07-23 14:05     ` Lars Ingebrigtsen
2020-07-23 14:19       ` Andreas Schwab
2020-07-23 14:32         ` Lars Ingebrigtsen
2020-07-23 14:33           ` Andreas Schwab
2020-07-23 14:39             ` Lars Ingebrigtsen
2020-07-30 12:39               ` 積丹尼 Dan Jacobson
2020-07-31  2:47                 ` Lars Ingebrigtsen
2020-07-31 11:58                   ` 積丹尼 Dan Jacobson
2020-07-31 12:04                     ` Lars Ingebrigtsen
2020-07-31 16:14                       ` 積丹尼 Dan Jacobson

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