summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-04-04 21:43:15 +0100
committerjao <jao@gnu.org>2021-04-04 21:43:15 +0100
commit88edb9f1c6f06d7c3dfccdc496e07b52ff296d50 (patch)
treee2b71eaf12d5ecf84cd42197571a531a581030d9
parentfcc1c0f41764750f6edfc232c3587dcf69aa1a01 (diff)
downloadelibs-88edb9f1c6f06d7c3dfccdc496e07b52ff296d50.tar.gz
elibs-88edb9f1c6f06d7c3dfccdc496e07b52ff296d50.tar.bz2
jao-eww config clean-ups
-rw-r--r--init.org63
1 files changed, 39 insertions, 24 deletions
diff --git a/init.org b/init.org
index b9f9869..d355020 100644
--- a/init.org
+++ b/init.org
@@ -2248,12 +2248,38 @@
(advice-add 'eww-back-url :after #'jao-eww--rename-buffer)
(advice-add 'eww-forward-url :after #'jao-eww--rename-buffer)
- (defun jao-eww--close ()
+ (defun jao-eww-browse (arg)
+ (interactive "P" eww-mode)
+ (setq eww-prompt-history
+ (cl-remove-duplicates eww-prompt-history :test #'string=))
+ (let ((url (completing-read (if arg "eww in new buffer: " "eww: ")
+ eww-prompt-history nil nil nil
+ 'eww-prompt-history (eww-current-url))))
+ (eww url (when arg 4))))
+
+ (defun jao-eww-browse-new ()
+ (interactive nil eww-mode)
+ (jao-eww-browse t))
+
+ (defvar jao-eww--closed-urls ())
+
+ (defun jao-eww-close ()
(interactive nil eww-mode)
+ (when-let (current (eww-current-url))
+ (add-to-list 'jao-eww--closed-urls current))
(kill-current-buffer)
(when-let (b (car (jao-eww-session--list-buffers)))
(switch-to-buffer b)))
+ (defun jao-eww-reopen (arg)
+ (interactive "P")
+ (if (> (length jao-eww--closed-urls) 0)
+ (let ((url (completing-read "URL: " jao-eww--closed-urls)))
+ (jao-afio--goto-www)
+ (setq jao-eww--closed-urls (remove url jao-eww--closed-urls))
+ (eww url (when arg 4)))
+ (message "No previously closed URLs.")))
+
(defun jao-eww-reload (images)
(interactive "P" eww-mode)
(if images
@@ -2261,8 +2287,12 @@
(eww-reload t))
(call-interactively 'eww-reload)))
- (defun jao-eww--next-image ()
+ (defun jao-eww-reopen-new ()
(interactive)
+ (jao-eww-reopen t))
+
+ (defun jao-eww-next-image ()
+ (interactive nil eww-mode)
(when-let (p (text-property-search-forward 'image-displayer nil nil t))
(goto-char (prop-match-beginning p))))
@@ -2270,20 +2300,23 @@
:bind (:map eww-mode-map (("d" . eww-download)
("D" . jao-download)
- ("o" . jao-eww-browse-dwim)
+ ("o" . jao-eww-browse)
+ ("O" . jao-eww-browse-new)
("f" . eww-lnum-follow)
("F" . eww-lnum-universal)
("j" . jao-eww-visit-url-on-page)
("J" . jao-eww-jump-to-url-on-page)
("L" . eww-forward-url)
- ("N" . jao-eww--next-image)
+ ("N" . jao-eww-next-image)
("r" . jao-eww-reload)
("S" . jao-eww-session-load)
- ("W" . jao-eww--close)
+ ("u" . jao-eww-reopen)
+ ("U" . jao-eww-reopen-new)
+ ("W" . jao-eww-close)
("w" . org-eww-copy-for-org-mode)
("x" . jao-rss-subscribe)
("y" . eww-copy-page-url)
- ("C-c C-w" . jao-eww--close))))
+ ("C-c C-w" . jao-eww-close))))
(defun jao-eww-browse-url (url &rest r)
"Browse URL using eww."
@@ -2300,24 +2333,6 @@
(setq jao-browse-url-function #'jao-eww-browse-url)
(setq browse-url-browser-function jao-browse-url-function)
- (defun jao-eww-browse-dwim (url &optional arg)
- "Visit a URL, maybe from `eww-prompt-history', with completion.
-
- With optional prefix ARG (\\[universal-argument]) open URL in the
- a new buffer.
-
- If URL does not look like a valid link, run a web query using
- `eww-search-prefix'."
- (interactive
- (list
- (completing-read (if current-prefix-arg "eww in new buffer: " "eww: ")
- (setq eww-prompt-history
- (cl-remove-duplicates eww-prompt-history
- :test #'string=))
- nil nil nil 'eww-prompt-history)
- current-prefix-arg))
- (eww url (if arg 4 nil)))
-
(defun jao-eww--at-link ()
(and (get-text-property (point) 'shr-url)
(not (get-text-property (point) 'eww-form))))