emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master bbc218b: Add eww-open-in-new-buffer to EWW


From: Mark Oteiza
Subject: [Emacs-diffs] master bbc218b: Add eww-open-in-new-buffer to EWW
Date: Wed, 2 Nov 2016 20:01:51 +0000 (UTC)

branch: master
commit bbc218b9b06d952f0ba31f7706d88c0bf8dc41d8
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>

    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.
---
 doc/misc/eww.texi |    6 ++++++
 etc/NEWS          |    3 +++
 lisp/net/eww.el   |   24 ++++++++++++++++++------
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index 81f97a9..ea25863 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
 web page hit @kbd{g} (@code{eww-reload}).  Pressing @kbd{w}
 (@code{eww-copy-page-url}) will copy the current URL to the kill ring.
 
address@hidden eww-open-in-new-buffer
address@hidden M-RET
+  The @kbd{M-RET} command (@code{eww-open-in-new-buffer}) opens the
+URL at point in a new EWW buffer, akin to opening a link in a new
+``tab'' in other browsers.
+
 @findex eww-readable
 @kindex R
   The @kbd{R} command (@code{eww-readable}) will attempt to determine
diff --git a/etc/NEWS b/etc/NEWS
index e29dfe2..9a671f2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -330,6 +330,9 @@ with blank space to eshell history.
 ** eww
 
 +++
+*** New 'M-RET' command for opening a link at point in a new eww buffer.
+
++++
 *** A new 's' command for switching to another eww buffer via the minibuffer.
 
 ---
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 6a84003..5310a81 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -64,18 +64,16 @@
 ;;;###autoload
 (defcustom eww-suggest-uris
   '(eww-links-at-point
-    url-get-url-at-point
-    eww-current-url)
+    url-get-url-at-point)
   "List of functions called to form the list of default URIs for `eww'.
 Each of the elements is a function returning either a string or a list
 of strings.  The results will be joined into a single list with
 duplicate entries (if any) removed."
-  :version "25.1"
+  :version "26.1"
   :group 'eww
   :type 'hook
   :options '(eww-links-at-point
-            url-get-url-at-point
-            eww-current-url))
+            url-get-url-at-point))
 
 (defcustom eww-bookmarks-directory user-emacs-directory
   "Directory where bookmark files will be stored."
@@ -246,7 +244,7 @@ This list can be customized via `eww-suggest-uris'."
 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
-   (let* ((uris (eww-suggested-uris))
+   (let* ((uris (append (eww-suggested-uris) (list (eww-current-url))))
          (prompt (concat "Enter URL or keywords"
                          (if uris (format " (default %s)" (car uris)) "")
                          ": ")))
@@ -314,6 +312,18 @@ See the `eww-search-prefix' variable for the search engine 
used."
   (interactive "r")
   (eww (buffer-substring beg end)))
 
+(defun eww-open-in-new-buffer ()
+  "Fetch link at point in a new EWW buffer."
+  (interactive)
+  (let ((url (eww-suggested-uris)))
+    (if (null url) (user-error "No link at point")
+      ;; clone useful to keep history, but
+      ;; should not clone from non-eww buffer
+      (with-current-buffer
+          (if (eq major-mode 'eww-mode) (clone-buffer)
+            (generate-new-buffer "*eww*"))
+        (eww (if (consp url) (car url) url))))))
+
 (defun eww-html-p (content-type)
   "Return non-nil if CONTENT-TYPE designates an HTML content type.
 Currently this means either text/html or application/xhtml+xml."
@@ -697,6 +707,7 @@ the like."
   (let ((map (make-sparse-keymap)))
     (define-key map "g" 'eww-reload) ;FIXME: revert-buffer-function instead!
     (define-key map "G" 'eww)
+    (define-key map [?\M-\r] 'eww-open-in-new-buffer)
     (define-key map [?\t] 'shr-next-link)
     (define-key map [?\M-\t] 'shr-previous-link)
     (define-key map [backtab] 'shr-previous-link)
@@ -731,6 +742,7 @@ the like."
        ["Exit" quit-window t]
        ["Close browser" quit-window t]
        ["Reload" eww-reload t]
+       ["Follow URL in new buffer" eww-open-in-new-buffer]
        ["Back to previous page" eww-back-url
         :active (not (zerop (length eww-history)))]
        ["Forward to next page" eww-forward-url



reply via email to

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