add eww page to collection

This commit is contained in:
Levi Neely 2024-09-17 15:25:21 +02:00
parent a301634140
commit 9efeff0dd9
1 changed files with 19 additions and 0 deletions

View File

@ -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)