aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2016-11-02 15:58:28 -0400
committerMark Oteiza2016-11-02 15:58:28 -0400
commitbbc218b9b06d952f0ba31f7706d88c0bf8dc41d8 (patch)
tree26c623ea9eed56d9a11bb07129f5e46996be4c79
parent3f06795181fb09aebaadfe592e7741ddc8ff8adf (diff)
downloademacs-bbc218b9b06d952f0ba31f7706d88c0bf8dc41d8.tar.gz
emacs-bbc218b9b06d952f0ba31f7706d88c0bf8dc41d8.zip
Add eww-open-in-new-buffer to EWW
* doc/misc/eww.texi (Basic): Document new command and key. * etc/NEWS: Mention new key and its purpose. * lisp/net/eww.el (eww-suggest-uris): Remove eww-current-url. (eww): Append (eww-current-url) to the prompt defaults. (eww-open-in-new-buffer): New command. (eww-mode-map): Bind it and add a menu item.
-rw-r--r--doc/misc/eww.texi6
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/net/eww.el24
3 files changed, 27 insertions, 6 deletions
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index 81f97a9db85..ea258634301 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -97,6 +97,12 @@ and the web page is rendered in it. You can leave EWW by pressing
97web page hit @kbd{g} (@code{eww-reload}). Pressing @kbd{w} 97web page hit @kbd{g} (@code{eww-reload}). Pressing @kbd{w}
98(@code{eww-copy-page-url}) will copy the current URL to the kill ring. 98(@code{eww-copy-page-url}) will copy the current URL to the kill ring.
99 99
100@findex eww-open-in-new-buffer
101@kindex M-RET
102 The @kbd{M-RET} command (@code{eww-open-in-new-buffer}) opens the
103URL at point in a new EWW buffer, akin to opening a link in a new
104``tab'' in other browsers.
105
100@findex eww-readable 106@findex eww-readable
101@kindex R 107@kindex R
102 The @kbd{R} command (@code{eww-readable}) will attempt to determine 108 The @kbd{R} command (@code{eww-readable}) will attempt to determine
diff --git a/etc/NEWS b/etc/NEWS
index e29dfe23028..9a671f2ae53 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -330,6 +330,9 @@ with blank space to eshell history.
330** eww 330** eww
331 331
332+++ 332+++
333*** New 'M-RET' command for opening a link at point in a new eww buffer.
334
335+++
333*** A new 's' command for switching to another eww buffer via the minibuffer. 336*** A new 's' command for switching to another eww buffer via the minibuffer.
334 337
335--- 338---
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 6a8400320c2..5310a814655 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -64,18 +64,16 @@
64;;;###autoload 64;;;###autoload
65(defcustom eww-suggest-uris 65(defcustom eww-suggest-uris
66 '(eww-links-at-point 66 '(eww-links-at-point
67 url-get-url-at-point 67 url-get-url-at-point)
68 eww-current-url)
69 "List of functions called to form the list of default URIs for `eww'. 68 "List of functions called to form the list of default URIs for `eww'.
70Each of the elements is a function returning either a string or a list 69Each of the elements is a function returning either a string or a list
71of strings. The results will be joined into a single list with 70of strings. The results will be joined into a single list with
72duplicate entries (if any) removed." 71duplicate entries (if any) removed."
73 :version "25.1" 72 :version "26.1"
74 :group 'eww 73 :group 'eww
75 :type 'hook 74 :type 'hook
76 :options '(eww-links-at-point 75 :options '(eww-links-at-point
77 url-get-url-at-point 76 url-get-url-at-point))
78 eww-current-url))
79 77
80(defcustom eww-bookmarks-directory user-emacs-directory 78(defcustom eww-bookmarks-directory user-emacs-directory
81 "Directory where bookmark files will be stored." 79 "Directory where bookmark files will be stored."
@@ -246,7 +244,7 @@ This list can be customized via `eww-suggest-uris'."
246If the input doesn't look like an URL or a domain name, the 244If the input doesn't look like an URL or a domain name, the
247word(s) will be searched for via `eww-search-prefix'." 245word(s) will be searched for via `eww-search-prefix'."
248 (interactive 246 (interactive
249 (let* ((uris (eww-suggested-uris)) 247 (let* ((uris (append (eww-suggested-uris) (list (eww-current-url))))
250 (prompt (concat "Enter URL or keywords" 248 (prompt (concat "Enter URL or keywords"
251 (if uris (format " (default %s)" (car uris)) "") 249 (if uris (format " (default %s)" (car uris)) "")
252 ": "))) 250 ": ")))
@@ -314,6 +312,18 @@ See the `eww-search-prefix' variable for the search engine used."
314 (interactive "r") 312 (interactive "r")
315 (eww (buffer-substring beg end))) 313 (eww (buffer-substring beg end)))
316 314
315(defun eww-open-in-new-buffer ()
316 "Fetch link at point in a new EWW buffer."
317 (interactive)
318 (let ((url (eww-suggested-uris)))
319 (if (null url) (user-error "No link at point")
320 ;; clone useful to keep history, but
321 ;; should not clone from non-eww buffer
322 (with-current-buffer
323 (if (eq major-mode 'eww-mode) (clone-buffer)
324 (generate-new-buffer "*eww*"))
325 (eww (if (consp url) (car url) url))))))
326
317(defun eww-html-p (content-type) 327(defun eww-html-p (content-type)
318 "Return non-nil if CONTENT-TYPE designates an HTML content type. 328 "Return non-nil if CONTENT-TYPE designates an HTML content type.
319Currently this means either text/html or application/xhtml+xml." 329Currently this means either text/html or application/xhtml+xml."
@@ -697,6 +707,7 @@ the like."
697 (let ((map (make-sparse-keymap))) 707 (let ((map (make-sparse-keymap)))
698 (define-key map "g" 'eww-reload) ;FIXME: revert-buffer-function instead! 708 (define-key map "g" 'eww-reload) ;FIXME: revert-buffer-function instead!
699 (define-key map "G" 'eww) 709 (define-key map "G" 'eww)
710 (define-key map [?\M-\r] 'eww-open-in-new-buffer)
700 (define-key map [?\t] 'shr-next-link) 711 (define-key map [?\t] 'shr-next-link)
701 (define-key map [?\M-\t] 'shr-previous-link) 712 (define-key map [?\M-\t] 'shr-previous-link)
702 (define-key map [backtab] 'shr-previous-link) 713 (define-key map [backtab] 'shr-previous-link)
@@ -731,6 +742,7 @@ the like."
731 ["Exit" quit-window t] 742 ["Exit" quit-window t]
732 ["Close browser" quit-window t] 743 ["Close browser" quit-window t]
733 ["Reload" eww-reload t] 744 ["Reload" eww-reload t]
745 ["Follow URL in new buffer" eww-open-in-new-buffer]
734 ["Back to previous page" eww-back-url 746 ["Back to previous page" eww-back-url
735 :active (not (zerop (length eww-history)))] 747 :active (not (zerop (length eww-history)))]
736 ["Forward to next page" eww-forward-url 748 ["Forward to next page" eww-forward-url