branch: externals/hyperbole commit 4860da080269d5561a41e68acef8a907db9b9d74 Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
hsettings.el (hyperbole-web-search): Add flag to return search expr --- ChangeLog | 4 ++++ hsettings.el | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c97134d18..5bca1146b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ 2022-07-19 Mats Lidell <ma...@gnu.org> +* hsettings.el (hyperbole-web-search): Add optional 'return-search-expr-flag' + to return search expression rather than doing the search. Use + with Assist Key. + * test/demo-tests.el (fast-demo-key-series-shell-pushd-hyperb-dir, fast-demo-key-series-shell-grep, fast-demo-key-series-shell-apropos): diff --git a/hsettings.el b/hsettings.el index 3a7f6ac032..c271674daf 100644 --- a/hsettings.el +++ b/hsettings.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 15-Apr-91 at 00:48:49 -;; Last-Mod: 18-Jun-22 at 21:56:43 by Mats Lidell +;; Last-Mod: 17-Jul-22 at 16:27:17 by Bob Weiner ;; ;; Copyright (C) 1991-2022 Free Software Foundation, Inc. ;; See the "HY-COPY" file for license information. @@ -156,7 +156,7 @@ lines" (hyperbole-default-web-search-term)))) (list service-name search-term))) -(defun hyperbole-web-search (&optional service-name search-term) +(defun hyperbole-web-search (&optional service-name search-term return-search-expr-flag) "Search web SERVICE-NAME for SEARCH-TERM. Both arguments are optional and are prompted for when not given or when null. Uses `hyperbole-web-search-alist' to match each service to its search url. @@ -170,11 +170,17 @@ package to display search results." (lambda (service1 service2) (equal (downcase service1) (downcase service2))))))) (setq search-term (browse-url-url-encode-chars search-term "[*\"()',=;?% ]")) - (cond ((stringp search-pat) - (browse-url (format search-pat search-term))) - ((functionp search-pat) - (funcall search-pat search-term)) - (t (user-error "(Hyperbole): Invalid web search service `%s'" service-name)))))) + (if return-search-expr-flag + (cond ((stringp search-pat) + (format search-pat search-term)) + ((functionp search-pat) + (list search-pat search-term)) + (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 search-term)) + (t (user-error "(Hyperbole): Invalid web search service `%s'" service-name))))))) ;; This must be defined before the defcustom `inhbit-hyperbole-messaging'. ;;;###autoload