From 7df610ba70be4349db418c901af33fdf126997bb Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 17 Mar 2024 14:06:58 +0100 Subject: condition case for lingva translations --- lisp/mastodon-toot.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 47bda3f..062eaf0 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -549,16 +549,18 @@ base toot." "Translate text of toot at point. Uses `lingva.el'." (interactive) - (if (not (require 'lingva nil :no-error)) - (message "Looks like you need to install lingva.el first.") - (if mastodon-tl--buffer-spec - (if-let ((toot (mastodon-tl--property 'item-json))) - (lingva-translate nil - (mastodon-tl--content toot) - (when mastodon-tl--enable-proportional-fonts - t)) - (message "No toot to translate?")) - (message "No mastodon buffer?")))) + (if mastodon-tl--buffer-spec + (if-let ((toot (mastodon-tl--property 'item-json))) + (condition-case x + (lingva-translate nil + (mastodon-tl--content toot) + (when mastodon-tl--enable-proportional-fonts + t)) + (void-function + (message "Looks like you need to install lingva.el. Error: %s" + (error-message-string x)))) + (message "No toot to translate?")) + (message "No mastodon buffer?"))) (defun mastodon-toot--own-toot-p (toot) "Check if TOOT is user's own, for deleting, editing, or pinning it." -- cgit v1.2.3