summaryrefslogtreecommitdiffhomepage
path: root/lib/net
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/jao-eww-session.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/net/jao-eww-session.el b/lib/net/jao-eww-session.el
index 6e68eb6..ddbc572 100644
--- a/lib/net/jao-eww-session.el
+++ b/lib/net/jao-eww-session.el
@@ -308,18 +308,21 @@ the session is already displayed in a eww tab, jao-eww-session can:
(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)
- (let ((inhibit-message is-auto))
- (with-temp-buffer
- (insert ";;;; File generated by jao-eww-session. DO NOT EDIT!\n")
- (pp (jao-eww-session-current) (current-buffer))
- (insert "\n" ";;;; End of "
- (file-name-nondirectory jao-eww-session-file) "\n")
- (write-region (point-min) (point-max) (expand-file-name filename)))))
+ (when jao-eww-session--init
+ (let ((inhibit-message is-auto))
+ (with-temp-buffer
+ (insert ";;;; File generated by jao-eww-session. DO NOT EDIT!\n")
+ (pp (jao-eww-session-current) (current-buffer))
+ (insert "\n" ";;;; End of "
+ (file-name-nondirectory jao-eww-session-file) "\n")
+ (write-region (point-min) (point-max) (expand-file-name filename))))))
(defvar jao-eww-session--timer nil)
-
(defun jao-eww-session--backup-name (fname)
(concat (expand-file-name fname) ".bak"))
@@ -341,9 +344,12 @@ 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-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)