branch: externals/kiwix commit 85c3a054a243474c85e7f2351384455ac60c3542 Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: stardiviner <numbch...@gmail.com>
Use same initial input for Ivy and Helm and extract the login into function --- kiwix.el | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/kiwix.el b/kiwix.el index 44c0cfd..b044d6e 100644 --- a/kiwix.el +++ b/kiwix.el @@ -261,15 +261,22 @@ list and return a list result." (data (request-response-data (let ((inhibit-message t)) (request ajax-url - :type "GET" - :sync t - :headers '(("Content-Type" . "application/json")) - :parser #'json-read - :success (cl-function - (lambda (&key data &allow-other-keys) - data))))))) + :type "GET" + :sync t + :headers '(("Content-Type" . "application/json")) + :parser #'json-read + :success (cl-function + (lambda (&key data &allow-other-keys) + data))))))) (if (vectorp data) (mapcar 'cdar data))))) +(defun kiwix--get-thing-at-point () + "Get region select text or symbol at point." + (if mark-active + (buffer-substring + (region-beginning) (region-end)) + (thing-at-point 'symbol))) + ;;;###autoload (defun kiwix-at-point () "Search for the symbol at point with `kiwix-query'." @@ -287,7 +294,7 @@ list and return a list result." `(lambda (input) (apply 'kiwix-ajax-search-hints input `(,kiwix--selected-library)))) - :input (word-at-point) + :input (kiwix--get-thing-at-point) :buffer "*helm kiwix completion candidates*")) ('ivy (ivy-read "Kiwix related entries: " @@ -296,10 +303,7 @@ list and return a list result." input `(,kiwix--selected-library))) :predicate nil :require-match nil - :initial-input (if mark-active - (buffer-substring - (region-beginning) (region-end)) - (thing-at-point 'symbol)) + :initial-input (kiwix--get-thing-at-point) :preselect nil :def nil :history nil