From 9efeff0dd995b947ee574c2c395e543a510cbe1d Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:25:21 +0200 Subject: [PATCH] add eww page to collection --- emacs/module/module-collect.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/emacs/module/module-collect.el b/emacs/module/module-collect.el index 0595551..7f39b22 100644 --- a/emacs/module/module-collect.el +++ b/emacs/module/module-collect.el @@ -224,6 +224,25 @@ ".html"))) (concat timestamp "_" (file-name-sans-extension full-path) extension))) +(defun collect/add-eww-page-to-collection () + "Add the current eww page to a specified collection." + (interactive) + (if (eq major-mode 'eww-mode) + (progn + (eww-copy-page-url) + (let* ((url (read-string "Enter URL to add: " (current-kill 0))) + (collections (collect/get-collections)) + (selected-collection (completing-read "Select collection to add to: " + (mapcar #'car collections) nil t)) + (target-dir (cdr (assoc selected-collection collections)))) + (if (and url (file-directory-p target-dir)) + (progn + (message "Adding webpage to collection...") + (collect/add-webpage-to-collection-internal url target-dir selected-collection)) + (message "Invalid URL or collection directory.")))) + (message "This function can only be used in eww-mode."))) + + (provide 'module-collect)