[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/jinx 4b3c81895d 2/2: Extract jinx--correct-setup
From: |
ELPA Syncer |
Subject: |
[elpa] externals/jinx 4b3c81895d 2/2: Extract jinx--correct-setup |
Date: |
Tue, 18 Apr 2023 04:59:03 -0400 (EDT) |
branch: externals/jinx
commit 4b3c81895d11952d347021d94bd13d40cb7a52ee
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Extract jinx--correct-setup
---
jinx.el | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/jinx.el b/jinx.el
index 028c148be1..a131b4065d 100644
--- a/jinx.el
+++ b/jinx.el
@@ -614,6 +614,20 @@ If VISIBLE is non-nil, only include visible overlays."
(insert word)
(exit-minibuffer))))
+(defun jinx--correct-setup ()
+ "Setup minibuffer for correction."
+ (let ((message-log-max nil)
+ (inhibit-message t)
+ (map (define-keymap :parent (current-local-map)
+ "SPC" #'self-insert-command)))
+ (dotimes (i 9)
+ (define-key map (vector (+ ?1 i)) #'jinx--correct-select))
+ (use-local-map map)
+ (when (and (eq completing-read-function #'completing-read-default)
+ (not (bound-and-true-p vertico-mode))
+ (not (bound-and-true-p icomplete-mode)))
+ (minibuffer-completion-help))))
+
(defun jinx--correct (overlay &optional recenter info)
"Correct word at OVERLAY with optional RECENTER and prompt INFO."
(let* ((word (buffer-substring-no-properties
@@ -622,21 +636,11 @@ If VISIBLE is non-nil, only include visible overlays."
(jinx--with-highlight overlay recenter
(lambda ()
(minibuffer-with-setup-hook
- (lambda ()
- (let ((message-log-max nil)
- (inhibit-message t)
- (map (define-keymap :parent (current-local-map)
- "SPC" #'self-insert-command)))
- (dotimes (i 9)
- (define-key map (vector (+ ?1 i))
#'jinx--correct-select))
- (use-local-map map)
- (when (and (eq completing-read-function
#'completing-read-default)
- (not (bound-and-true-p vertico-mode))
- (not (bound-and-true-p icomplete-mode)))
- (minibuffer-completion-help))))
- (or (completing-read (format "Correct ā%sā%s: " word (or info
""))
- (jinx--suggestion-table word)
- nil nil nil t word)
+ #'jinx--correct-setup
+ (or (completing-read
+ (format "Correct ā%sā%s: " word (or info ""))
+ (jinx--suggestion-table word)
+ nil nil nil t word)
word))))))
(if (string-match-p "\\`[@#*]" selected)
(let* ((new-word (replace-regexp-in-string "\\`[@#*]+" "" selected))