summary refs log tree commit diff stats
path: root/lisp/+link-hint.el
diff options
context:
space:
mode:
authorCase Duckworth2022-02-18 18:18:20 -0600
committerCase Duckworth2022-02-18 18:18:20 -0600
commit0064d11659d8fe826c11ecf02bf1378256b3bdde (patch)
tree398797abd0153bac98137d2b5e3102918f75b3f9 /lisp/+link-hint.el
parentFix some typo stuff (diff)
downloademacs-0064d11659d8fe826c11ecf02bf1378256b3bdde.tar.gz
emacs-0064d11659d8fe826c11ecf02bf1378256b3bdde.zip
Stub out +link-hint-define-keyword
I think this is still not quite right
Diffstat (limited to 'lisp/+link-hint.el')
-rw-r--r--lisp/+link-hint.el62
1 files changed, 62 insertions, 0 deletions
diff --git a/lisp/+link-hint.el b/lisp/+link-hint.el index a6999b7..205e915 100644 --- a/lisp/+link-hint.el +++ b/lisp/+link-hint.el
@@ -2,6 +2,7 @@
2 2
3;;; Code: 3;;; Code:
4 4
5(require 'cl-lib)
5(require 'link-hint) 6(require 'link-hint)
6 7
7(defgroup +link-hint nil 8(defgroup +link-hint nil
@@ -25,6 +26,67 @@
25(defvar +link-hint-map (make-sparse-keymap) 26(defvar +link-hint-map (make-sparse-keymap)
26 "Keymap for `link-hint' functionality.") 27 "Keymap for `link-hint' functionality.")
27 28
29(cl-defmacro +link-hint-define-keyword (keyword handler docstring
30 &optional (types 'link-hint-types)
31 &rest rest
32 &key multiple &allow-other-keys)
33 "Set up a `link-hint' KEYWORD, with optional TYPES.
34If TYPES is not present, use `link-hint-types'.
35
36KEYWORD defines the link-hint type. It will be used to create a
37function for opening links of the form \"link-hint-openKEYWORD\".
38
39HANDLER is the function to open a link with.
40
41DOCSTRING is the macro's documentation.
42
43Keyword arguments are passed to `link-hint-define-type' prefixed
44with the KEYWORD."
45 (declare (indent 2)
46 (doc-string 3))
47 (let ((types (symbol-value types))
48 (func-sym (intern (format "+link-hint-open%s" keyword)))
49 (mult-sym (intern (format "%s-multiple" keyword)))
50 (expr))
51 ;; Define the type
52 (push `(dolist (type ',types)
53 (link-hint-define-type type
54 ,keyword ,handler
55 ,@(mapcar (lambda (el)
56 (if (eq el :multiple)
57 mult-sym
58 el))
59 rest)))
60 expr)
61 ;; Define an opener
62 (push `(defun ,func-sym ()
63 ,(format "%s\n\nDefined by `+link-hint-define'." docstring)
64 (interactive)
65 (avy-with link-hint-open-link
66 (link-hint--one ,keyword)))
67 expr)
68 ;; Handle `:multiple'
69 (when multiple
70 (push `(defun ,(intern (format "+link-hint-open-multiple%s" keyword)) ()
71 ,(format "Open multiple links with `%s'.\n\nDefined by `+link-hint-define'."
72 func-sym)
73 (avy-with link-hint-open-multiple-links
74 (link-hint--multiple ,keyword)))
75 expr)
76 (push `(defun ,(intern (format "+link-hint-open-all%s" keyword)) ()
77 ,(format "Open all visible links with `%s'.\n\nDefined by `+link-hint-define'."
78 func-sym)
79 (avy-with link-hint-open-all-links
80 (link-hint--all ,keyword)))
81 expr))
82 ;; Return the built expression
83 `(progn ,@(nreverse expr))))
84
85(+link-hint-define-keyword :secondary browse-url-secondary-browser-function
86 "Open a link in the secondary browser."
87 +link-hint-open-secondary-types
88 :multiple t)
89
28(defun +link-hint-open-secondary-setup (&optional types) 90(defun +link-hint-open-secondary-setup (&optional types)
29 "Define the `:open-secondary' link-hint type for TYPES. 91 "Define the `:open-secondary' link-hint type for TYPES.
30If TYPES is nil, define it for `+link-hint-open-secondary-types'." 92If TYPES is nil, define it for `+link-hint-open-secondary-types'."