From: Mark Oteiza <mvoteiza@udel.edu>
To: emacs-devel@gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: [PATCH] eww-open-in-new-buffer
Date: Tue, 01 Nov 2016 22:03:18 -0400 [thread overview]
Message-ID: <87shramye1.fsf@udel.edu> (raw)
Hi,
I wanted something akin to "open in new tab" for eww, so I wrote the
following.
M-RET seemed a good binding. One thing that bugs me about this is that
eww-current-url in eww-suggest-uris didn't quite fit: as the new
function is, it doesn't make sense if url is (eww-current-url).
So, I made changes to eww-suggest-uris. Alternatively,
eww-open-in-new-buffer could check if url is equal to eww-current-url
and just clone instead of invoking eww. That might be better.
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 6a84003..bbb55ca 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -64,8 +64,7 @@ eww-download-directory
;;;###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
@@ -74,8 +73,7 @@ eww-suggest-uris
: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 @@ eww
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 @@ eww-search-words
(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 @@ eww-mode-map
(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 @@ eww-mode-map
["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
next reply other threads:[~2016-11-02 2:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 2:03 Mark Oteiza [this message]
2016-11-02 19:22 ` [PATCH] eww-open-in-new-buffer Lars Ingebrigtsen
2016-11-02 20:52 ` Mark Oteiza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87shramye1.fsf@udel.edu \
--to=mvoteiza@udel.edu \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.