Function: hyperbole-web-search

hyperbole-web-search is an interactive and byte-compiled function defined in hsettings.el.

Signature

(hyperbole-web-search &optional SERVICE-NAME SEARCH-TERM RETURN-SEARCH-EXPR-FLAG)

Documentation

Search web SERVICE-NAME for SEARCH-TERM (both arguments are optional).

With optional RETURN-SEARCH-EXPR-FLAG, return the search expression.

Use hyperbole-web-search-alist to match each service to its search url or function. Use hyperbole-web-search-browser-function and the browse-url package to display search results.

If SERVICE-NAME is not given or is null and it is associated with a function rather than a search url in hyperbole-web-search-alist, don't prompt for SEARCH-TERM; the function will prompt for that when run.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hsettings.el
(defun hyperbole-web-search (&optional service-name search-term return-search-expr-flag)
  "Search web SERVICE-NAME for SEARCH-TERM (both arguments are optional).
With optional RETURN-SEARCH-EXPR-FLAG, return the search expression.

Use `hyperbole-web-search-alist' to match each service to its search
url or function.
Use `hyperbole-web-search-browser-function' and the `browse-url'
package to display search results.

If SERVICE-NAME is not given or is null and it is associated with
a function rather than a search url in `hyperbole-web-search-alist',
don't prompt for SEARCH-TERM; the function will prompt for that when
run."
  (interactive)
  (cl-multiple-value-bind (service-name search-term)
      (hyperbole-read-web-search-arguments service-name search-term)
    (let ((browse-url-browser-function hyperbole-web-search-browser-function)
	  (search-pat (cdr (assoc service-name hyperbole-web-search-alist
				  (lambda (service1 service2)
				    (equal (downcase service1) (downcase service2)))))))
      (unless (null search-term)
	(setq search-term (browse-url-url-encode-chars search-term "[*\"()',=;?% ]")))
      (if return-search-expr-flag
	  (cond ((stringp search-pat)
		 (format search-pat search-term))
		((functionp search-pat)
		 (list search-pat))
		(t (user-error "(Hyperbole): Invalid web search service `%s'" service-name)))
	(cond ((stringp search-pat)
	       (browse-url (format search-pat search-term)))
	      ((functionp search-pat)
	       (funcall search-pat))
	      (t (user-error "(Hyperbole): Invalid web search service `%s'" service-name)))))))