Simplify SEARCHENGINES:PREPROCESS-AND-SEARCH

Hoist guard clause to the start of the function. This separates the
preconditions from the 'meat' of function and makes the wrapping PROGN form
unnecessary. Don't test for nil explicitly either.
This commit is contained in:
Javier Olaechea 2017-08-22 07:25:12 -05:00
parent 4f090025dd
commit f9e9a27cdc

View file

@ -7,20 +7,19 @@
"Additional executable parameters for searching browser")
(defun preprocess-and-search (url search &optional (raw-search nil) (raise-browser t))
(unless *search-browser-executable*
(message-no-timeout "searchengines:*search-browser-executable* is nil, set it first."))
(let* ((search-processed (if raw-search
search
(url-encode search :utf-8)))
(uri (format nil url search-processed)))
(if (eql *search-browser-executable* nil)
(message-no-timeout "searchengines:*search-browser-executable* is nil, set it first")
(progn
(run-shell-command
(concatenate 'string
*search-browser-executable*
" " (format nil "~{~A~^ ~}" *search-browser-params*)
" \"" uri "\""))
(when raise-browser
(funcall (intern (string-upcase *search-browser-executable*))))))))
(run-shell-command
(concatenate 'string
*search-browser-executable*
" " (format nil "~{~A~^ ~}" *search-browser-params*)
" \"" uri "\""))
(when raise-browser
(funcall (intern (string-upcase *search-browser-executable*))))))
(defmacro make-searchengine-prompt (name caption url docstring
&key (map nil) (key nil) (binded t))