[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 488cfd9ed7 086/146: Move code around
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 488cfd9ed7 086/146: Move code around |
Date: |
Sun, 9 Jan 2022 20:57:45 -0500 (EST) |
branch: externals/cape
commit 488cfd9ed7dbe1237abafd18530666df5dcef548
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Move code around
---
cape.el | 90 +++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 57 insertions(+), 33 deletions(-)
diff --git a/cape.el b/cape.el
index e2689a9f94..12735c1883 100644
--- a/cape.el
+++ b/cape.el
@@ -31,6 +31,8 @@
(eval-when-compile (require 'cl-lib))
+;;;; Customization
+
(defgroup cape nil
"Completion At Point Extensions."
:group 'convenience
@@ -305,6 +307,8 @@
"Alist of major modes and keywords."
:type 'alist)
+;;;; Helpers
+
(defmacro cape--silent (&rest body)
"Silence BODY."
`(cl-letf ((inhibit-message t)
@@ -373,6 +377,10 @@ VALID is the input comparator, see `cape--input-valid-p'."
input new-input)))
(complete-with-action action table str pred))))
+;;;; Capfs
+
+;;;;; cape-file
+
(defvar cape--file-properties
(list :annotation-function (lambda (s) (if (string-suffix-p "/" s) " Folder"
" File"))
:company-kind (lambda (s) (if (string-suffix-p "/" s) 'folder 'file)))
@@ -394,6 +402,8 @@ If INTERACTIVE is nil the function acts like a capf."
:company-prefix-length ,(and (not (equal file "/")) (string-suffix-p
"/" file))
:exclusive no ,@cape--file-properties)))))
+;;;;; cape-symbol
+
(defvar cape--symbol-properties
(list :annotation-function #'cape--symbol-annotation
:company-kind #'cape--symbol-kind)
@@ -433,6 +443,8 @@ If INTERACTIVE is nil the function acts like a capf."
,(cape--table-with-properties obarray :category 'symbol)
:exclusive no ,@cape--symbol-properties))))
+;;;;; cape-dabbrev
+
(defvar cape--dabbrev-properties
(list :annotation-function (lambda (_) " Dabbrev")
:company-kind (lambda (_) 'text))
@@ -485,6 +497,8 @@ If INTERACTIVE is nil the function acts like a capf."
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))
@@ -511,6 +525,8 @@ If INTERACTIVE is nil the function acts like a capf."
:category 'cape-ispell)
:exclusive no ,@cape--ispell-properties))))
+;;;;; cape-dict
+
(defvar cape--dict-properties
(list :annotation-function (lambda (_) " Dict")
:company-kind (lambda (_) 'text))
@@ -538,6 +554,8 @@ If INTERACTIVE is nil the function acts like a capf."
,(cape--table-with-properties (cape--dict-words) :category 'cape-dict)
:exclusive no ,@cape--dict-properties))))
+;;;;; cape-abbrev
+
(defun cape--abbrev-list ()
"Abbreviation list."
(delete "" (nconc (all-completions "" global-abbrev-table)
@@ -571,6 +589,8 @@ If INTERACTIVE is nil the function acts like a capf."
,(cape--table-with-properties abbrevs :category 'cape-abbrev)
:exclusive no ,@cape--abbrev-properties)))))
+;;;;; cape-keyword
+
(defun cape--keyword-list ()
"Return keywords for current major mode."
(when-let (kw (alist-get major-mode cape-keywords))
@@ -594,6 +614,43 @@ If INTERACTIVE is nil the function acts like a capf."
,(cape--table-with-properties keywords :category 'cape-keyword)
:exclusive no ,@cape--keyword-properties)))))
+;;;;; cape-line
+
+(defvar cape--line-properties nil
+ "Completion extra properties for `cape-line'.")
+
+(defun cape--line-list ()
+ "Return all lines from buffer."
+ (let ((beg (point-min))
+ (max (point-max))
+ (pt (point))
+ (ht (make-hash-table :test #'equal))
+ end lines)
+ (save-excursion
+ (while (< beg max)
+ (goto-char beg)
+ (setq end (line-end-position))
+ (unless (<= beg pt end)
+ (let ((line (buffer-substring-no-properties beg end)))
+ (unless (or (string-blank-p line) (gethash line ht))
+ (puthash line t ht)
+ (push line lines))))
+ (setq beg (1+ end))))
+ (nreverse lines)))
+
+;;;###autoload
+(defun cape-line (&optional interactive)
+ "Complete current line from other lines in buffer.
+If INTERACTIVE is nil the function acts like a capf."
+ (interactive (list t))
+ (if interactive
+ (cape--interactive #'cape-line)
+ `(,(line-beginning-position) ,(point)
+ ,(cape--table-with-properties (cape--line-list) :sort nil)
+ ,@cape--line-properties)))
+
+;;;; Capf combinators
+
(defun cape--super-function (ht prop)
"Return merged function for PROP given HT."
(lambda (x)
@@ -726,39 +783,6 @@ VALID is the input comparator, see `cape--input-valid-p'."
(complete-with-action action table str pred)))
,@plist)))))
-(defvar cape--line-properties nil
- "Completion extra properties for `cape-line'.")
-
-(defun cape--line-list ()
- "Return all lines from buffer."
- (let ((beg (point-min))
- (max (point-max))
- (pt (point))
- (ht (make-hash-table :test #'equal))
- end lines)
- (save-excursion
- (while (< beg max)
- (goto-char beg)
- (setq end (line-end-position))
- (unless (<= beg pt end)
- (let ((line (buffer-substring-no-properties beg end)))
- (unless (or (string-blank-p line) (gethash line ht))
- (puthash line t ht)
- (push line lines))))
- (setq beg (1+ end))))
- (nreverse lines)))
-
-;;;###autoload
-(defun cape-line (&optional interactive)
- "Complete current line from other lines in buffer.
-If INTERACTIVE is nil the function acts like a capf."
- (interactive (list t))
- (if interactive
- (cape--interactive #'cape-line)
- `(,(line-beginning-position) ,(point)
- ,(cape--table-with-properties (cape--line-list) :sort nil)
- ,@cape--line-properties)))
-
;;;###autoload
(defun cape-capf-with-properties (capf &rest properties)
"Return a new CAPF with additional completion PROPERTIES.
- [elpa] externals/cape 9bd7bed258 029/146: cape-company-capf: Call the backend later in the completion process, (continued)
- [elpa] externals/cape 9bd7bed258 029/146: cape-company-capf: Call the backend later in the completion process, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 67c3b75e2a 039/146: Refactor dabbrev, simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 6e525cdfdd 040/146: Rework cape-company-to-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 6deb7d7a8b 044/146: Add docstrings, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3ad6aa105e 045/146: cape-company-to-capf: Simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 4a1f19af23 057/146: Fix super capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 26401bfa6a 069/146: Unify cape-abbrev and cape-abbrev-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d265a03e7f 074/146: cape-dabbrev: Make interactive, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3eb7efc2d4 050/146: README: Expand reasoning, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8cf2942881 085/146: Add comments regarding interruptible completion tables, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 488cfd9ed7 086/146: Move code around,
ELPA Syncer <=
- [elpa] externals/cape 2008d809b6 088/146: Add cape-capf-with-predicate, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 4b424150ef 090/146: cape-super-capf: Delete duplicates (Fix #13), ELPA Syncer, 2022/01/09
- [elpa] externals/cape da32e232d6 093/146: cape--company-call: Cheaper timeout checking, throw error, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c4d821d55b 079/146: Add cape--symbol-annotation, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 2ce63259d7 097/146: Update README - Asynchronous Company backends work as expected, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c1f7fa746b 104/146: Improve synchronization, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1d69a06890 117/146: cape-tex/cape-sgml: Add autoloads, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 7f11b354df 124/146: cape-company-capf: Remove symbol restriction, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a6db83b1bd 135/146: Improve repair function, ELPA Syncer, 2022/01/09
- [elpa] externals/cape f26e835929 131/146: README: Do not use hashed symbol, ELPA Syncer, 2022/01/09