[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape c7feeee10b 080/146: Simplify
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape c7feeee10b 080/146: Simplify |
Date: |
Sun, 9 Jan 2022 20:57:44 -0500 (EST) |
branch: externals/cape
commit c7feeee10b981f93b7836e01cd6710a6dfd94e64
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Simplify
---
cape.el | 83 +++++++++++++++++++++++++++++++----------------------------------
1 file changed, 40 insertions(+), 43 deletions(-)
diff --git a/cape.el b/cape.el
index d221ecc3c8..72a6d4f5d0 100644
--- a/cape.el
+++ b/cape.el
@@ -347,24 +347,20 @@ The CMP argument determines how the new input is compared
to the old input.
('equal (equal old-input new-input))
('substring (string-match-p (regexp-quote old-input) new-input)))))
-(cl-defun cape--cached-table (beg end fun &key valid category (sort t))
+(defun cape--cached-table (beg end fun valid)
"Create caching completion table.
BEG and END are the input bounds.
FUN is the function which computes the candidates.
-VALID is the input comparator, see `cape--input-valid-p'.
-CATEGORY is the optional completion category.
-SORT should be nil to disable sorting."
+VALID is the input comparator, see `cape--input-valid-p'."
(let ((input 'init)
(beg (copy-marker beg))
(end (copy-marker end t))
(table nil))
- (cape--table-with-properties
- (lambda (str pred action)
- (let ((new-input (buffer-substring-no-properties beg end)))
- (when (or (eq input 'init) (not (cape--input-valid-p input new-input
valid)))
- (setq table (funcall fun new-input) input new-input)))
- (complete-with-action action table str pred))
- :category category :sort sort)))
+ (lambda (str pred action)
+ (let ((new-input (buffer-substring-no-properties beg end)))
+ (when (or (eq input 'init) (not (cape--input-valid-p input new-input
valid)))
+ (setq table (funcall fun new-input) input new-input)))
+ (complete-with-action action table str pred))))
(defvar cape--file-properties
(list :annotation-function (lambda (s) (if (string-suffix-p "/" s) " Folder"
" File"))
@@ -455,13 +451,15 @@ If INTERACTIVE is nil the function acts like a capf."
(setq end (point)))
(if interactive
(cape--complete beg end
- (cape--cached-table beg end
#'cape--dabbrev-expansions
- :valid 'prefix :category
'cape-dabbrev)
+ (cape--table-with-properties
+ (cape--cached-table beg end
#'cape--dabbrev-expansions 'prefix)
+ :category 'cape-dabbrev)
cape--dabbrev-properties)
`(,beg ,end
;; Use equal check, since candidates must be longer than
cape-dabbrev-min-length
- ,(cape--cached-table beg end #'cape--dabbrev-limited-expansions
- :valid 'equal :category 'cape-dabbrev)
+ ,(cape--table-with-properties
+ (cape--cached-table beg end
#'cape--dabbrev-limited-expansions 'equal)
+ :category 'cape-dabbrev)
:exclusive no ,@cape--dabbrev-properties)))
(interactive (user-error "No expansion")))))
@@ -497,8 +495,9 @@ If INTERACTIVE is nil the function acts like a capf."
(defun cape--ispell-table (bounds)
"Return completion table for Ispell completion between BOUNDS."
- (cape--cached-table (car bounds) (cdr bounds) #'cape--ispell-words
- :valid 'substring :category 'cape-ispell))
+ (cape--table-with-properties
+ (cape--cached-table (car bounds) (cdr bounds) #'cape--ispell-words
'substring)
+ :category 'cape-ispell))
;;;###autoload
(defun cape-ispell (&optional interactive)
@@ -630,24 +629,21 @@ If INTERACTIVE is nil the function acts like a capf."
(setq prefix-len (max prefix-len plen)))))))
(setq tables (nreverse tables))
(list beg end
- (lambda (str pred action)
- (if (eq action 'metadata)
- '(metadata
- (category . cape-super)
- (display-sort-function . identity)
- (cycle-sort-function . identity))
- (when (eq candidates 'init)
- (clrhash ht)
- (setq candidates
- (cl-loop for (table . plist) in tables nconc
- (let* ((pred (plist-get plist :predicate))
- (metadata (completion-metadata ""
table pred))
- (sort (or (completion-metadata-get
metadata 'display-sort-function)
- #'identity))
- (cands (funcall sort
(all-completions "" table pred))))
- (cl-loop for cand in cands do (puthash
cand plist ht))
- cands))))
- (complete-with-action action candidates str pred)))
+ (cape--table-with-properties
+ (lambda (str pred action)
+ (when (eq candidates 'init)
+ (clrhash ht)
+ (setq candidates
+ (cl-loop for (table . plist) in tables nconc
+ (let* ((pred (plist-get plist :predicate))
+ (metadata (completion-metadata ""
table pred))
+ (sort (or (completion-metadata-get
metadata 'display-sort-function)
+ #'identity))
+ (cands (funcall sort (all-completions
"" table pred))))
+ (cl-loop for cand in cands do (puthash
cand plist ht))
+ cands))))
+ (complete-with-action action candidates str pred))
+ :sort nil :category 'cape-super)
:exclusive 'no
:company-prefix-length prefix-len
:company-doc-buffer (cape--super-function ht :company-doc-buffer)
@@ -693,14 +689,15 @@ This feature is experimental."
;; remembered result the next time the capf is called.
(let* ((end (point)) (beg (- end (length initial-input))))
(list beg end
- (cape--cached-table beg end
- (if (cape--company-call backend
'duplicates)
- (lambda (input)
- (delete-dups (cape--company-call
backend 'candidates input)))
- (apply-partially #'cape--company-call
backend 'candidates))
- :category backend
- :valid (if (cape--company-call backend
'no-cache initial-input) 'never valid)
- :sort (not (cape--company-call backend
'sorted)))
+ (cape--table-with-properties
+ (cape--cached-table beg end
+ (if (cape--company-call backend
'duplicates)
+ (lambda (input)
+ (delete-dups (cape--company-call
backend 'candidates input)))
+ (apply-partially #'cape--company-call
backend 'candidates))
+ (if (cape--company-call backend 'no-cache
initial-input) 'never valid))
+ :category backend
+ :sort (not (cape--company-call backend 'sorted)))
:exclusive 'no
:company-prefix-length (cdr-safe prefix)
:company-doc-buffer (lambda (x) (cape--company-call backend
'doc-buffer x))
- [elpa] externals/cape 8a2cc4c7bb 060/146: Add completion categories, (continued)
- [elpa] externals/cape 8a2cc4c7bb 060/146: Add completion categories, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 496bb4a5e4 065/146: Rename function, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ba85197981 075/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 202345e954 083/146: cape-capf-with-properties: Add support for :sort and :category, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 15491cef1a 087/146: Add link to Emacs, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 659f710682 089/146: Add comment, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ceca3a3d06 077/146: Expand readme, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c57b01e982 091/146: Improve dynamic table support of cape-super-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 7008958b02 078/146: Minor corrections, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 9e4651649b 094/146: Treat company backends as non-interruptible., ELPA Syncer, 2022/01/09
- [elpa] externals/cape c7feeee10b 080/146: Simplify,
ELPA Syncer <=
- [elpa] externals/cape 02c9629bc6 081/146: Refactor and simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d3d9d926ac 082/146: Add cape-interactive-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3c44bff1f6 095/146: Minor refactoring, ELPA Syncer, 2022/01/09
- [elpa] externals/cape e341f81a79 098/146: README: Add emoji example, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b06e3271e0 099/146: README: Be more precise about supported completion tables, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b612af5754 101/146: Capf query should always be interruptible, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 15279b57fa 103/146: Remove todo, ELPA Syncer, 2022/01/09
- [elpa] externals/cape dcb5a139c4 105/146: Add cape-capf-with-case-fold, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 4cd6cdd4a2 106/146: Respect ignore-case for company backends, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b8776afc9f 107/146: Add cape-dabbrev-check-other-buffers, ELPA Syncer, 2022/01/09