summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-10-30 17:15:49 +0800
committerJSDurand <mmemmew@gmail.com>2021-10-30 17:15:49 +0800
commita6409c2c21bde798ffb30b6256630ff35659c1c5 (patch)
treee3479146092c024044d2e5932f14d2bdaf764422
parent74056ddaed555c37e80552b70fc0016768530112 (diff)
blist: external groups
* bookmark-conf.el (blist-filter-groups): ("external"): (durand-set-external-bookmark): (durand-external-jump):
-rw-r--r--bookmark-conf.el54
1 files changed, 54 insertions, 0 deletions
diff --git a/bookmark-conf.el b/bookmark-conf.el
index 45e0849..f20dfff 100644
--- a/bookmark-conf.el
+++ b/bookmark-conf.el
@@ -65,6 +65,7 @@
(cons "Gnus" #'blist-gnus-p)
(cons "EWW" #'blist-eww-p)
(cons "Info" #'blist-info-p)
+ (cons "External" #'blist-external-p)
(cons "Org" #'blist-org-p)
(cons "C" #'blist-c-p)
(cons "Default" #'blist-default-p)))
@@ -131,6 +132,12 @@
(blist-define-criterion "elisp" "ELisp"
(string-match-p "\\.el$" (blist-get-location bookmark)))
+;;;; External group
+
+(blist-define-criterion "external" "External"
+ (eq (bookmark-get-handler bookmark)
+ #'durand-external-jump))
+
;;; Fit annotations buffer to window
(defun durand-bookmark-jump-fit-to-window (&rest _args)
@@ -198,5 +205,52 @@ any."
:around
#'durand-bookmark-set-preserve-annotation-advice)
+;;; Bookmarks for external browsers
+
+(defun durand-set-external-bookmark (url name)
+ "Set a bookmark NAME storing URL.
+This will be opened by the function `browse-url-default-browser'."
+ (bookmark-store
+ name
+ (list
+ (cons 'location url)
+ (cons 'handler #'durand-external-jump))
+ nil))
+
+(defun durand-external-jump (bookmark)
+ "Jump to the external BOOKMARK.
+BOOKMARK should be set by `durand-set-external-bookmark'."
+ (let* ((location (bookmark-prop-get bookmark 'location))
+ (reporter (make-progress-reporter
+ (format "Opening %s..." location))))
+ (browse-url-default-browser location)
+ (progress-reporter-done reporter)))
+
+(mapc
+ (lambda (cons-cell)
+ (durand-set-external-bookmark (car cons-cell) (cdr cons-cell)))
+ (list
+ (cons
+ "https://www.youtube.com"
+ "(External) YouTube")
+ (cons
+ "https://www.gmail.com"
+ "(External) GMail")
+ (cons
+ "https://www.facebook.com"
+ "(External) Facebook")
+ (cons
+ "https://protesilaos.com"
+ "(External) prot")
+ (cons
+ "https://wmail1.cc.ntu.edu.tw/rc/?_task=mail&_mbox=INBOX"
+ "(External) NTU mail")
+ (cons
+ "https://dictionary.christian-steinert.de/#home"
+ "(External) tibdict")
+ ;; "https://wmail1.cc.ntu.edu.tw/index.php?url=https%3A%2F%2Fwmail1.cc.ntu.edu.tw%2F"
+ ))
+
+
(provide 'bookmark-conf)
;;; bookmark-conf.el ends here