[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs
From: |
Jens Lechtenboerger |
Subject: |
bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs |
Date: |
Wed, 20 Jul 2011 17:28:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
Dear all,
ffap-url-unwrap-local does not work properly for file URIs. Recipe
starting from `emacs -Q':
M-x ffap-bindings
M-: (ffap-url-unwrap-local "file:///home/foo/bar")
This results in nil, while "/home/foo/bar" would be correct.
The regular expression within ffap-url-unwrap-local is incorrect.
Moreover, I don't understand why and how ffap distinguishes local
from remote URLs. The doc string for variable ffap-url-unwrap-local
talks about "file:" URLs, while the one for ffap-url-unwrap-remote
talks about "ftp:" URLs. Nevertheless, the regular expressions in
both functions, ffap-url-unwrap-local and ffap-url-unwrap-remote,
match both, "file:" and "ftp:"...
The incorrect function is:
(defsubst ffap-url-unwrap-local (url)
"Return URL as a local file, or nil. Ignores `ffap-url-regexp'."
(and (string-match "\\`\\(file\\|ftp\\):/?\\([^/]\\|\\'\\)" url)
(substring url (1+ (match-end 1)))))
I suggest the following:
(defsubst ffap-url-unwrap-local (url)
"Return URL as a local file, or nil. Ignores `ffap-url-regexp'."
(and (not (string-match "^\\(file\\|ftp\\)://[^/]" url))
(string-match "^\\(file\\|ftp\\):\\(//\\)?\\(.*\\)" url)
(match-string 3 url)))
The first condition ("not ...") makes sure that we look at a URI
without authority part, which is my interpretation of "local" URI
(although there are "local" authority parts such as "localhost",
local IP addresses, or DNS names of the local machine).
Thanks for ffap, which I only discovered today ;)
Jens
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs,
Jens Lechtenboerger <=