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

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

[elpa] externals/company a253fa5505 25/30: company-files--prefix: Captur


From: ELPA Syncer
Subject: [elpa] externals/company a253fa5505 25/30: company-files--prefix: Capture suffix as well
Date: Sat, 13 Jul 2024 00:57:52 -0400 (EDT)

branch: externals/company
commit a253fa55059624517d4947f9a42d76bd2abfc46c
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    company-files--prefix: Capture suffix as well
    
    No support for spaces in the suffix (escaping is hard).
    
    #340
---
 company-files.el | 4 +++-
 company.el       | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/company-files.el b/company-files.el
index cc15fc7017..61e8490467 100644
--- a/company-files.el
+++ b/company-files.el
@@ -129,7 +129,9 @@ Set this to nil to disable that behavior."
     (all-completions file (cdr company-files--completion-cache))))
 
 (defun company-files--prefix ()
-  (company-files--grab-existing-name))
+  (let ((existing (company-files--grab-existing-name)))
+    (when existing
+      (list existing (company-grab-suffix "[^ '\"\t\n\r/]*/?")))))
 
 (defun company-file--keys-match-p (new old)
   (and (equal (cdr old) (cdr new))
diff --git a/company.el b/company.el
index c56b47c518..5ccb69fcbb 100644
--- a/company.el
+++ b/company.el
@@ -1114,6 +1114,10 @@ means that `company-mode' is always turned on except in 
`message-mode' buffers."
   (when (looking-back regexp limit)
     (or (match-string-no-properties (or expression 0)) "")))
 
+(defun company-grab-suffix (regexp &optional expression)
+  (when (looking-at regexp)
+    (or (match-string-no-properties (or expression 0)) "")))
+
 (defun company-grab-line (regexp &optional expression)
   "Return a match string for REGEXP if it matches text before point.
 If EXPRESSION is non-nil, return the match string for the respective



reply via email to

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