emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r115172: net/eww.el: Detect localhost and similar pa


From: Teodor Zlatanov
Subject: [Emacs-diffs] trunk r115172: net/eww.el: Detect localhost and similar patterns.
Date: Thu, 21 Nov 2013 16:41:11 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115172
revision-id: address@hidden
parent: address@hidden
committer: Ted Zlatanov <address@hidden>
branch nick: quickfixes
timestamp: Thu 2013-11-21 11:41:35 -0500
message:
  net/eww.el: Detect localhost and similar patterns.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/net/eww.el                eww.el-20130610114603-80ap3gwnw4x4m5ix-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-11-21 16:30:14 +0000
+++ b/lisp/ChangeLog    2013-11-21 16:41:35 +0000
@@ -1,3 +1,8 @@
+2013-11-21  Kenjiro Nakayama <address@hidden>  (tiny change)
+
+       * net/eww.el (eww-local-regex): New variable.
+       (eww): Use it to detect localhost and similar.
+
 2013-11-21  Leo Liu  <address@hidden>
 
        Add completion for command `ag'.

=== modified file 'lisp/net/eww.el'
--- a/lisp/net/eww.el   2013-10-16 01:30:55 +0000
+++ b/lisp/net/eww.el   2013-11-21 16:41:35 +0000
@@ -101,23 +101,28 @@
 (defvar eww-start-url nil)
 (defvar eww-contents-url nil)
 
+(defvar eww-local-regex "localhost"
+  "When this regex is found in the URL, it's not a keyword but an address.")
+
 ;;;###autoload
 (defun eww (url)
   "Fetch URL and render the page.
 If the input doesn't look like an URL or a domain name, the
 word(s) will be searched for via `eww-search-prefix'."
   (interactive "sEnter URL or keywords: ")
-  (if (and (= (length (split-string url)) 1)
-           (> (length (split-string url "\\.")) 1))
-      (progn
-        (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
-          (setq url (concat "http://"; url)))
-        ;; some site don't redirect final /
-        (when (string= (url-filename (url-generic-parse-url url)) "")
-          (setq url (concat url "/"))))
-    (unless (string-match-p "\\'file:" url)
-      (setq url (concat eww-search-prefix
-                        (replace-regexp-in-string " " "+" url)))))
+  (cond ((string-match-p "\\`file:" url))
+       (t
+        (if (and (= (length (split-string url)) 1)
+                 (or (> (length (split-string url "\\.")) 1)
+                     (string-match eww-local-regex url)))
+            (progn
+              (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
+                (setq url (concat "http://"; url)))
+              ;; some site don't redirect final /
+              (when (string= (url-filename (url-generic-parse-url url)) "")
+                (setq url (concat url "/"))))
+          (setq url (concat eww-search-prefix
+                            (replace-regexp-in-string " " "+" url))))))
   (url-retrieve url 'eww-render (list url)))
 
 ;;;###autoload


reply via email to

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