EWW: Only read bookmarks if modified since last time

master
Pierre Neidhardt 2018-10-27 10:16:06 +02:00
parent 580b3214f0
commit 24dd3f80c3
1 changed files with 13 additions and 6 deletions

View File

@ -236,13 +236,20 @@ With prefix argument, prompt for bookmark title."
(message "Bookmarked %s (%s)" url title))))
(advice-add 'eww-add-bookmark :override 'ambrevar/eww-add-bookmark)
(defvar ambrevar/eww-bookmark-timestamp nil)
(defun ambrevar/eww-read-bookmarks ()
(let ((file (expand-file-name "eww-bookmarks.gpg" eww-bookmarks-directory)))
(setq eww-bookmarks
(unless (zerop (or (nth 7 (file-attributes file)) 0))
(with-temp-buffer
(insert-file-contents file)
(read (current-buffer)))))))
(let* ((file (expand-file-name "eww-bookmarks.gpg" eww-bookmarks-directory))
(mtime (file-attribute-modification-time (file-attributes file))))
(when (or (null ambrevar/eww-bookmark-timestamp)
(null eww-bookmarks)
(time-less-p ambrevar/eww-bookmark-timestamp
mtime))
(setq ambrevar/eww-bookmark-timestamp mtime)
(setq eww-bookmarks
(unless (zerop (or (file-attribute-size (file-attributes file)) 0))
(with-temp-buffer
(insert-file-contents file)
(read (current-buffer))))))))
(advice-add 'eww-read-bookmarks :override 'ambrevar/eww-read-bookmarks)
(defun ambrevar/eww-write-bookmarks ()