* bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs
@ 2011-07-20 15:28 Jens Lechtenboerger
2012-05-10 6:27 ` Chong Yidong
0 siblings, 1 reply; 2+ messages in thread
From: Jens Lechtenboerger @ 2011-07-20 15:28 UTC (permalink / raw)
To: 9131
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs
2011-07-20 15:28 bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs Jens Lechtenboerger
@ 2012-05-10 6:27 ` Chong Yidong
0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2012-05-10 6:27 UTC (permalink / raw)
To: Jens Lechtenboerger; +Cc: 9131
Jens Lechtenboerger <lechten@wi.uni-muenster.de> writes:
> ffap-url-unwrap-local does not work properly for file URIs.
Thanks. I just committed a fix to trunk.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-10 6:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-20 15:28 bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs Jens Lechtenboerger
2012-05-10 6:27 ` Chong Yidong
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.