emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file://host/location URLs


From: joakim
Subject: Re: file://host/location URLs
Date: Wed, 21 Nov 2012 07:33:16 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

Daniel Colascione <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]