From d70cf20ddcd1fd6dafb73e344834d9022b2aa419 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sun, 15 Apr 2018 20:06:46 +0530 Subject: [PATCH] eww: Add tag filtering --- .emacs.d/lisp/init-eww.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.emacs.d/lisp/init-eww.el b/.emacs.d/lisp/init-eww.el index 6e1c9821..d46d3e3e 100644 --- a/.emacs.d/lisp/init-eww.el +++ b/.emacs.d/lisp/init-eww.el @@ -1,9 +1,5 @@ ;;; EWW -;; DONE: Bookmarks: Check if count is correct after saving. -;; DONE: Bookmarks: Check sorting. -;; DONE: Bookmarks: Fix encoding. - ;; TODO: Fix `eww-forward-url' infinite forwarding. ;; TODO: Extend the history / bookmarks view to display tags, etc. @@ -276,4 +272,23 @@ word(s) will be searched for via `eww-search-prefix'." (let ((eww-bookmarks (seq-filter (lambda (b) (plist-get b :mark)) eww-bookmarks))) (eww-list-bookmarks))) +(defun ambrevar/eww-bookmarks-list-by-tags (&optional arg) + "Return bookmarks matching one of the specified tags. +With prefix argument or ARG, bookmarks much match all tags." + (let ((tag-list (delq nil (mapcar (lambda (b) (plist-get b :tags)) eww-bookmarks)))) + (seq-uniq (mapcar 'append tag-list)) + (let ((tags (completing-read-multiple "Tags for bookmark (comma separated): " tag-list))) + (seq-filter (lambda (b) + (if arg + (null (seq-difference tags (plist-get b :tags))) + (seq-intersection tags (plist-get b :tags)))) + eww-bookmarks)))) + +(defun ambrevar/eww-bookmarks-by-tags (&optional arg) + "Display bookmarks matching one of the specified tags. +With prefix argument or ARG, bookmarks much match all tags." + (interactive "P") + (let ((eww-bookmarks (ambrevar/eww-bookmarks-list-by-tags arg))) + (eww-list-bookmarks))) + (provide 'init-eww)