aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-10-07 00:08:10 +0300
committerJuri Linkov2019-10-07 00:08:10 +0300
commitd24a19779028f1fe940b43eb72e6c68d2d835bd7 (patch)
tree146fe1974e4991c72ace3e4172e885a190076311
parent47cf2a37e7f7d2df3cc05b657b1b4ad8307c7c64 (diff)
downloademacs-d24a19779028f1fe940b43eb72e6c68d2d835bd7.tar.gz
emacs-d24a19779028f1fe940b43eb72e6c68d2d835bd7.zip
Use tabs in EWW (bug#37592)
* lisp/net/eww.el (eww-open-in-new-buffer): Call tab-new when tab-bar-mode is enabled. (eww-browse-url): Add docstring. Call tab-new when tab-bar-mode is enabled. * lisp/net/shr.el (shr-map): Bind [C-down-mouse-1] to shr-mouse-browse-url-new-window. (shr-mouse-browse-url-new-window): New command. (shr-browse-url): Add optional arg new-window. * doc/misc/eww.texi (Basics): Mention opening tabs on M-RET.
-rw-r--r--doc/misc/eww.texi5
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/net/eww.el18
-rw-r--r--lisp/net/shr.el13
4 files changed, 37 insertions, 3 deletions
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index b8821cbc299..d0a4c9a7900 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -105,7 +105,10 @@ web page hit @kbd{g} (@code{eww-reload}). Pressing @kbd{w}
105@kindex M-RET 105@kindex M-RET
106 The @kbd{M-@key{RET}} command (@code{eww-open-in-new-buffer}) opens the 106 The @kbd{M-@key{RET}} command (@code{eww-open-in-new-buffer}) opens the
107URL at point in a new EWW buffer, akin to opening a link in a new 107URL at point in a new EWW buffer, akin to opening a link in a new
108``tab'' in other browsers. 108``tab'' in other browsers. When @code{global-tab-line-mode} is
109enabled, this buffer is displayed in the tab on the window tab line.
110When @code{tab-bar-mode} is enabled, a new tab is created on the frame
111tab bar.
109 112
110@findex eww-readable 113@findex eww-readable
111@kindex R 114@kindex R
diff --git a/etc/NEWS b/etc/NEWS
index 208db12519b..906dc912d6d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1186,6 +1186,10 @@ Invoking the command with a prefix argument will cause it to create a
1186new EWW buffer for the URL instead of reusing the default one. 1186new EWW buffer for the URL instead of reusing the default one.
1187 1187
1188+++ 1188+++
1189*** Clicking with the Ctrl key or 'C-u RET' on a link opens a new tab
1190when tab-bar-mode is enabled.
1191
1192+++
1189*** The 'd' ('eww-download') command now falls back to current page's URL. 1193*** The 'd' ('eww-download') command now falls back to current page's URL.
1190If this command is invoked with no URL at point, it now downloads the 1194If this command is invoked with no URL at point, it now downloads the
1191current page instead of signaling an error. 1195current page instead of signaling an error.
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fb495a98582..0756c6088bc 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -369,6 +369,9 @@ engine used."
369 (interactive) 369 (interactive)
370 (let ((url (eww-suggested-uris))) 370 (let ((url (eww-suggested-uris)))
371 (if (null url) (user-error "No link at point") 371 (if (null url) (user-error "No link at point")
372 (when tab-bar-mode
373 (let ((tab-bar-new-tab-choice t))
374 (tab-new)))
372 ;; clone useful to keep history, but 375 ;; clone useful to keep history, but
373 ;; should not clone from non-eww buffer 376 ;; should not clone from non-eww buffer
374 (with-current-buffer 377 (with-current-buffer
@@ -878,7 +881,22 @@ the like."
878 881
879;;;###autoload 882;;;###autoload
880(defun eww-browse-url (url &optional new-window) 883(defun eww-browse-url (url &optional new-window)
884 "Ask the EWW browser to load URL.
885
886Interactively, if the variable `browse-url-new-window-flag' is non-nil,
887loads the document in a new buffer tab on the window tab-line. A non-nil
888prefix argument reverses the effect of `browse-url-new-window-flag'.
889
890If `tab-bar-mode' is enabled, then whenever a document would
891otherwise be loaded in a new buffer, it is loaded in a new tab
892in the tab-bar on an existing frame.
893
894Non-interactively, this uses the optional second argument NEW-WINDOW
895instead of `browse-url-new-window-flag'."
881 (when new-window 896 (when new-window
897 (when tab-bar-mode
898 (let ((tab-bar-new-tab-choice t))
899 (tab-new)))
882 (pop-to-buffer-same-window 900 (pop-to-buffer-same-window
883 (generate-new-buffer 901 (generate-new-buffer
884 (format "*eww-%s*" (url-host (url-generic-parse-url 902 (format "*eww-%s*" (url-host (url-generic-parse-url
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 628cc17a5bd..f3d5de9fb67 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -201,6 +201,7 @@ and other things:
201 (define-key map [?\M-\t] 'shr-previous-link) 201 (define-key map [?\M-\t] 'shr-previous-link)
202 (define-key map [follow-link] 'mouse-face) 202 (define-key map [follow-link] 'mouse-face)
203 (define-key map [mouse-2] 'shr-browse-url) 203 (define-key map [mouse-2] 'shr-browse-url)
204 (define-key map [C-down-mouse-1] 'shr-mouse-browse-url-new-window)
204 (define-key map "I" 'shr-insert-image) 205 (define-key map "I" 'shr-insert-image)
205 (define-key map "w" 'shr-maybe-probe-and-copy-url) 206 (define-key map "w" 'shr-maybe-probe-and-copy-url)
206 (define-key map "u" 'shr-maybe-probe-and-copy-url) 207 (define-key map "u" 'shr-maybe-probe-and-copy-url)
@@ -967,7 +968,13 @@ size, and full-buffer size."
967 (mouse-set-point ev) 968 (mouse-set-point ev)
968 (shr-browse-url)) 969 (shr-browse-url))
969 970
970(defun shr-browse-url (&optional external mouse-event) 971(defun shr-mouse-browse-url-new-window (ev)
972 "Browse the URL under the mouse cursor in a new window."
973 (interactive "e")
974 (mouse-set-point ev)
975 (shr-browse-url nil nil t))
976
977(defun shr-browse-url (&optional external mouse-event new-window)
971 "Browse the URL at point using `browse-url'. 978 "Browse the URL at point using `browse-url'.
972If EXTERNAL is non-nil (interactively, the prefix argument), browse 979If EXTERNAL is non-nil (interactively, the prefix argument), browse
973the URL using `browse-url-secondary-browser-function'. 980the URL using `browse-url-secondary-browser-function'.
@@ -987,7 +994,9 @@ the mouse click event."
987 (progn 994 (progn
988 (funcall browse-url-secondary-browser-function url) 995 (funcall browse-url-secondary-browser-function url)
989 (shr--blink-link)) 996 (shr--blink-link))
990 (browse-url url)))))) 997 (browse-url url (if new-window
998 (not browse-url-new-window-flag)
999 browse-url-new-window-flag)))))))
991 1000
992(defun shr-save-contents (directory) 1001(defun shr-save-contents (directory)
993 "Save the contents from URL in a file." 1002 "Save the contents from URL in a file."