tools/lookup: fix missing libs for dictionary/thesaurus lookup

This commit is contained in:
Henrik Lissner 2019-12-24 21:24:06 -05:00
parent 55f0be7074
commit d00a0af925
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -335,7 +335,7 @@ Otherwise, falls back on `find-file-at-point'."
current-prefix-arg)) current-prefix-arg))
(unless (featurep! +dictionary) (unless (featurep! +dictionary)
(user-error "The +dictionary feature hasn't be enabled on :tools lookup module")) (user-error "The +dictionary feature hasn't be enabled on :tools lookup module"))
(cond (IS-MAC (cond ((and IS-MAC (require 'osx-dictionary nil t))
(osx-dictionary--view-result identifier)) (osx-dictionary--view-result identifier))
(+lookup-dictionary-enable-online (+lookup-dictionary-enable-online
(define-word identifier nil arg)) (define-word identifier nil arg))
@ -350,7 +350,11 @@ Otherwise, falls back on `find-file-at-point'."
current-prefix-arg)) current-prefix-arg))
(unless (featurep! +dictionary) (unless (featurep! +dictionary)
(user-error "The +dictionary feature hasn't be enabled on :tools lookup module")) (user-error "The +dictionary feature hasn't be enabled on :tools lookup module"))
(if +lookup-dictionary-enable-online (unless +lookup-dictionary-enable-online
;; TODO Implement offline synonyms backend
(user-error "No offline dictionary implemented yet"))
(require 'request)
(require 'powerthesaurus)
(request (request
(powerthesaurus-compose-url identifier) (powerthesaurus-compose-url identifier)
:parser (lambda () (libxml-parse-html-region (point) (point-max))) :parser (lambda () (libxml-parse-html-region (point) (point-max)))
@ -363,6 +367,4 @@ Otherwise, falls back on `find-file-at-point'."
(funcall (powerthesaurus-choose-callback (funcall (powerthesaurus-choose-callback
(region-beginning) (region-end)) (region-beginning) (region-end))
(powerthesaurus-pick-synonym data) (powerthesaurus-pick-synonym data)
identifier))))) identifier))))))
;; TODO Implement offline synonyms backend
(user-error "No offline dictionary implemented yet")))