From: joakim@verona.se
To: Daniel Colascione <dancol@dancol.org>
Cc: Achim Gratz <Stromeko@nexgo.de>, emacs-devel@gnu.org
Subject: Re: file://host/location URLs
Date: Wed, 21 Nov 2012 07:33:16 +0100 [thread overview]
Message-ID: <m34nkjtqhf.fsf@chopper.vpn.verona.se> (raw)
In-Reply-To: <50A8FF48.6090007@dancol.org> (Daniel Colascione's message of "Sun, 18 Nov 2012 07:31:20 -0800")
Daniel Colascione <dancol@dancol.org> writes:
> On 11/17/12 12:25 AM, Achim Gratz wrote:
>> Daniel Colascione writes:
>>> If anyone actually uses remote file URIs, please tell me. Otherwise, I intend to
>>> make "file:" and "file://" strictly equivalent and always local.
>>
>> Common bugs in applications and misconceptions of some users
>> notwithstanding, an URI should implement:
>>
>> http://tools.ietf.org/html/rfc3986>
>> You may find that your proposal (IIUIC) is violating that specification.
>> The only instances a file: URI refers to the local file system is if the
>> authority (host) part is missing or the local host is explicitly given
>> as the authority.
>
> Yes, my proposal violates the RFC. I maintain that nobody deliberately
> constructs file URLs pointing to remote hosts, and that the behavior
> that best matches user intent is to always interpret file URIs as
> local, RFC be damned.
>
>
In the xwidget branch I use the attached patch to massage the url
entered by the user. It makes browsing more convenient.
Do you think this solution could be expanded to also handle file://
urls? (The url fixup should be opt-in but I havent done that yet)
=== modified file 'lisp/net/browse-url.el'
--- lisp/net/browse-url.el 2012-09-17 05:41:04 +0000
+++ lisp/net/browse-url.el 2012-11-13 01:55:06 +0000
@@ -666,7 +666,7 @@
;; functions allows them to be stand-alone commands, making it easier
;; to switch between browsers.
-(defun browse-url-interactive-arg (prompt)
+(defun browse-url-interactive-arg (prompt &optional default-url)
"Read a URL from the minibuffer, prompting with PROMPT.
If `transient-mark-mode' is non-nil and the mark is active,
it defaults to the current region, else to the URL at or before
@@ -683,7 +683,8 @@
"[\t\r\f\n ]+" ""
(buffer-substring-no-properties
(region-beginning) (region-end))))
- (browse-url-url-at-point)))
+ (browse-url-url-at-point)
+ default-url))
(not (eq (null browse-url-new-window-flag)
(null current-prefix-arg)))))
@@ -790,6 +791,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Browser-independent commands
+(defun url-tidy (url)
+ "Tidy up URL as much as possible."
+ (if (equal 0 (string-match ".*://" url))
+ url
+ (concat "http://" url) ;;TODO guess more url forms, like mailto
+ ))
+
;; A generic command to call the current browse-url-browser-function
;;;###autoload
@@ -802,6 +810,7 @@
(interactive (browse-url-interactive-arg "URL: "))
(unless (called-interactively-p 'interactive)
(setq args (or args (list browse-url-new-window-flag))))
+ (setq url (url-tidy url))
(let ((process-environment (copy-sequence process-environment))
(function (or (and (string-match "\\`mailto:" url)
browse-url-mailto-function)
--
Joakim Verona
next prev parent reply other threads:[~2012-11-21 6:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-15 23:43 file://host/location URLs Daniel Colascione
2012-11-16 14:18 ` Stefan Monnier
2012-11-17 0:58 ` James Cloos
2012-11-17 3:00 ` Daniel Colascione
2012-11-17 8:25 ` Achim Gratz
2012-11-17 20:16 ` James Cloos
2012-11-18 8:12 ` Chong Yidong
2012-11-18 15:31 ` Daniel Colascione
2012-11-19 3:54 ` Stephen J. Turnbull
2012-11-19 17:16 ` Achim Gratz
2012-11-20 12:54 ` Jason Rumney
2012-11-20 20:07 ` Daniel Colascione
2012-11-20 20:52 ` Achim Gratz
2012-11-21 6:33 ` joakim [this message]
2012-11-21 8:29 ` Andreas Schwab
2012-11-22 8:50 ` joakim
2012-11-18 15:27 ` Stephen J. Turnbull
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=m34nkjtqhf.fsf@chopper.vpn.verona.se \
--to=joakim@verona.se \
--cc=Stromeko@nexgo.de \
--cc=dancol@dancol.org \
--cc=emacs-devel@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).