Add :lookup & rewrite +jump/online
This commit is contained in:
parent
d5d0f26c09
commit
61ad485ae3
3 changed files with 30 additions and 30 deletions
|
@ -2,20 +2,15 @@
|
|||
|
||||
;;;###autoload (autoload '+jump:online "feature/jump/autoload/evil" nil t)
|
||||
(evil-define-command +jump:online (query &optional bang)
|
||||
"Look up QUERY online. You can prefix your queries with a one-letter shortcut
|
||||
key (dictated by `+jump-search-url-alist'), otherwise you will be prompted for
|
||||
what search engine to use."
|
||||
"Look up QUERY online. Will prompt for search engine the first time, then
|
||||
reuse it on consecutive uses of this command. If BANG, always prompt for search
|
||||
engine."
|
||||
(interactive "<a><!>")
|
||||
(let ((query query)
|
||||
(engine (assoc (car-safe (split-string query " " t t))
|
||||
+jump-search-url-alist)))
|
||||
(if engine
|
||||
(setq query (string-join (cdr-safe (split-string query " " t t)) " "))
|
||||
(let ((engine (completing-read "Search on: "
|
||||
(mapcar #'cadr +jump-search-url-alist)
|
||||
nil t)))
|
||||
(setq engine (cl-find-if (lambda (x) (equal (cadr x) engine))
|
||||
+jump-search-url-alist))))
|
||||
(unless engine
|
||||
(error "Search engine couldn't be found"))
|
||||
(setq query (or query (thing-at-point 'symbol t)))
|
||||
(unless query
|
||||
(user-error "The search query is empty"))
|
||||
(let ((engine (or (and (not bang) (bound-and-true-p +jump--online-last))
|
||||
(completing-read (format "Search on (%s): " query)
|
||||
(mapcar #'car +jump-search-url-alist)
|
||||
nil t))))
|
||||
(+jump/online engine query)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue