From 1476cdcb68a10ea33850649cc4b5e9c86d82159c Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Wed, 24 Aug 2022 22:40:03 +0300 Subject: [PATCH] feat: ignore errors --- reverso.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/reverso.el b/reverso.el index 35bbc0a..e5e945e 100644 --- a/reverso.el +++ b/reverso.el @@ -998,6 +998,16 @@ alist as defined in `reverso--get-grammar'." if (overlay-get ov 'reverso-correction) return (cons ov (overlay-get ov 'reverso-correction)))) +(defun reverso-check-ignore-error () + "Remove error at point." + (interactive) + (let ((err (reverso--get-error-at-point))) + (unless err + (user-error "No error at point!")) + (delete-overlay (car err)) + (when transient-current-command + (reverso-check-next-error)))) + (defun reverso-describe-error-at-point () "Describe reverso-error at point." (interactive) @@ -1013,6 +1023,8 @@ alist as defined in `reverso--get-grammar'." (let ((err (reverso--get-error-at-point))) (unless err (user-error "No error at point!")) + (unless (alist-get :suggestions (cdr err)) + (user-error "No suggestions!")) (let ((correction (completing-read "Fix: " @@ -1035,7 +1047,7 @@ alist as defined in `reverso--get-grammar'." If a region is active, restrict the action to that region. LANGUAGE is a language from the `reverso--languages' list. -REGION-START and REGION-END are borders of the region. +REGION-START and REGION-END are the borders of the region. If STRING-JOIN is non-nil, remove linebreaks from the string." (interactive (append @@ -1068,7 +1080,7 @@ If STRING-JOIN is non-nil, remove linebreaks from the string." "Whether to use the current buffer as input. That parameter is normally set by the prefix argument, but as it -doesn't pesist between parent and child invocations, this variable is +doesn't persist between parent and child invocations, this variable is used instead.") (cl-defmethod transient-init-value ((obj reverso--transient-input)) @@ -1524,6 +1536,7 @@ region. Otherwise, use the entire buffer." ["Errors" :class transient-row ("f" "Fix error" reverso--check-fix-at-point-transient) + ("i" "Ignore error" reverso-check-ignore-error :transient t) ("p" "Previous error" reverso-check-prev-error :transient t) ("P" "First error" reverso-check-first-error :transient t) ("n" "Next error" reverso-check-next-error :transient t)