From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joakim@verona.se Newsgroups: gmane.emacs.devel Subject: Re: file://host/location URLs Date: Wed, 21 Nov 2012 07:33:16 +0100 Message-ID: References: <50A57E1A.4040109@dancol.org> <50A6FDD7.4090304@dancol.org> <87a9ugljpg.fsf@Rainer.invalid> <50A8FF48.6090007@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1353479625 14595 80.91.229.3 (21 Nov 2012 06:33:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Nov 2012 06:33:45 +0000 (UTC) Cc: Achim Gratz , emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 21 07:33:55 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tb3sh-0005wP-1a for ged-emacs-devel@m.gmane.org; Wed, 21 Nov 2012 07:33:55 +0100 Original-Received: from localhost ([::1]:53464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tb3sW-000896-K7 for ged-emacs-devel@m.gmane.org; Wed, 21 Nov 2012 01:33:44 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tb3sS-00080W-TI for emacs-devel@gnu.org; Wed, 21 Nov 2012 01:33:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tb3sR-0003uI-Fm for emacs-devel@gnu.org; Wed, 21 Nov 2012 01:33:40 -0500 Original-Received: from mx1.bahnhof.se ([213.80.101.11]:61040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tb3sR-0003t5-5k for emacs-devel@gnu.org; Wed, 21 Nov 2012 01:33:39 -0500 Original-Received: from localhost (mf.bahnhof.se [213.80.101.20]) by mx1-reinject (Postfix) with ESMTP id D9F72295616; Wed, 21 Nov 2012 07:33:29 +0100 (CET) X-Virus-Scanned: by amavisd-new using ClamAV at bahnhof.se (MF3) Original-Received: from mf3.bahnhof.se ([127.0.0.1]) by localhost (mf3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T1wXBS-fQY37; Wed, 21 Nov 2012 07:33:27 +0100 (CET) Original-Received: from exodia.verona.se (h-235-102.a149.priv.bahnhof.se [85.24.235.102]) by mf3.bahnhof.se (Postfix) with ESMTP id 16A39605051; Wed, 21 Nov 2012 07:33:26 +0100 (CET) Original-Received: from chopper.vpn.verona.se (DIR-655.verona.se [192.168.200.86]) by exodia.verona.se (Postfix) with ESMTP id 8DC734E010B; Wed, 21 Nov 2012 07:33:16 +0100 (CET) In-Reply-To: <50A8FF48.6090007@dancol.org> (Daniel Colascione's message of "Sun, 18 Nov 2012 07:31:20 -0800") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Mac OS X 10.x X-Received-From: 213.80.101.11 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:155014 Archived-At: Daniel Colascione 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