unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jens Lechtenboerger <lechten@wi.uni-muenster.de>
To: 9131@debbugs.gnu.org
Subject: bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs
Date: Wed, 20 Jul 2011 17:28:21 +0200	[thread overview]
Message-ID: <87k4bdott6.fsf@pcwi7557.uni-muenster.de> (raw)

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





             reply	other threads:[~2011-07-20 15:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 15:28 Jens Lechtenboerger [this message]
2012-05-10  6:27 ` bug#9131: 23.3; ffap-url-unwrap-local broken for file URIs Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k4bdott6.fsf@pcwi7557.uni-muenster.de \
    --to=lechten@wi.uni-muenster.de \
    --cc=9131@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).