summaryrefslogtreecommitdiffhomepage
path: root/lib/net
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-03-26 22:40:54 +0000
committerjao <jao@gnu.org>2021-03-26 22:40:54 +0000
commita0db7c20b6621b17b90f0f758652c7d120468a4a (patch)
treea820a437d75cda69a1fb86eb892e0d3a291c1ae5 /lib/net
parent2efe63605a87df5537ec07d931bd5ae0e395a42a (diff)
downloadelibs-a0db7c20b6621b17b90f0f758652c7d120468a4a.tar.gz
elibs-a0db7c20b6621b17b90f0f758652c7d120468a4a.tar.bz2
jao-eww-session: flag to avoid saving non-started sessions
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)