about summary refs log tree commit diff stats
path: root/lisp/+link-hint.el
blob: e9d215af7e3f27370befd5b686c374573a075c3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;;; +link-hint.el -*- lexical-binding: t; -*-

;;; Code:

(require 'link-hint)

(defgroup +link-hint nil
  "Extra customizations for `link-hint'."
  :group 'link-hint)

(defcustom +link-hint-open-secondary-types '(gnus-w3m-image-url
                                             gnus-w3m-url
                                             markdown-link
                                             mu4e-attachment
                                             mu4e-url
                                             notmuch-hello
                                             nov-link
                                             org-link
                                             shr-url
                                             text-url
                                             w3m-link
                                             w3m-message-link)
  "Link types to define `:open-secondary' for.")

(defun +link-hint-setup-open-secondary (&optional types)
  "Define the `:open-secondary' link-hint type for TYPES.
If TYPES is nil, define it for `+link-hint-open-secondary-types'."
  (dolist (type (or types +link-hint-open-secondary-types))
    (link-hint-define-type type
      :open-secondary browse-url-secondary-browser-function
      :open-secondary-multiple t)))

(defun +link-hint-open-link (prefix)
  "Open a link.
Without a PREFIX, open using `browse-url-browser-function'; with
a PREFIX, use `browse-url-secondary-browser-function'."
  (interactive "P")
  (avy-with link-hint-open-link
    (link-hint--one (if prefix :open-secondary :open))))

(defun +link-hint-open-multiple-links (prefix)
  "Open multiple links.
Without a PREFIX, open using `browse-url-browser-function'; with
a PREFIX, use `browse-url-secondary-browser-function'."
  (interactive "P")
  (avy-with link-hint-open-multiple-links
    (link-hint--one (if prefix :open-secondary :open))))

(defun +link-hint-open-all-links (prefix)
  "Open all visible links.
Without a PREFIX, open using `browse-url-browser-function'; with
a PREFIX, use `browse-url-secondary-browser-function'."
  (interactive "P")
  (avy-with link-hint-open-all-links
    (link-hint--one (if prefix :open-secondary :open))))

(provide '+link-hint)
;;; +link-hint.el ends here