branch: externals/cape
commit 9defa71303aa2ec2e1c430b7e6f02bbf10da3934
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
cape-dabbrev: Add cape-dabbrev-forbid-space
Ensure that the abbreviation at point is limited to the current line
---
cape.el | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/cape.el b/cape.el
index cbfbc37279..5dae916e1d 100644
--- a/cape.el
+++ b/cape.el
@@ -64,6 +64,10 @@
"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)
@@ -490,17 +494,20 @@ 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))
+ (let ((cape-dabbrev-min-length 0)
+ cape-dabbrev-forbid-space)
(cape--interactive #'cape-dabbrev))
(require 'dabbrev)
(cape--dabbrev-reset)
- (let ((abbrev (ignore-errors (dabbrev--abbrev-at-point))) beg end)
- (when (and abbrev (not (string-match-p "\\s-" abbrev)))
- (save-excursion
- (search-backward abbrev)
- (setq beg (point))
- (search-forward abbrev)
- (setq end (point)))
+ (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.