diff options
| author | Ted Zlatanov | 2013-11-21 11:41:35 -0500 |
|---|---|---|
| committer | Ted Zlatanov | 2013-11-21 11:41:35 -0500 |
| commit | 604ede6c0722816ff54a72644ccd73fdc18530ed (patch) | |
| tree | 6d3f5ed60f79678e50f4f5a0df93cb7e2f581a9f | |
| parent | 2021a20053592053dfe78ff5190afa1104010344 (diff) | |
| download | emacs-604ede6c0722816ff54a72644ccd73fdc18530ed.tar.gz emacs-604ede6c0722816ff54a72644ccd73fdc18530ed.zip | |
net/eww.el: Detect localhost and similar patterns.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/net/eww.el | 27 |
2 files changed, 21 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0865d0c81cf..ce530e898a0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-11-21 Kenjiro Nakayama <nakayamakenjiro@gmail.com> (tiny change) | ||
| 2 | |||
| 3 | * net/eww.el (eww-local-regex): New variable. | ||
| 4 | (eww): Use it to detect localhost and similar. | ||
| 5 | |||
| 1 | 2013-11-21 Leo Liu <sdl.web@gmail.com> | 6 | 2013-11-21 Leo Liu <sdl.web@gmail.com> |
| 2 | 7 | ||
| 3 | Add completion for command `ag'. | 8 | Add completion for command `ag'. |
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 573715e8fcf..86e09776b42 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -101,23 +101,28 @@ | |||
| 101 | (defvar eww-start-url nil) | 101 | (defvar eww-start-url nil) |
| 102 | (defvar eww-contents-url nil) | 102 | (defvar eww-contents-url nil) |
| 103 | 103 | ||
| 104 | (defvar eww-local-regex "localhost" | ||
| 105 | "When this regex is found in the URL, it's not a keyword but an address.") | ||
| 106 | |||
| 104 | ;;;###autoload | 107 | ;;;###autoload |
| 105 | (defun eww (url) | 108 | (defun eww (url) |
| 106 | "Fetch URL and render the page. | 109 | "Fetch URL and render the page. |
| 107 | If the input doesn't look like an URL or a domain name, the | 110 | If the input doesn't look like an URL or a domain name, the |
| 108 | word(s) will be searched for via `eww-search-prefix'." | 111 | word(s) will be searched for via `eww-search-prefix'." |
| 109 | (interactive "sEnter URL or keywords: ") | 112 | (interactive "sEnter URL or keywords: ") |
| 110 | (if (and (= (length (split-string url)) 1) | 113 | (cond ((string-match-p "\\`file:" url)) |
| 111 | (> (length (split-string url "\\.")) 1)) | 114 | (t |
| 112 | (progn | 115 | (if (and (= (length (split-string url)) 1) |
| 113 | (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url) | 116 | (or (> (length (split-string url "\\.")) 1) |
| 114 | (setq url (concat "http://" url))) | 117 | (string-match eww-local-regex url))) |
| 115 | ;; some site don't redirect final / | 118 | (progn |
| 116 | (when (string= (url-filename (url-generic-parse-url url)) "") | 119 | (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url) |
| 117 | (setq url (concat url "/")))) | 120 | (setq url (concat "http://" url))) |
| 118 | (unless (string-match-p "\\'file:" url) | 121 | ;; some site don't redirect final / |
| 119 | (setq url (concat eww-search-prefix | 122 | (when (string= (url-filename (url-generic-parse-url url)) "") |
| 120 | (replace-regexp-in-string " " "+" url))))) | 123 | (setq url (concat url "/")))) |
| 124 | (setq url (concat eww-search-prefix | ||
| 125 | (replace-regexp-in-string " " "+" url)))))) | ||
| 121 | (url-retrieve url 'eww-render (list url))) | 126 | (url-retrieve url 'eww-render (list url))) |
| 122 | 127 | ||
| 123 | ;;;###autoload | 128 | ;;;###autoload |