Skip to content
Matthew edited this page Dec 20, 2019 · 3 revisions

Snippets to integrate with Helm

Categorize eaf bookmarks

The following adds sources for browser and pdf app to `helm-filtered-bookmarks` command:

(defvar helm-bookmark-preds+
  '(helm-bookmark-org-file-p
    helm-bookmark-addressbook-p
    helm-bookmark-gnus-bookmark-p
    helm-bookmark-w3m-bookmark-p
    helm-bookmark-woman-man-bookmark-p
    helm-bookmark-info-bookmark-p
    helm-bookmark-image-bookmark-p
    helm-bookmark-file-p
    helm-bookmark-helm-find-files-p
    helm-bookmark-addressbook-p))

(define-advice helm-bookmark-uncategorized-bookmark-p (:override (bookmark) customize)
  "Return non--nil if BOOKMARK match no known category.

This uses `helm-bookmark-preds+' to make it easier to add categories."
  (cl-loop for pred in helm-bookmark-preds+
           never (funcall pred bookmark)))


(with-eval-after-load 'helm-bookmark
  (push 'helm-bookmark-eaf-p+ helm-bookmark-preds+)

  (defun helm-bookmark-eaf-p+ (bookmark)
    "Check if bookmark is an eaf bookmark."
    (eq (bookmark-get-handler bookmark)
        'eaf--bookmark-restore))


    (dolist (app '("browser" "pdf-viewer"))
      (push
       (helm-make-source (format "Bookmark %s" app) 'helm-source-filtered-bookmarks
         :init (lambda ()
                 (bookmark-maybe-load-default-file)
                 (helm-init-candidates-in-buffer
                     'global
                   (helm-bookmark-filter-setup-alist
                    (lambda (bookmark)
                      (equal (bookmark-prop-get bookmark 'eaf-app)
                             app))))))
       helm-bookmark-default-filtered-sources)))
Clone this wiki locally