diff --git a/.config/next/init.lisp b/.config/next/init.lisp index 04cafb4b..bdf5d02b 100644 --- a/.config/next/init.lisp +++ b/.config/next/init.lisp @@ -134,17 +134,7 @@ Recognized formats: (getf (nthcdr 3 object) :keybinding) (format-c->lisp (nth 2 object))))) -(defvar my-search-engines - (loop for file in '("~/.emacs.d/lisp/init-engine.el" - "~/personal/bookmarks/engines.el") - append (next::with-maybe-gpg-file (s file) - (read-emacs-engines s)))) - -(define-configuration browser - ((search-engines (append my-search-engines %slot-default)) - (session-restore-prompt :always-restore))) - -(defmethod deserialize-bookmarks (stream) +(defmethod deserialize-eww-bookmarks (stream) "This version of deserialize-bookmarks is compatibly with Ambrevar's EWW format." (handler-case @@ -165,13 +155,44 @@ format." (when (getf entry :mark) (setf (getf entry :shortcut) (getf entry :mark)) (remf entry :mark)) - (apply #'make-instance 'bookmark-entry + (apply #'make-instance 'next:bookmark-entry entry)) entries))) (error (c) - (log:error "Error during bookmark deserialization: ~a" c) + (log:error "During bookmark deserialization: ~a" c) nil))) +(defun restore-eww-bookmarks () + "Restore the bookmarks from EWW." + (handler-case + (let ((data (with-data-file (file (make-instance 'data-path + :basename "~/personal/bookmarks/eww-bookmarks.gpg") + :direction :input + :if-does-not-exist nil) + (when file + (deserialize-eww-bookmarks file))))) + (when data + (echo "Loading ~a bookmarks from ~s." + (length data) + (expand-path (bookmarks-path *browser*))) + (setf (slot-value *browser* 'next::bookmarks-data) data))) + + (error (c) + (echo-warning "Failed to load bookmarks from ~s: ~a" (expand-path (bookmarks-path *browser*)) c)))) + +(defvar my-search-engines + (loop for file in '("~/.emacs.d/lisp/init-engine.el" + "~/personal/bookmarks/engines.el") + append (next::with-maybe-gpg-file (s file) + (read-emacs-engines s)))) + +(define-configuration browser + ((search-engines (append my-search-engines %slot-default)) + (session-restore-prompt :always-restore) + (bookmarks-path (make-instance 'bookmarks-data-path :basename "bookmarks.lisp.gpg")) + ;; (bookmarks-restore-function #'restore-eww-bookmarks) + )) + (setf next/vcs:*vcs-projects-roots* '("~/projects" "~/common-lisp" "~/.local/share/emacs/site-lisp"))