summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-01 00:08:14 +0100
committerjao <jao@gnu.org>2022-09-01 00:08:14 +0100
commit749905e3b35e784b8254d9efbe33ddef2cb1d776 (patch)
tree3bbf9b319fc0f3b6b1aed9dc4dc4441ca6ebe2f3 /lib
parent1070a4ecb5c15933e80724bf93f785a9790a27cb (diff)
downloadelibs-749905e3b35e784b8254d9efbe33ddef2cb1d776.tar.gz
elibs-749905e3b35e784b8254d9efbe33ddef2cb1d776.tar.bz2
eww-session: don't try to open if there's eww buffers around
Diffstat (limited to 'lib')
-rw-r--r--lib/eos/jao-afio.el18
-rw-r--r--lib/net/jao-eww-session.el10
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/eos/jao-afio.el b/lib/eos/jao-afio.el
index 0f1ae43..c8f4b7d 100644
--- a/lib/eos/jao-afio.el
+++ b/lib/eos/jao-afio.el
@@ -72,25 +72,29 @@
(when (y-or-n-p (format "Load saved session? (%d docs)" (length docs)))
(jao-afio-open-pdf-session docs))))))
-(declare w3m "w3m")
-(declare w3m-alive-p "w3m")
-(declare w3m-previous-buffer "w3m")
-(declare notmuch "notmuch")
+(declare-function w3m "w3m")
+(declare-function notmuch "notmuch")
+(declare-function jao-eww-session-eww-buffers "jao-eww-session")
+(declare-function jao-eww-session-load "jao-eww-session")
+
+(defun jao-afio--open-eww-sesion ()
+ (when (null (jao-eww-session-eww-buffers))
+ (jao-eww-session-load)))
;;;###autoload
(defun jao-afio-open-www ()
(interactive)
(require 'jao-eww-session)
(if (< (frame-width) 160)
- (if jao-afio-use-w3m (w3m) (jao-eww-session-load))
+ (if jao-afio-use-w3m (w3m) (jao-afio--open-eww-session))
(delete-other-windows)
(split-window-right)
(if jao-afio-use-w3m
(w3m)
- (jao-eww-session-load)
+ (jao-afio--open-eww-session)
(let ((b (current-buffer)))
(other-window 1)
- (switch-to-buffer (car (jao-eww-session--list-buffers b)))
+ (switch-to-buffer (car (jao-eww-session-eww-buffers b)))
(other-window 1)))))
;;;###autoload
diff --git a/lib/net/jao-eww-session.el b/lib/net/jao-eww-session.el
index 9a34656..4ac5447 100644
--- a/lib/net/jao-eww-session.el
+++ b/lib/net/jao-eww-session.el
@@ -86,7 +86,7 @@ the session is already displayed in a eww tab, jao-eww-session can:
(defvar jao-eww-current-session '(jao-eww-session 0 nil))
-(defun jao-eww-session--list-buffers (&optional skip)
+(defun jao-eww-session-eww-buffers (&optional skip)
(seq-filter (lambda (b)
(when (not (eq b skip))
(with-current-buffer b (derived-mode-p 'eww-mode))))
@@ -94,7 +94,7 @@ the session is already displayed in a eww tab, jao-eww-session can:
(defun jao-eww-session-invisible-buffers ()
(seq-filter (lambda (b) (null (get-buffer-window b)))
- (jao-eww-session--list-buffers (current-buffer))))
+ (jao-eww-session-eww-buffers (current-buffer))))
(defun jao-eww--current-url ()
(when-let (url (eww-current-url)) (url-encode-url url)))
@@ -104,7 +104,7 @@ the session is already displayed in a eww tab, jao-eww-session can:
(cb (current-buffer))
(pos 0)
(count 0))
- (dolist (b (jao-eww-session--list-buffers (when skip-current cb))
+ (dolist (b (jao-eww-session-eww-buffers (when skip-current cb))
(list pos (reverse urls)))
(set-buffer b)
(when-let (url (jao-eww--current-url))
@@ -141,7 +141,7 @@ the session is already displayed in a eww tab, jao-eww-session can:
(or (and (eq jao-eww-session-duplicate-tabs 'never))
(not (y-or-n-p (format "'%s' (%s) is already open. Duplicate? "
(jao-eww-buffer-title) url))))))))
- (jao-eww-session--list-buffers)))
+ (jao-eww-session-eww-buffers)))
(defun jao-eww-session-load-aux ()
(let ((new-session (jao-eww-session-from-file
@@ -226,7 +226,7 @@ the session is already displayed in a eww tab, jao-eww-session can:
(dolist (url urls) (eww url 4))
(seq-each #'kill-buffer buffers)
(unless (zerop offset)
- (switch-to-buffer (nth offset (jao-eww-session--list-buffers)))))))
+ (switch-to-buffer (nth offset (jao-eww-session-eww-buffers)))))))
(provide 'jao-eww-session)
;;; jao-eww-session.el ends here