all messages for Emacs-related lists mirrored at yhetil.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

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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.