unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13961: 24.3; ffap-url-unwrap-remote fails for remote file URIs
@ 2013-03-14 17:24 Jens Lechtenboerger
  2013-03-14 21:57 ` Michael Albinus
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Lechtenboerger @ 2013-03-14 17:24 UTC (permalink / raw)
  To: 13961

Hi there,

I’d like to access remote file URIs via ffap and ssh, e.g., /bar on
host foo via “file://foo/bar”.  However, the behavior of
ffap-url-unwrap-remote has changed from Emacs 23 to 24.

I’m using:

src/emacs -Q
(ffap-bindings)
(setq ffap-ftp-default-user nil)

In Emacs 23.4, with point in “file://foo/bar”, “C-x C-f” shows
“/foo:/bar” in  
the minibuffer, and RET retrieves the file via ssh, which is good.

In Emacs 24.3, “C-x C-f” shows “file://foo/bar”, and RET opens a
browser, which tries to access “file:///bar”, which is incorrect as
it misses the host.

The file scheme is not recognized as remote one.  Thus:
(setq ffap-url-unwrap-remote '("ftp" "file"))
Now, “C-x C-f” shows “/file:foo:/bar”, and RET leads to the error:
“Host `foo' looks like a remote host, `file' can only use the local host”

I’m not sure whether the previous result should be changed
somewhere.  Why should file only use the local host?

However, the problem can be avoided by the following version of
ffap-url-unwrap-remote.  Moreover, changing ffap-ftp-default-user is
not necessary any more.

(defun ffap-url-unwrap-remote (url)
  "Return URL as a remote file name, or nil."
  (let* ((obj    (url-generic-parse-url url))
	 (scheme (url-type obj))
	 (valid-schemes (if (listp ffap-url-unwrap-remote)
			    ffap-url-unwrap-remote
			  '("ftp")))
	 (host (url-host obj))
	 (port (url-port-if-non-default obj))
	 (user (url-user obj))
	 (filename (car (url-path-and-query obj))))
    (when (and (member scheme valid-schemes)
	       (string-match "\\`[a-zA-Z][-a-zA-Z0-9+.]*\\'" scheme)
	       (not (equal host "")))
      (concat "/"
	      (if (not (string= scheme "file"))
		  (concat scheme ":"))
	      (if user (concat user "@"))
	      host
	      (if port (concat "#" (number-to-string port)))
	      ":" filename))))

Best wishes
Jens





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

* bug#13961: 24.3; ffap-url-unwrap-remote fails for remote file URIs
  2013-03-14 17:24 bug#13961: 24.3; ffap-url-unwrap-remote fails for remote file URIs Jens Lechtenboerger
@ 2013-03-14 21:57 ` Michael Albinus
  2015-12-25 21:09   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Albinus @ 2013-03-14 21:57 UTC (permalink / raw)
  To: Jens Lechtenboerger; +Cc: 13961

Jens Lechtenboerger <lechten@wi.uni-muenster.de> writes:

> Hi there,

Hi Jens,

> I’d like to access remote file URIs via ffap and ssh, e.g., /bar on
> host foo via “file://foo/bar”.  However, the behavior of
> ffap-url-unwrap-remote has changed from Emacs 23 to 24.

Yes. See the NEWS file of Emacs 24.3:

--8<---------------cut here---------------start------------->8---
** The FFAP option `ffap-url-unwrap-remote' can now be a list of strings,
specifying URL types that should be converted to remote file names at
the FFAP prompt.  The default is now '("ftp").
--8<---------------cut here---------------end--------------->8---

> I’m using:
>
> src/emacs -Q
> (ffap-bindings)
> (setq ffap-ftp-default-user nil)
>
> In Emacs 23.4, with point in “file://foo/bar”, “C-x C-f” shows
> “/foo:/bar” in  
> the minibuffer, and RET retrieves the file via ssh, which is good.

In Emacs 23, ffap-url-unwrap-remote had the intention to unwrap to an
ftp file name. It uses the ange-ftp syntax "/host:/remote/path".

Tramp is bundled with Emacs 23, and it uses an extended syntax
"/method:host:/remote/path". The "method:" part is optional; in this
case the default method ("ssh" in your case) will be used.

So it did work for you due to an unintended side effect.

> In Emacs 24.3, “C-x C-f” shows “file://foo/bar”, and RET opens a
> browser, which tries to access “file:///bar”, which is incorrect as
> it misses the host.

ffap-url-unwrap-remote has been changed to handle the scheme part of the
url as Tramp method, when it is known in ffap-url-unwrap-remote. "file"
does not belong to this list by default; therefore the url is regarded
as url, and it is sent to the browser.

> The file scheme is not recognized as remote one.  Thus:
> (setq ffap-url-unwrap-remote '("ftp" "file"))
> Now, “C-x C-f” shows “/file:foo:/bar”, and RET leads to the error:
> “Host `foo' looks like a remote host, `file' can only use the local host”

In this case, you declare "file" as Tramp method. The resulting
"/file:foo:/bar" is not accepted by Tramp; it doesn't know of any method
"file".

> I’m not sure whether the previous result should be changed
> somewhere.  Why should file only use the local host?
>
> However, the problem can be avoided by the following version of
> ffap-url-unwrap-remote.  Moreover, changing ffap-ftp-default-user is
> not necessary any more.
>
> (defun ffap-url-unwrap-remote (url)
>   "Return URL as a remote file name, or nil."
>   (let* ((obj    (url-generic-parse-url url))
> 	 (scheme (url-type obj))
> 	 (valid-schemes (if (listp ffap-url-unwrap-remote)
> 			    ffap-url-unwrap-remote
> 			  '("ftp")))
> 	 (host (url-host obj))
> 	 (port (url-port-if-non-default obj))
> 	 (user (url-user obj))
> 	 (filename (car (url-path-and-query obj))))
>     (when (and (member scheme valid-schemes)
> 	       (string-match "\\`[a-zA-Z][-a-zA-Z0-9+.]*\\'" scheme)
> 	       (not (equal host "")))
>       (concat "/"
> 	      (if (not (string= scheme "file"))
> 		  (concat scheme ":"))
> 	      (if user (concat user "@"))
> 	      host
> 	      (if port (concat "#" (number-to-string port)))
> 	      ":" filename))))

This patch tries to conserve the side effect of ffap in Emacs 23. I'm
not a user of ffap, so I don't know whether it is acceptable to add such
a kludge.

> Best wishes
> Jens

Best regards, Michael.





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

* bug#13961: 24.3; ffap-url-unwrap-remote fails for remote file URIs
  2013-03-14 21:57 ` Michael Albinus
@ 2015-12-25 21:09   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2015-12-25 21:09 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Jens Lechtenboerger, 13961

Michael Albinus <michael.albinus@gmx.de> writes:

> Tramp is bundled with Emacs 23, and it uses an extended syntax
> "/method:host:/remote/path". The "method:" part is optional; in this
> case the default method ("ssh" in your case) will be used.
>
> So it did work for you due to an unintended side effect.

Since this has been working this way for almost three years now, I think
we probably shouldn't change this back now (if I understood this thread
correctly).  So I'm closing the bug report.

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





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

end of thread, other threads:[~2015-12-25 21:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14 17:24 bug#13961: 24.3; ffap-url-unwrap-remote fails for remote file URIs Jens Lechtenboerger
2013-03-14 21:57 ` Michael Albinus
2015-12-25 21:09   ` Lars Ingebrigtsen

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