summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/net/jao-eww-session.el40
1 files changed, 11 insertions, 29 deletions
diff --git a/lib/net/jao-eww-session.el b/lib/net/jao-eww-session.el
index b0c659d..06f9287 100644
--- a/lib/net/jao-eww-session.el
+++ b/lib/net/jao-eww-session.el
@@ -194,7 +194,7 @@ the session is already displayed in a eww tab, jao-eww-session can:
(const :value always)
(const :value ask)))
-(defcustom jao-eww-session-file "~/.jao-eww-session"
+(defcustom jao-eww-session-file "~/.emacs.d/eww-session.eld"
"File to save the eww session data."
:group 'jao-eww-session
:type 'file)
@@ -218,18 +218,8 @@ the session is already displayed in a eww tab, jao-eww-session can:
(t (jao-eww-session--filter url (cdr filters)))))
(defun jao-eww-session--list-buffers ()
- (save-window-excursion
- (when (ignore-errors (eww-list-buffers))
- (goto-char (point-min))
- (let* ((buffers)
- (cf (lambda ()
- (when-let (b (get-text-property (line-beginning-position)
- 'eww-buffer))
- (push b buffers))
- (forward-line)
- (not (eobp)))))
- (while (funcall cf))
- buffers))))
+ (seq-filter (lambda (b) (with-current-buffer b (derived-mode-p 'eww-mode)))
+ (buffer-list)))
(defun jao-eww-session--current-urls ()
(let ((urls)
@@ -305,15 +295,9 @@ the session is already displayed in a eww tab, jao-eww-session can:
(let ((sexp (read (current-buffer))))
(and (equal 'jao-eww-session (car sexp)) sexp))))))
-(defun jao-eww-session-current-to-file ()
- (jao-eww-session--to--file jao-eww-session-file))
-
-(defvar jao-eww-session--init nil)
-(defun jao-eww-session--init () (setq jao-eww-session--init t))
-
(defun jao-eww-session--to--file (filename &optional is-auto)
(require 'pp)
- (when jao-eww-session--init
+ (when (> (length (jao-eww-session-urls)) 0)
(let ((inhibit-message is-auto))
(with-temp-buffer
(insert ";;;; File generated by jao-eww-session. DO NOT EDIT!\n")
@@ -322,6 +306,9 @@ the session is already displayed in a eww tab, jao-eww-session can:
(file-name-nondirectory jao-eww-session-file) "\n")
(write-region (point-min) (point-max) (expand-file-name filename))))))
+(defun jao-eww-session-current-to-file ()
+ (jao-eww-session--to--file jao-eww-session-file))
+
(defvar jao-eww-session--timer nil)
(defun jao-eww-session--backup-name (fname)
(concat (expand-file-name fname) ".bak"))
@@ -344,12 +331,9 @@ the session is already displayed in a eww tab, jao-eww-session can:
jao-eww-session-autosave-period
'jao-eww-session--save-backup))))
-
-
;;;; save session on checkpoints
-(add-to-list 'kill-emacs-query-functions (lambda () (jao-eww-session-save) t))
+(add-to-list 'kill-emacs-query-functions #'jao-eww-session-save)
(add-hook 'eww-after-render-hook #'jao-eww-session--save-backup)
-(add-hook 'eww-after-render-hook #'jao-eww-session--init)
(advice-add 'eww-back-url :after #'jao-eww-session--save-backup)
(advice-add 'eww-forward-url :after #'jao-eww-session--save-backup)
@@ -362,11 +346,9 @@ the session is already displayed in a eww tab, jao-eww-session can:
(defun jao-eww-session-save ()
"Save the current eww session."
(interactive)
- (when (and jao-eww-session--init
- (or jao-eww-session-save-always
- (y-or-n-p "Save current eww session? ")))
- (jao-eww-session-current-to-file)
- (jao-eww-session--restart--autosave)))
+ (when (or jao-eww-session-save-always (y-or-n-p "Save current eww session? "))
+ (jao-eww-session-current-to-file))
+ t)
;;;###autoload
(defun jao-eww-session-load ()