fix(lookup): check ivy|helm-mode before using their backends

This commit is contained in:
Itai Y. Efrat 2022-05-04 09:40:24 +03:00 committed by Henrik Lissner
parent 8a27eb99be
commit 68191e7419

View file

@ -74,12 +74,12 @@ QUERY must be a string, and PROVIDER must be a key of
;;;###autoload ;;;###autoload
(defun +lookup--online-backend-google (query) (defun +lookup--online-backend-google (query)
"Search Google, starting with QUERY, with live autocompletion." "Search Google, starting with QUERY, with live autocompletion."
(cond ((fboundp 'counsel-search) (cond ((and (bound-and-true-p ivy-mode) (fboundp 'counsel-search))
(let ((ivy-initial-inputs-alist `((t . ,query))) (let ((ivy-initial-inputs-alist `((t . ,query)))
(counsel-search-engine 'google)) (counsel-search-engine 'google))
(call-interactively #'counsel-search) (call-interactively #'counsel-search)
t)) t))
((require 'helm-net nil t) ((and (bound-and-true-p helm-mode) (require 'helm-net nil t))
(helm :sources 'helm-source-google-suggest (helm :sources 'helm-source-google-suggest
:buffer "*helm google*" :buffer "*helm google*"
:input query) :input query)
@ -88,7 +88,7 @@ QUERY must be a string, and PROVIDER must be a key of
;;;###autoload ;;;###autoload
(defun +lookup--online-backend-duckduckgo (query) (defun +lookup--online-backend-duckduckgo (query)
"Search DuckDuckGo, starting with QUERY, with live autocompletion." "Search DuckDuckGo, starting with QUERY, with live autocompletion."
(cond ((fboundp 'counsel-search) (cond ((and (bound-and-true-p ivy-mode) (fboundp 'counsel-search))
(let ((ivy-initial-inputs-alist `((t . ,query))) (let ((ivy-initial-inputs-alist `((t . ,query)))
(counsel-search-engine 'ddg)) (counsel-search-engine 'ddg))
(call-interactively #'counsel-search) (call-interactively #'counsel-search)