Replies: 2 comments 1 reply
-
I couldn't do any better than making "a custom" version that simply replaces (defun jinx--autocorrect-overlay (overlay &optional info)
"Auto correct word at OVERLAY, maybe show prompt INFO."
(catch 'jinx--goto
(let* ((word (buffer-substring-no-properties
(overlay-start overlay) (overlay-end overlay)))
(choice
(jinx--correct-highlight overlay
(lambda ()
(when (or (< (point) (window-start)) (> (point) (window-end nil t)))
(recenter))
(car (jinx--correct-suggestions word)))))
(len (length choice)))
(pcase (and (> len 0) (assq (aref choice 0) jinx--save-keys))
(`(,key . ,fun)
(funcall fun 'save key (if (> len 1) (substring choice 1) word))
(jinx--recheck-overlays))
((guard (not (equal choice word)))
(jinx--correct-replace overlay choice)))
nil)))
;;;###autoload
(defun jinx-autocorrect-nearest+ ()
"Auto-correct nearest misspelled word.
A dirty hack until there's a solution for https:/minad/jinx/issues/100"
(interactive "*")
(save-excursion
(jinx--correct-guard
(let* ((overlays (jinx--force-overlays (window-start) (window-end) :visible t))
(count (length overlays))
(idx 0))
;; Not using `while-let' is intentional here.
(while (when-let ((ov (nth idx overlays)))
(if (overlay-buffer ov)
(when-let ((skip (jinx--autocorrect-overlay ov)))
(setq idx (mod (+ idx skip) count)))
(cl-incf idx)))))))) |
Beta Was this translation helpful? Give feedback.
0 replies
-
There has been the proposal #30 a while ago. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Would it be possible to add such a function? I thought I could simply add a version of
jinx-correct-nearest
that simply picks the first element from the list, but I couldn't figure that out.Also, it would be nice if by default
RET
always picked the first suggestion injinx-correct
selection. I tried bindingRET
to(execute-kbd-macro (kbd "1"))
for that, but that unfortunately broke@
&*
(adding word to the dictionary).Beta Was this translation helpful? Give feedback.
All reactions