Skip to content

Commit

Permalink
search-engine(query-selection-in-search-engine): Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
aadcg committed Feb 20, 2024
1 parent a84f08e commit a490d1a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions source/search-engine.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,10 @@ Right now default search engine is the last one."

(define-command query-selection-in-search-engine (&key (query-in-new-buffer-p t))
"Search selected text using the queried search engine.
QUERY-IN-NEW-BUFFER creates a new buffer with the search results."
(let* ((selection (ffi-buffer-copy (current-buffer)))
(engine (prompt1 :prompt "Search engine"
:sources 'search-engine-source))
(target-buffer (if query-in-new-buffer-p
(make-buffer-focus)
(current-buffer))))
(when engine
(buffer-load (make-instance 'new-url-query :query selection :engine engine)
:buffer target-buffer))))
When QUERY-IN-NEW-BUFFER-P is non-nil, open the results in a new buffer."
(alex:when-let ((engine (prompt1 :prompt "Search engine"
:sources 'search-engine-source)))
(buffer-load (make-instance 'new-url-query
:query (ffi-buffer-copy (current-buffer))
:engine engine)
:buffer (if query-in-new-buffer-p (make-buffer-focus) (current-buffer)))))

0 comments on commit a490d1a

Please sign in to comment.