I configured Emacs to open new links in eww like so:
(setq browse-url-browser-function 'eww-browse-url)
Now when I click on a link, it opens in the same buffer.
I would like it to open a new window (i.e split vertically like C - x 3) and open the page in the newly created frame on the right. So that I still have the original org-mode notes on the left.
[Edit]
I hacked together something. But it only works when I activate the hotkey, not when another function opens a link.
Ideally, I want something like the below, but for whenever I open a link (e.g in helm-google).
(defun my/open-in-right-window ()
"Open the selected link on the right window plane"
(interactive)
(delete-other-windows nil)
(split-window-right nil)
(other-window 1)
(org-return nil)
)
(defun my/eww-quitAndSingleWin ()
"Quit the current browser session and activate single window mode."
(interactive)
(quit-window nil)
(delete-other-windows nil)
)
(defun my/eww-split-right ()
"Splits the Window. Moves eww to the right and underlying content on the left."
(interactive)
(split-window-right nil)
(quit-window nil)
(other-window 1)
)
(global-set-key (kbd "H-r") 'my/open-in-right-window)
(add-hook 'eww-mode-hook ;no impact.
(lambda ()
(local-set-key (kbd "s") 'my/eww-split-right)
(local-set-key (kbd "Q") 'my/eww-quitAndSingleWin)
))
It kills other windows, opens new window, switches to new window, then presses return [which is configured to open links in my config].
Further then in eww-mode a 'Q' (capital) quits the session and kills the other window so as to avoid too many open windows.
It's not the most elegant solution. I'm open to better ideas?
While russel's answer may have been correct in the past, eww-current-title
and eww-current-url
has been obsoleted in favour of a buffer-local plist called eww-data
.
Current eww-implementation also includes the hooks we need to plug in after a buffer is rendered, thus avoiding the need to do "messy" things like defadvice
.
As per August 2015 and this Git-commit, the following elisp works for me:
(defun my-set-eww-buffer-title ()
(let* ((title (plist-get eww-data :title))
(url (plist-get eww-data :url))
(result (concat "*eww-" (or title
(if (string-match "://" url)
(substring url (match-beginning 0))
url)) "*")))
(rename-buffer result t)))
(add-hook 'eww-after-render-hook 'my-set-eww-buffer-title)
You can probably use this hook to add your desired keybindings too.