[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape a8d00aa3ef 006/146: Add defcustoms
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape a8d00aa3ef 006/146: Add defcustoms |
Date: |
Sun, 9 Jan 2022 20:57:36 -0500 (EST) |
branch: externals/cape
commit a8d00aa3ef1fc803b9cb286fb862f3cfe070fb4b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add defcustoms
---
cape.el | 263 +++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 134 insertions(+), 129 deletions(-)
diff --git a/cape.el b/cape.el
index b697fddaf4..5305e2d3aa 100644
--- a/cape.el
+++ b/cape.el
@@ -31,136 +31,16 @@
(require 'dabbrev)
-(defun cape--complete-in-region (thing table &rest extra)
- "Complete THING at point given completion TABLE and EXTRA properties."
- (let ((bounds (or (bounds-of-thing-at-point thing) (cons (point) (point))))
- (completion-extra-properties extra))
- (completion-in-region (car bounds) (cdr bounds) table)))
-
-;;;###autoload
-(defun cape-file-capf ()
- "File name completion-at-point-function."
- (when-let (bounds (bounds-of-thing-at-point 'filename))
- (list (car bounds) (cdr bounds)
- #'read-file-name-internal
- :exclusive 'no
- :annotation-function (lambda (_) " File"))))
-
-;;;###autoload
-(defun cape-file ()
- "Complete file name at point."
- (interactive)
- (cape--complete-in-region 'filename #'read-file-name-internal))
-
-;;;###autoload
-(defun cape-dabbrev-capf ()
- "Dabbrev completion-at-point-function."
- (let ((dabbrev-check-all-buffers nil)
- (dabbrev-check-other-buffers nil))
- (dabbrev--reset-global-variables))
- (let ((abbrev (ignore-errors (dabbrev--abbrev-at-point))))
- (when (and abbrev (not (string-match-p "[ \t]" abbrev)))
- (pcase ;; Interruptible scanning
- (while-no-input
- (let ((inhibit-message t)
- (message-log-max nil))
- (or (dabbrev--find-all-expansions
- abbrev (dabbrev--ignore-case-p abbrev))
- t)))
- ('nil (keyboard-quit))
- ('t nil)
- (words
- ;; Ignore completions which are too short
- (let ((min-len (+ 4 (length abbrev))))
- (setq words (seq-remove (lambda (x) (< (length x) min-len)) words)))
- (when words
- (let ((beg (progn (search-backward abbrev) (point)))
- (end (progn (search-forward abbrev) (point))))
- (unless (string-match-p "\n" (buffer-substring beg end))
- (list beg end words
- :exclusive 'no
- :annotation-function (lambda (_) " Dabbrev"))))))))))
-
-(autoload 'ispell-lookup-words "ispell")
-
-;;;###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))))))))
- (list (car bounds) (cdr bounds) table
- :exclusive 'no
- :annotation-function (lambda (_) " Ispell"))))
-
-;;;###autoload
-(defun cape-ispell ()
- "Complete with Ispell at point."
- (interactive)
- (let ((completion-at-point-functions (list #'cape-ispell-capf)))
- (completion-at-point)))
-
-(defvar cape--dict-words nil
- "List of dictionary words.")
+(defgroup cape nil
+ "Completion At Point Extensions."
+ :group 'convenience
+ :prefix "cape-")
-(defvar cape--dict-file "/etc/dictionaries-common/words"
- "Dictionary word list file.")
-
-(defun cape--dict-words ()
- "Return list of dictionary words."
- (or cape--dict-words
- (setq cape--dict-words
- (split-string (with-temp-buffer
- (insert-file-contents-literally cape--dict-file)
- (buffer-string))
- "\n"))))
-
-;;;###autoload
-(defun cape-dict-capf ()
- "Dictionary completion-at-point-function."
- (when-let (bounds (bounds-of-thing-at-point 'word))
- (list (car bounds) (cdr bounds) (cape--dict-words)
- :exclusive 'no
- :annotation-function (lambda (_) " Dict"))))
-
-;;;###autoload
-(defun cape-dict ()
- "Complete word at point."
- (interactive)
- (cape--complete-in-region 'word (cape--dict-words)))
-
-(defun cape--abbrev-completions ()
- "Return all abbreviations."
- (delete "" (nconc (all-completions "" global-abbrev-table)
- (all-completions "" local-abbrev-table))))
-
-(defun cape--abbrev-expand (&rest _)
- "Expand abbreviation before point."
- (expand-abbrev))
-
-;;;###autoload
-(defun cape-abbrev-capf ()
- "Abbrev completion-at-point-function."
- (when-let ((bounds (bounds-of-thing-at-point 'symbol))
- (abbrevs (cape--abbrev-completions)))
- (list (car bounds) (cdr bounds) abbrevs
- :exclusive 'no
- :exit-function #'cape--abbrev-expand
- :annotation-function (lambda (_) " Abbrev"))))
-
-;;;###autoload
-(defun cape-abbrev ()
- "Complete abbreviation at point."
- (interactive)
- (cape--complete-in-region 'symbol (or (cape--abbrev-completions)
- (user-error "No abbreviations"))
- :exit-function #'cape--abbrev-expand))
+(defcustom cape-dict-file "/etc/dictionaries-common/words"
+ "Dictionary word list file."
+ :type 'string)
-(defvar cape-keywords
+(defcustom cape-keywords
;; Taken from company-keywords.el
;; Please contribute corrections or additions.
'((c++-mode ;; https://en.cppreference.com/w/cpp/keyword
@@ -406,7 +286,132 @@
(jde-mode java-mode)
(ess-julia-mode julia-mode)
(enh-ruby-mode ruby-mode))
- "Alist of major modes and keywords.")
+ "Alist of major modes and keywords."
+ :type 'alist)
+
+(defun cape--complete-in-region (thing table &rest extra)
+ "Complete THING at point given completion TABLE and EXTRA properties."
+ (let ((bounds (or (bounds-of-thing-at-point thing) (cons (point) (point))))
+ (completion-extra-properties extra))
+ (completion-in-region (car bounds) (cdr bounds) table)))
+
+;;;###autoload
+(defun cape-file-capf ()
+ "File name completion-at-point-function."
+ (when-let (bounds (bounds-of-thing-at-point 'filename))
+ (list (car bounds) (cdr bounds)
+ #'read-file-name-internal
+ :exclusive 'no
+ :annotation-function (lambda (_) " File"))))
+
+;;;###autoload
+(defun cape-file ()
+ "Complete file name at point."
+ (interactive)
+ (cape--complete-in-region 'filename #'read-file-name-internal))
+
+;;;###autoload
+(defun cape-dabbrev-capf ()
+ "Dabbrev completion-at-point-function."
+ (let ((dabbrev-check-all-buffers nil)
+ (dabbrev-check-other-buffers nil))
+ (dabbrev--reset-global-variables))
+ (let ((abbrev (ignore-errors (dabbrev--abbrev-at-point))))
+ (when (and abbrev (not (string-match-p "[ \t]" abbrev)))
+ (pcase ;; Interruptible scanning
+ (while-no-input
+ (let ((inhibit-message t)
+ (message-log-max nil))
+ (or (dabbrev--find-all-expansions
+ abbrev (dabbrev--ignore-case-p abbrev))
+ t)))
+ ('nil (keyboard-quit))
+ ('t nil)
+ (words
+ ;; Ignore completions which are too short
+ (let ((min-len (+ 4 (length abbrev))))
+ (setq words (seq-remove (lambda (x) (< (length x) min-len)) words)))
+ (when words
+ (let ((beg (progn (search-backward abbrev) (point)))
+ (end (progn (search-forward abbrev) (point))))
+ (unless (string-match-p "\n" (buffer-substring beg end))
+ (list beg end words
+ :exclusive 'no
+ :annotation-function (lambda (_) " Dabbrev"))))))))))
+
+(autoload 'ispell-lookup-words "ispell")
+
+;;;###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))))))))
+ (list (car bounds) (cdr bounds) table
+ :exclusive 'no
+ :annotation-function (lambda (_) " Ispell"))))
+
+;;;###autoload
+(defun cape-ispell ()
+ "Complete with Ispell at point."
+ (interactive)
+ (let ((completion-at-point-functions (list #'cape-ispell-capf)))
+ (completion-at-point)))
+
+(defvar cape--dict-words nil)
+(defun cape--dict-words ()
+ "Return list of dictionary words."
+ (or cape--dict-words
+ (setq cape--dict-words
+ (split-string (with-temp-buffer
+ (insert-file-contents-literally cape-dict-file)
+ (buffer-string))
+ "\n"))))
+
+;;;###autoload
+(defun cape-dict-capf ()
+ "Dictionary completion-at-point-function."
+ (when-let (bounds (bounds-of-thing-at-point 'word))
+ (list (car bounds) (cdr bounds) (cape--dict-words)
+ :exclusive 'no
+ :annotation-function (lambda (_) " Dict"))))
+
+;;;###autoload
+(defun cape-dict ()
+ "Complete word at point."
+ (interactive)
+ (cape--complete-in-region 'word (cape--dict-words)))
+
+(defun cape--abbrev-completions ()
+ "Return all abbreviations."
+ (delete "" (nconc (all-completions "" global-abbrev-table)
+ (all-completions "" local-abbrev-table))))
+
+(defun cape--abbrev-expand (&rest _)
+ "Expand abbreviation before point."
+ (expand-abbrev))
+
+;;;###autoload
+(defun cape-abbrev-capf ()
+ "Abbrev completion-at-point-function."
+ (when-let ((bounds (bounds-of-thing-at-point 'symbol))
+ (abbrevs (cape--abbrev-completions)))
+ (list (car bounds) (cdr bounds) abbrevs
+ :exclusive 'no
+ :exit-function #'cape--abbrev-expand
+ :annotation-function (lambda (_) " Abbrev"))))
+
+;;;###autoload
+(defun cape-abbrev ()
+ "Complete abbreviation at point."
+ (interactive)
+ (cape--complete-in-region 'symbol (or (cape--abbrev-completions)
+ (user-error "No abbreviations"))
+ :exit-function #'cape--abbrev-expand))
(defun cape--keywords ()
"Return keywords for current major mode."
- [elpa] branch externals/cape created (now 5ccece0e34), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 4b3f29e565 001/146: Initial commit, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 139ffe8720 002/146: Add license, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8ed1e4e9cd 005/146: Remove parens from annotations, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a8d00aa3ef 006/146: Add defcustoms,
ELPA Syncer <=
- [elpa] externals/cape 97eacd933d 016/146: README: Update example, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 9833045077 017/146: Add completion categories, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b3c5e4ec69 018/146: cape-merge-capfs: Fix sorting, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 26b822db0a 011/146: Add MELPA badges, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 84c128ae9b 013/146: Add cape-merge-capfs (Fix #2), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 6c124b6cfd 015/146: README: Add some justification for the name :), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 63ded5fde4 028/146: Improve cape-company-to-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape f270456b5d 041/146: Improve cape-dabbrev-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a8e10cf7ae 014/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d6b13d3055 027/146: Fix no-cache call, ELPA Syncer, 2022/01/09