emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/cape 9defa71303 142/146: cape-dabbrev: Add cape-dabbrev


From: ELPA Syncer
Subject: [elpa] externals/cape 9defa71303 142/146: cape-dabbrev: Add cape-dabbrev-forbid-space
Date: Sun, 9 Jan 2022 20:57:49 -0500 (EST)

branch: externals/cape
commit 9defa71303aa2ec2e1c430b7e6f02bbf10da3934
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]