diff options
| author | Juri Linkov | 2019-10-07 00:08:10 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-10-07 00:08:10 +0300 |
| commit | d24a19779028f1fe940b43eb72e6c68d2d835bd7 (patch) | |
| tree | 146fe1974e4991c72ace3e4172e885a190076311 /lisp | |
| parent | 47cf2a37e7f7d2df3cc05b657b1b4ad8307c7c64 (diff) | |
| download | emacs-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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/net/eww.el | 18 | ||||
| -rw-r--r-- | lisp/net/shr.el | 13 |
2 files changed, 29 insertions, 2 deletions
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 | |||
| 886 | Interactively, if the variable `browse-url-new-window-flag' is non-nil, | ||
| 887 | loads the document in a new buffer tab on the window tab-line. A non-nil | ||
| 888 | prefix argument reverses the effect of `browse-url-new-window-flag'. | ||
| 889 | |||
| 890 | If `tab-bar-mode' is enabled, then whenever a document would | ||
| 891 | otherwise be loaded in a new buffer, it is loaded in a new tab | ||
| 892 | in the tab-bar on an existing frame. | ||
| 893 | |||
| 894 | Non-interactively, this uses the optional second argument NEW-WINDOW | ||
| 895 | instead 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'. |
| 972 | If EXTERNAL is non-nil (interactively, the prefix argument), browse | 979 | If EXTERNAL is non-nil (interactively, the prefix argument), browse |
| 973 | the URL using `browse-url-secondary-browser-function'. | 980 | the 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." |