GNU bug report logs - #9131
23.3; ffap-url-unwrap-local broken for file URIs

Previous Next

Package: emacs;

Reported by: Jens Lechtenboerger <lechten <at> wi.uni-muenster.de>

Date: Wed, 20 Jul 2011 17:05:01 UTC

Severity: normal

Found in version 23.3

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9131 in the body.
You can then email your comments to 9131 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9131; Package emacs. (Wed, 20 Jul 2011 17:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jens Lechtenboerger <lechten <at> wi.uni-muenster.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 20 Jul 2011 17:05:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jens Lechtenboerger <lechten <at> wi.uni-muenster.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.3; ffap-url-unwrap-local broken for file URIs
Date: Wed, 20 Jul 2011 17:28:21 +0200
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9131; Package emacs. (Thu, 10 May 2012 06:31:01 GMT) Full text and rfc822 format available.

Message #8 received at 9131 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Jens Lechtenboerger <lechten <at> wi.uni-muenster.de>
Cc: 9131 <at> debbugs.gnu.org
Subject: Re: bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs
Date: Thu, 10 May 2012 14:27:54 +0800
Jens Lechtenboerger <lechten <at> wi.uni-muenster.de> writes:

> ffap-url-unwrap-local does not work properly for file URIs.

Thanks.  I just committed a fix to trunk.




bug closed, send any further explanations to 9131 <at> debbugs.gnu.org and Jens Lechtenboerger <lechten <at> wi.uni-muenster.de> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 10 May 2012 06:31:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 07 Jun 2012 11:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 296 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.