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

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

[elpa] externals/cape b1f57d79ba 009/146: Improve ispell


From: ELPA Syncer
Subject: [elpa] externals/cape b1f57d79ba 009/146: Improve ispell
Date: Sun, 9 Jan 2022 20:57:38 -0500 (EST)

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

    Improve ispell
---
 cape.el | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/cape.el b/cape.el
index 33ee2918ee..90447354b0 100644
--- a/cape.el
+++ b/cape.el
@@ -343,30 +343,36 @@
              (unless (string-match-p "\n" (buffer-substring beg end))
                `(,beg ,end ,words :exclusive no 
,@cape--dabbrev-properties)))))))))
 
-(autoload 'ispell-lookup-words "ispell")
 
 (defvar cape--ispell-properties
   (list :annotation-function (lambda (_) " Ispell")
         :company-kind (lambda (_) 'text)))
 
+(autoload 'ispell-lookup-words "ispell")
+(defun cape--ispell-words (bounds)
+  "Return words from Ispell which match the string within BOUNDS."
+  (with-demoted-errors
+      (let ((message-log-max nil)
+            (inhibit-message t))
+        (ispell-lookup-words
+         (format "*%s*" (buffer-substring-no-properties
+                         (car bounds) (cdr bounds)))))))
+
 ;;;###autoload
 (defun cape-ispell-capf ()
   "Ispell completion-at-point-function."
   (when-let* ((bounds (bounds-of-thing-at-point 'word))
-              (table (with-demoted-errors
-                         (let ((message-log-max nil)
-                               (inhibit-message t))
-                           (ispell-lookup-words
-                            (format "*%s*"
-                                    (buffer-substring-no-properties (car 
bounds) (cdr bounds))))))))
+              (table (cape--ispell-words bounds)))
     `(,(car bounds) ,(cdr bounds) ,table :exclusive no 
,@cape--ispell-properties)))
 
 ;;;###autoload
 (defun cape-ispell ()
   "Complete with Ispell at point."
   (interactive)
-  (let ((completion-at-point-functions (list #'cape-ispell-capf)))
-    (completion-at-point)))
+  (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)))))
 
 (defvar cape--dict-properties
   (list :annotation-function (lambda (_) " Dict")



reply via email to

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