counsel-web icon indicating copy to clipboard operation
counsel-web copied to clipboard

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

Open zed opened this issue 3 years ago • 2 comments

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.

zed avatar Dec 07 '21 10:12 zed

Great suggestion! Would you like to send a PR?

mnewt avatar Dec 08 '21 23:12 mnewt

Would you like to send a PR?

No, please, use the snippet anyway you like.

zed avatar Dec 13 '21 17:12 zed