[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 12b00151d1 143/146: Improve and simplify cape-dabb
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 12b00151d1 143/146: Improve and simplify cape-dabbrev |
Date: |
Sun, 9 Jan 2022 20:57:50 -0500 (EST) |
branch: externals/cape
commit 12b00151d1965da3c42e5c6ece3720a506dacb9c
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve and simplify cape-dabbrev
Use bounds-of-thing-at-point instead of dabbrev--abbrev-at-point.
dabbrev--abbrev-at-point returns strings with spaces which is undesired.
Furthermore it only returns the part of the word before the point, which
leads
to odd side effects.
---
cape.el | 46 ++++++++++++++--------------------------------
1 file changed, 14 insertions(+), 32 deletions(-)
diff --git a/cape.el b/cape.el
index 5dae916e1d..2aaeb3e22b 100644
--- a/cape.el
+++ b/cape.el
@@ -64,10 +64,6 @@
"Minimum length of dabbrev expansions."
:type 'integer)
-(defcustom cape-dabbrev-forbid-space t
- "Forbid space in dabbrev expansions."
- :type 'boolean)
-
(defcustom cape-dabbrev-check-other-buffers t
"Buffers to check for dabbrev."
:type 'boolean)
@@ -486,7 +482,6 @@ If INTERACTIVE is nil the function acts like a capf."
(declare-function dabbrev--ignore-case-p "dabbrev")
(declare-function dabbrev--find-all-expansions "dabbrev")
(declare-function dabbrev--reset-global-variables "dabbrev")
-(declare-function dabbrev--abbrev-at-point "dabbrev")
;;;###autoload
(defun cape-dabbrev (&optional interactive)
@@ -494,39 +489,26 @@ If INTERACTIVE is nil the function acts like a capf."
If INTERACTIVE is nil the function acts like a capf."
(interactive (list t))
(if interactive
- (let ((cape-dabbrev-min-length 0)
- cape-dabbrev-forbid-space)
+ (let ((cape-dabbrev-min-length 0))
(cape--interactive #'cape-dabbrev))
- (require 'dabbrev)
- (cape--dabbrev-reset)
- (let ((abbrev (ignore-errors (dabbrev--abbrev-at-point)))
- (beg (line-beginning-position))
- (end (line-end-position)))
- (when (and abbrev
- (not (and cape-dabbrev-forbid-space (string-match-p "\\s-"
abbrev)))
- (save-excursion
- (setq beg (search-backward abbrev beg 'noerror)
- end (search-forward abbrev end 'noerror))
- (and beg end)))
- `(,beg ,end
- ,(cape--table-with-properties
- ;; Use equal, if candidates must be longer than
cape-dabbrev-min-length.
- (cape--cached-table beg end #'cape--dabbrev-list
- (if (> cape-dabbrev-min-length 0)
- 'equal 'prefix))
+ (when-let (bounds (bounds-of-thing-at-point 'word))
+ `(,(car bounds) ,(cdr bounds)
+ ,(cape--table-with-properties
+ ;; Use equal, if candidates must be longer than
cape-dabbrev-min-length.
+ (cape--cached-table (car bounds) (cdr bounds)
+ #'cape--dabbrev-list
+ (if (> cape-dabbrev-min-length 0)
+ 'equal 'prefix))
:category 'cape-dabbrev)
- :exclusive no ,@cape--dabbrev-properties)))))
-
-(defun cape--dabbrev-reset ()
- "Reset dabbrev state."
- (let ((dabbrev-check-all-buffers cape-dabbrev-check-other-buffers)
- (dabbrev-check-other-buffers cape-dabbrev-check-other-buffers))
- (dabbrev--reset-global-variables)))
+ :exclusive no ,@cape--dabbrev-properties))))
(defun cape--dabbrev-list (word)
"Find all dabbrev expansions for WORD."
+ (require 'dabbrev)
(cape--silent
- (cape--dabbrev-reset)
+ (let ((dabbrev-check-all-buffers cape-dabbrev-check-other-buffers)
+ (dabbrev-check-other-buffers cape-dabbrev-check-other-buffers))
+ (dabbrev--reset-global-variables))
(cl-loop with min-len = (+ cape-dabbrev-min-length (length word))
for w in (dabbrev--find-all-expansions word
(dabbrev--ignore-case-p word))
if (>= (length w) min-len) collect w)))
- [elpa] externals/cape fd8828cff3 100/146: Make cape--company-call more robust, (continued)
- [elpa] externals/cape fd8828cff3 100/146: Make cape--company-call more robust, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1d0d3abbd1 102/146: Use namespaced symbol, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 4aec140c08 109/146: Minor cleanup, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b3e2850fcf 108/146: Add unwind-protect, ELPA Syncer, 2022/01/09
- [elpa] externals/cape e81e3cfd4e 112/146: Indent, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b895c8cf28 114/146: cape-capf-case-fold: Add dont-fold, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c0343a247c 123/146: cape-tex/sgml: Improve docsig, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 6d076f2480 129/146: README: Document company--multi-backend-adapter, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c8c0a9f9a6 134/146: Simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 5319e343bb 136/146: Improve repair function, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 12b00151d1 143/146: Improve and simplify cape-dabbrev,
ELPA Syncer <=
- [elpa] externals/cape be2014538a 144/146: cape-dabbrev: Use thing-at-point-looking-at, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 5ccece0e34 146/146: Add to GNU ELPA, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 700c9d7bc2 137/146: Remove cape-repair-misbehaving-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape bc1c1ee9fc 140/146: Make cape-tex etc less aggressive, add cape-tex-prefix-required variable, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8726bc7246 138/146: cape--interactive: Simplify, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ac65f2acdf 048/146: Add autoloads, renamings, README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0a05e51d2a 053/146: Add cape-capf-with-predicate (See #9), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 75cb8c799a 071/146: Unify cape-file and cape-file-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1d72f84b64 046/146: Add cape-capf-with-properties and cape-silent-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 693a376913 054/146: Revert "Add cape-capf-with-predicate (See #9)", ELPA Syncer, 2022/01/09