emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/cape b5485b8878 031/146: cape-ispell-capf: Compute cand


From: ELPA Syncer
Subject: [elpa] externals/cape b5485b8878 031/146: cape-ispell-capf: Compute candidates later
Date: Sun, 9 Jan 2022 20:57:40 -0500 (EST)

branch: externals/cape
commit b5485b887878493ceeeab7e0ab5f9277295839db
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    cape-ispell-capf: Compute candidates later
---
 cape.el | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/cape.el b/cape.el
index 4c6dec0980..0af2f6ea42 100644
--- a/cape.el
+++ b/cape.el
@@ -386,31 +386,35 @@
         :company-kind (lambda (_) 'text)))
 
 (declare-function ispell-lookup-words "ispell")
-(defun cape--ispell-words (bounds)
-  "Return words from Ispell which match the string within BOUNDS."
+(defun cape--ispell-words (str)
+  "Return words from Ispell which match STR."
   (require 'ispell)
   (with-demoted-errors
       (let ((message-log-max nil)
             (inhibit-message t))
-        (ispell-lookup-words
-         (format "*%s*" (buffer-substring-no-properties
-                         (car bounds) (cdr bounds)))))))
+        (ispell-lookup-words (format "*%s*" str)))))
 
 ;;;###autoload
 (defun cape-ispell-capf ()
   "Ispell completion-at-point-function."
-  (when-let* ((bounds (bounds-of-thing-at-point 'word))
-              (table (cape--ispell-words bounds)))
-    `(,(car bounds) ,(cdr bounds) ,table :exclusive no 
,@cape--ispell-properties)))
+  (when-let (bounds (bounds-of-thing-at-point 'word))
+    (let ((input (buffer-substring-no-properties (car bounds) (cdr bounds)))
+          (words nil))
+      `(,(car bounds) ,(cdr bounds)
+        ,(lambda (str pred action)
+           (complete-with-action
+            action (or words (setq words (cape--ispell-words input))) str 
pred))
+        :exclusive no
+        ,@cape--ispell-properties))))
 
 ;;;###autoload
 (defun cape-ispell ()
   "Complete with Ispell at point."
   (interactive)
-  (let ((bounds (or (bounds-of-thing-at-point 'word) (cons (point) (point))))
-        (completion-extra-properties cape--ispell-properties))
-    (when-let (table (cape--ispell-words bounds))
-      (completion-in-region (car bounds) (cdr bounds) (cape--ispell-words 
bounds)))))
+  (let* ((bounds (or (bounds-of-thing-at-point 'word) (cons (point) (point))))
+         (input (buffer-substring-no-properties (car bounds) (cdr bounds)))
+         (completion-extra-properties cape--ispell-properties))
+    (completion-in-region (car bounds) (cdr bounds) (cape--ispell-words 
input))))
 
 (defvar cape--dict-properties
   (list :annotation-function (lambda (_) " Dict")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]