summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.org1
-rw-r--r--README.org7
-rw-r--r--cape.el65
3 files changed, 30 insertions, 43 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org
index a394aea..c894a73 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -8,6 +8,7 @@
VALID must be a function taking two arguments, the old and new input. It
should return nil if the input must be considered invalid such that the
candidates must be recomputed.
+- =cape-ispell=: Deprecate in favor of =cape-dict=.
* Version 0.13 (2023-02-15)
diff --git a/README.org b/README.org
index a760ac6..085edba 100644
--- a/README.org
+++ b/README.org
@@ -43,7 +43,6 @@ advantage of Company backends even if you are not using Company as frontend.
+ ~cape-keyword~: Complete programming language keyword
+ ~cape-symbol~: Complete Elisp symbol
+ ~cape-abbrev~: Complete abbreviation (~add-global-abbrev~, ~add-mode-abbrev~)
-+ ~cape-ispell~: Complete word from Ispell dictionary
+ ~cape-dict~: Complete word from dictionary file
+ ~cape-line~: Complete entire line from current buffer
+ ~cape-tex~: Complete Unicode char from TeX command, e.g. ~\hbar~.
@@ -75,7 +74,6 @@ could be upstreamed into Emacs itself.
("C-c p k" . cape-keyword)
("C-c p s" . cape-symbol)
("C-c p a" . cape-abbrev)
- ("C-c p i" . cape-ispell)
("C-c p l" . cape-line)
("C-c p w" . cape-dict)
("C-c p \\" . cape-tex)
@@ -93,7 +91,6 @@ could be upstreamed into Emacs itself.
;;(add-to-list 'completion-at-point-functions #'cape-sgml)
;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
- ;;(add-to-list 'completion-at-point-functions #'cape-ispell)
;;(add-to-list 'completion-at-point-functions #'cape-dict)
;;(add-to-list 'completion-at-point-functions #'cape-symbol)
;;(add-to-list 'completion-at-point-functions #'cape-line)
@@ -184,8 +181,8 @@ Completion table merging works only for tables which are sufficiently
well-behaved and tables which do not define completion boundaries.
~cape-super-capf~ has the same restrictions as ~completion-table-merge~ and
~completion-table-in-turn~. As a simple rule of thumb, ~cape-super-capf~ works only
-well for static completion functions like ~cape-dabbrev~, ~cape-keyword~,
-~cape-ispell~, etc., but not for complex multi-step completions like ~cape-file~.
+well for static completion functions like ~cape-dabbrev~, ~cape-keyword~, ~cape-dict~,
+etc., but not for complex multi-step completions like ~cape-file~.
#+begin_src emacs-lisp
;; Merge the dabbrev, dict and keyword capfs, display candidates together.
diff --git a/cape.el b/cape.el
index 7f566e3..f6d4e67 100644
--- a/cape.el
+++ b/cape.el
@@ -35,7 +35,6 @@
;; cape-keyword: Complete programming language keyword
;; cape-symbol: Complete Elisp symbol
;; cape-abbrev: Complete abbreviation (add-global-abbrev, add-mode-abbrev)
-;; cape-ispell: Complete word from Ispell dictionary
;; cape-dict: Complete word from dictionary file
;; cape-line: Complete entire line from file
;; cape-tex: Complete Unicode char from TeX command, e.g. \hbar.
@@ -67,6 +66,14 @@
"Dictionary word list file."
:type 'string)
+(defcustom cape-dict-grep t
+ "Use grep to search through `cape-dict-file'.
+If this variable is non-nil, the dictionary will be searched with
+grep in a separate process. Otherwise the whole dictionary will
+be loaded into Emacs. Depending on the size of your dictionary
+one or the other approach is preferable."
+ :type 'boolean)
+
(defcustom cape-dabbrev-min-length 4
"Minimum length of dabbrev expansions.
This setting ensures that words which are too short
@@ -391,37 +398,6 @@ See the user options `cape-dabbrev-min-length' and
for w in (dabbrev--find-all-expansions word (dabbrev--ignore-case-p word))
if (>= (length w) min-len) collect w)))
-;;;;; cape-ispell
-
-(defvar cape--ispell-properties
- (list :annotation-function (lambda (_) " Ispell")
- :company-kind (lambda (_) 'text)
- :exclusive 'no)
- "Completion extra properties for `cape-ispell'.")
-
-(declare-function ispell-lookup-words "ispell")
-(defun cape--ispell-words (str)
- "Return all words from Ispell matching STR."
- (with-demoted-errors "Ispell Error: %S"
- (require 'ispell)
- (cape--silent (ispell-lookup-words (format "*%s*" str)))))
-
-;;;###autoload
-(defun cape-ispell (&optional interactive)
- "Complete word at point with Ispell.
-If INTERACTIVE is nil the function acts like a Capf."
- (interactive (list t))
- (if interactive
- (cape-interactive #'cape-ispell)
- (let ((bounds (cape--bounds 'word)))
- `(,(car bounds) ,(cdr bounds)
- ,(cape--table-with-properties
- (cape--cached-table (car bounds) (cdr bounds)
- #'cape--ispell-words
- #'string-search)
- :category 'cape-ispell)
- ,@cape--ispell-properties))))
-
;;;;; cape-dict
(defvar cape--dict-properties
@@ -430,11 +406,16 @@ If INTERACTIVE is nil the function acts like a Capf."
:exclusive 'no)
"Completion extra properties for `cape-dict'.")
-(defvar cape--dict-words nil)
-(defun cape--dict-words ()
- "Dictionary words."
- (or cape--dict-words
- (setq cape--dict-words
+(defun cape--dict-grep-words (str)
+ "Return all words from `cape-dict-file' matching STR."
+ (unless (equal str "")
+ (process-lines-ignore-status "grep" "-Fi" str cape-dict-file)))
+
+(defvar cape--dict-all-words nil)
+(defun cape--dict-all-words ()
+ "Load all words from `cape-dict-file'."
+ (or cape--dict-all-words
+ (setq cape--dict-all-words
(split-string (with-temp-buffer
(insert-file-contents cape-dict-file)
(buffer-string))
@@ -450,9 +431,17 @@ If INTERACTIVE is nil the function acts like a Capf."
(cape-interactive #'cape-dict)
(let ((bounds (cape--bounds 'word)))
`(,(car bounds) ,(cdr bounds)
- ,(cape--table-with-properties (cape--dict-words) :category 'cape-dict)
+ ,(cape--table-with-properties
+ (if cape-dict-grep
+ (cape--cached-table (car bounds) (cdr bounds)
+ #'cape--dict-grep-words
+ #'string-search)
+ (cape--dict-all-words))
+ :category 'cape-dict)
,@cape--dict-properties))))
+(define-obsolete-function-alias 'cape-ispell 'cape-dict "0.13")
+
;;;;; cape-abbrev
(defun cape--abbrev-tables ()