eww: Add `url' and `title' optional arguments to eww-add-bookmark
parent
c541fa0ab4
commit
dbae48e80d
|
@ -170,8 +170,10 @@ word(s) will be searched for via `eww-search-prefix'."
|
|||
;; TODO: Merge qutebrowser quickmarks.
|
||||
;; TODO: Add bookmark editing functions such as edit title, tags, quickmark,
|
||||
;; search-engine. Use eww-buffers and Helm.
|
||||
(defun ambrevar/eww-add-bookmark ()
|
||||
(defun ambrevar/eww-add-bookmark (&optional url title)
|
||||
"Bookmark the current page."
|
||||
(setq url (or url (plist-get eww-data :url)))
|
||||
(setq title (or title (plist-get eww-data :title)))
|
||||
(interactive)
|
||||
(eww-read-bookmarks)
|
||||
(let (tag-list)
|
||||
|
@ -179,22 +181,21 @@ word(s) will be searched for via `eww-search-prefix'."
|
|||
(when (equal
|
||||
;; PATCH: Ignore protocol when sorting.
|
||||
;; TODO: Include "sort-bookmarks": Warn for unique tags, warn for same URL up to paragraph. Make this customizable.
|
||||
(replace-regexp-in-string "^https?" "" (plist-get eww-data :url))
|
||||
(replace-regexp-in-string "^https?" "" url)
|
||||
(replace-regexp-in-string "^https?" "" (plist-get bookmark :url)))
|
||||
(user-error "Already bookmarked"))
|
||||
(setq tag-list (append tag-list (plist-get bookmark :tags))))
|
||||
(cl-delete-duplicates tag-list)
|
||||
(let ((tags (completing-read-multiple "Tags for bookmark (comma separated): " tag-list))
|
||||
(title (replace-regexp-in-string "[\n\t\r]" " "
|
||||
(plist-get eww-data :title))))
|
||||
(title (replace-regexp-in-string "[\n\t\r]" " " title)))
|
||||
(setq title (replace-regexp-in-string "\\` +\\| +\\'" "" title))
|
||||
(push `(:url ,(plist-get eww-data :url)
|
||||
(push `(:url ,url
|
||||
:title ,title
|
||||
:time ,(current-time-string)
|
||||
,@(if tags (list :tags tags)))
|
||||
eww-bookmarks)
|
||||
(eww-write-bookmarks)
|
||||
(message "Bookmarked %s (%s)" (plist-get eww-data :url)
|
||||
(message "Bookmarked %s (%s)" url
|
||||
(plist-get eww-data :title)))))
|
||||
(advice-add 'eww-add-bookmark :override 'ambrevar/eww-add-bookmark)
|
||||
|
||||
|
|
Loading…
Reference in New Issue