fix(lookup): +lookup/online for vertico users
Would formerly throw wrong-number-of-args errors.
This commit is contained in:
parent
910230d14d
commit
3bd358dc36
1 changed files with 21 additions and 24 deletions
|
@ -36,30 +36,27 @@ QUERY must be a string, and PROVIDER must be a key of
|
|||
(interactive
|
||||
(list (if (use-region-p) (doom-thing-at-point-or-region))
|
||||
(+lookup--online-provider current-prefix-arg)))
|
||||
(let ((backend (cl-find-if (lambda (x) (or (stringp x) (fboundp x)))
|
||||
(cdr (assoc provider +lookup-provider-url-alist)))))
|
||||
(unless (and (functionp backend)
|
||||
(funcall backend query))
|
||||
(unless backend
|
||||
(user-error "%S is an invalid query engine backend for %S provider"
|
||||
backend provider))
|
||||
(let ((backends (cdr (assoc provider +lookup-provider-url-alist))))
|
||||
(unless backends
|
||||
(user-error "No available online lookup backend for %S provider"
|
||||
provider))
|
||||
(catch 'done
|
||||
(dolist (backend backends)
|
||||
(cl-check-type backend (or string function))
|
||||
(condition-case-unless-debug e
|
||||
(progn
|
||||
(unless query
|
||||
(setq query
|
||||
(cond ((stringp backend)
|
||||
(funcall +lookup-open-url-fn
|
||||
(format backend
|
||||
(url-encode-url
|
||||
(or query
|
||||
(read-string (format "Search for (on %s): " provider)
|
||||
(thing-at-point 'symbol t))))
|
||||
(when (or (functionp backend) (symbolp backend))
|
||||
(setq backend (funcall backend)))
|
||||
(when (string-empty-p query)
|
||||
(user-error "The query query is empty"))
|
||||
(funcall +lookup-open-url-fn (format backend (url-encode-url query))))
|
||||
(thing-at-point 'symbol t)))))))
|
||||
((condition-case-unless-debug e
|
||||
(and (fboundp backend)
|
||||
(funcall backend query))
|
||||
(error
|
||||
(setq +lookup--last-provider
|
||||
(delq (assq major-mode +lookup--last-provider)
|
||||
+lookup--last-provider))
|
||||
(signal (car e) (cdr e)))))))
|
||||
(delq! major-mode +lookup--last-provider 'assq)
|
||||
(signal (car e) (cdr e))))
|
||||
(throw 'done t)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +lookup/online-select ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue