Stub out +link-hint-define-keyword

I think this is still not quite right
This commit is contained in:
Case Duckworth 2022-02-18 18:18:20 -06:00
parent 7f8a95ea03
commit 0064d11659
1 changed files with 62 additions and 0 deletions

View File

@ -2,6 +2,7 @@
;;; Code:
(require 'cl-lib)
(require 'link-hint)
(defgroup +link-hint nil
@ -25,6 +26,67 @@
(defvar +link-hint-map (make-sparse-keymap)
"Keymap for `link-hint' functionality.")
(cl-defmacro +link-hint-define-keyword (keyword handler docstring
&optional (types 'link-hint-types)
&rest rest
&key multiple &allow-other-keys)
"Set up a `link-hint' KEYWORD, with optional TYPES.
If TYPES is not present, use `link-hint-types'.
KEYWORD defines the link-hint type. It will be used to create a
function for opening links of the form \"link-hint-openKEYWORD\".
HANDLER is the function to open a link with.
DOCSTRING is the macro's documentation.
Keyword arguments are passed to `link-hint-define-type' prefixed
with the KEYWORD."
(declare (indent 2)
(doc-string 3))
(let ((types (symbol-value types))
(func-sym (intern (format "+link-hint-open%s" keyword)))
(mult-sym (intern (format "%s-multiple" keyword)))
(expr))
;; Define the type
(push `(dolist (type ',types)
(link-hint-define-type type
,keyword ,handler
,@(mapcar (lambda (el)
(if (eq el :multiple)
mult-sym
el))
rest)))
expr)
;; Define an opener
(push `(defun ,func-sym ()
,(format "%s\n\nDefined by `+link-hint-define'." docstring)
(interactive)
(avy-with link-hint-open-link
(link-hint--one ,keyword)))
expr)
;; Handle `:multiple'
(when multiple
(push `(defun ,(intern (format "+link-hint-open-multiple%s" keyword)) ()
,(format "Open multiple links with `%s'.\n\nDefined by `+link-hint-define'."
func-sym)
(avy-with link-hint-open-multiple-links
(link-hint--multiple ,keyword)))
expr)
(push `(defun ,(intern (format "+link-hint-open-all%s" keyword)) ()
,(format "Open all visible links with `%s'.\n\nDefined by `+link-hint-define'."
func-sym)
(avy-with link-hint-open-all-links
(link-hint--all ,keyword)))
expr))
;; Return the built expression
`(progn ,@(nreverse expr))))
(+link-hint-define-keyword :secondary browse-url-secondary-browser-function
"Open a link in the secondary browser."
+link-hint-open-secondary-types
:multiple t)
(defun +link-hint-open-secondary-setup (&optional types)
"Define the `:open-secondary' link-hint type for TYPES.
If TYPES is nil, define it for `+link-hint-open-secondary-types'."