SavchenkoValeriy / emacs-powerthesaurus

Powerthesaurus integration for Emacs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simplified two commands into one: powerthesaurus-lookup-word-region-or-thing-at-point-or-ask

sewkokot opened this issue · comments

I wrote a command which combines the two commands:
powerthesaurus-lookup-word and powerthesaurus-lookup-word-at-point into one. This way I can bind it to one key instead of two. Perhaps it can be implemented directly in the library?

(defun powerthesaurus-lookup-word-region-or-thing-at-point-or-ask ()
  "Wrapper function for powerthesaurus-lookup-word commands.

If a region is selected use powerthesaurus-lookup-word
if a thing at point is not empty use powerthesaurus-lookup-word-at-point
otherwise as for word using powerthesaurus-lookup-word"
  (interactive)
  (let (beg end bounds)
	(if (use-region-p)
		(progn
		  (setq beg (region-beginning))
		  (setq end (region-end))
		  (powerthesaurus-lookup-word beg end))
	  (if (thing-at-point 'word)
		  (powerthesaurus-lookup-word-at-point (point))
		(powerthesaurus-lookup-word)))))

Hello.
Sorry for such a late reaction, somehow I overlooked the notification.
I like your idea, the only thing I changed is the name. Now it's a DWIM function.
Thank you!