mnewt / counsel-web

Search the Web using Ivy
GNU General Public License v3.0
33 stars 2 forks source link

Use current (under cursor) word as the initial input for a web search with suggestions #4

Open zed opened 2 years ago

zed commented 2 years ago

To start a web search suggesting a thing at point initially, I've defined counsel-web-suggest-thing-at-point (analogously to counsel-web-thing-at-point):

(use-package counsel-web
  :commands (counsel-web-suggest counsel-web-search counsel-web-thing-at-point)
  :bind
  ("C-c s" . counsel-web-suggest-thing-at-point)
  :custom
  (counsel-web-engine 'google)
  :config
  ;; start web search suggesting a thing at point
  (defun counsel-web-suggest-thing-at-point (thing)
    "Use THING as the initial input for counsel-web-suggest"
    (interactive (list (thing-at-point counsel-web-thing)))
    (counsel-web-suggest thing)))

counsel-web-suggest-thing-at-point could be included into the package and/or mentioned in the README.

mnewt commented 2 years ago

Great suggestion! Would you like to send a PR?

zed commented 2 years ago

Would you like to send a PR?

No, please, use the snippet anyway you like.