[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company 10fcb21d46 09/30: Remove suffix after completio
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company 10fcb21d46 09/30: Remove suffix after completion by company-dabbrev-code too |
Date: |
Sat, 13 Jul 2024 00:57:50 -0400 (EDT) |
branch: externals/company
commit 10fcb21d461992180385469069ea404b5fb5bf93
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
Remove suffix after completion by company-dabbrev-code too
Though only when company-dabbrev-code-completion-styles is non-nil.
#340
#1106
---
company-capf.el | 22 +++++++++++-----------
company-dabbrev-code.el | 46 ++++++++++++++++++++++++++++------------------
company.el | 3 ++-
3 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/company-capf.el b/company-capf.el
index ff775e517d..93f54e16fc 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -160,7 +160,7 @@ so we can't just use the preceding variable instead.")
(plist-get (nthcdr 4 (company--capf-data)) :company-require-match))
(`init nil) ;Don't bother: plenty of other ways to initialize the
code.
(`post-completion
- (company--capf-post-completion arg (car rest)))
+ (company--capf-post-completion arg (nth 0 rest) (nth 1 rest)))
))
(defun company-capf--annotation (arg)
@@ -220,15 +220,8 @@ so we can't just use the preceding variable instead.")
(throw 'interrupted 'new-input))
res)))
-(defun company--capf-post-completion (arg prefix)
- (let* ((res company-capf--current-completion-data)
- (exit-function (plist-get (nthcdr 4 res) :exit-function))
- (pred (plist-get (nthcdr 4 res) :predicate))
- (suffix (buffer-substring (+ (nth 1 res) (length arg))
- (+ (nth 2 res)
- (- (length arg) (length prefix)))))
- (table (nth 3 res))
- (replace-suffix t))
+(defun company--capf-chop-suffix (arg prefix suffix table &optional pred)
+ (let ((replace-suffix t))
;; If emacs22 is reached and matches, that style is used.
(cl-letf (((symbol-function 'completion-emacs22-all-completions)
(lambda (&rest _)
@@ -240,7 +233,14 @@ so we can't just use the preceding variable instead.")
(length prefix)))
(when replace-suffix
;; Replace unless the style is emacs22.
- (delete-region (point) (+ (point) (length suffix))))
+ (delete-region (point) (+ (point) (length suffix))))))
+
+(defun company--capf-post-completion (arg prefix suffix)
+ (let* ((res company-capf--current-completion-data)
+ (exit-function (plist-get (nthcdr 4 res) :exit-function))
+ (pred (plist-get (nthcdr 4 res) :predicate))
+ (table (nth 3 res)))
+ (company--capf-chop-suffix arg prefix suffix table pred)
(if exit-function
;; We can more or less know when the user is done with completion,
;; so we do something different than `completion--done'.
diff --git a/company-dabbrev-code.el b/company-dabbrev-code.el
index 1060c844fa..968ca967a2 100644
--- a/company-dabbrev-code.el
+++ b/company-dabbrev-code.el
@@ -106,24 +106,15 @@ comments or strings."
(or company-dabbrev-code-everywhere
(not (company-in-string-or-comment)))
(company-grab-symbol-parts)))
- (candidates
- (let* ((case-fold-search company-dabbrev-code-ignore-case)
- (regexp (company-dabbrev-code--make-regexp arg)))
- (company-dabbrev-code--filter
- arg (car rest)
- (company-cache-fetch
- 'dabbrev-code-candidates
- (lambda ()
- (company-dabbrev--search
- regexp
- company-dabbrev-code-time-limit
- (pcase company-dabbrev-code-other-buffers
- (`t (list major-mode))
- (`code company-dabbrev-code-modes)
- (`all `all))
- (not company-dabbrev-code-everywhere)))
- :expire t
- :check-tag regexp))))
+ (candidates (company-dabbrev--candidates arg (car rest)))
+ (post-completion
+ (when company-dabbrev-code-completion-styles
+ (let ((completion-styles (if (listp
company-dabbrev-code-completion-styles)
+ company-dabbrev-code-completion-styles
+ completion-styles)))
+ (require 'company-capf)
+ (company--capf-chop-suffix arg (nth 0 rest) (nth 1 rest)
+ (company-dabbrev--candidates arg (car
rest))))))
(kind 'text)
(no-cache t)
(ignore-case company-dabbrev-code-ignore-case)
@@ -131,6 +122,25 @@ comments or strings."
(company--match-from-capf-face arg)))
(duplicates t)))
+(defun company-dabbrev--candidates (prefix suffix)
+ (let* ((case-fold-search company-dabbrev-code-ignore-case)
+ (regexp (company-dabbrev-code--make-regexp prefix)))
+ (company-dabbrev-code--filter
+ prefix suffix
+ (company-cache-fetch
+ 'dabbrev-code-candidates
+ (lambda ()
+ (company-dabbrev--search
+ regexp
+ company-dabbrev-code-time-limit
+ (pcase company-dabbrev-code-other-buffers
+ (`t (list major-mode))
+ (`code company-dabbrev-code-modes)
+ (`all `all))
+ (not company-dabbrev-code-everywhere)))
+ :expire t
+ :check-tag regexp))))
+
(defun company-dabbrev-code--filter (prefix suffix table)
(let ((completion-ignore-case company-dabbrev-code-ignore-case)
(completion-styles (if (listp company-dabbrev-code-completion-styles)
diff --git a/company.el b/company.el
index a4d7824486..06e19655a1 100644
--- a/company.el
+++ b/company.el
@@ -2356,6 +2356,7 @@ For more details see `company-insertion-on-trigger' and
(defun company-cancel (&optional result)
(let ((prefix company-prefix)
+ (suffix company-suffix)
(backend company-backend))
(setq company-backend nil
company-prefix nil
@@ -2383,7 +2384,7 @@ For more details see `company-insertion-on-trigger' and
(if (stringp result)
(let ((company-backend backend))
(run-hook-with-args 'company-completion-finished-hook result)
- (company-call-backend 'post-completion result prefix))
+ (company-call-backend 'post-completion result prefix suffix))
(run-hook-with-args 'company-completion-cancelled-hook result))
(run-hook-with-args 'company-after-completion-hook result)))
;; Make return value explicit.
- [elpa] externals/company updated (8d2ca28a16 -> 31f7ad52e4), ELPA Syncer, 2024/07/13
- [elpa] externals/company 22551866cc 03/30: Switch to non-obsolete function, ELPA Syncer, 2024/07/13
- [elpa] externals/company b5db1934ce 08/30: company--capf-post-completion: Make sure to replace the suffix, ELPA Syncer, 2024/07/13
- [elpa] externals/company 01e82364bf 23/30: company-post-command: Refresh more often, ELPA Syncer, 2024/07/13
- [elpa] externals/company 78ed92db96 14/30: Fix "Attempt to modify read-only object", ELPA Syncer, 2024/07/13
- [elpa] externals/company ff6107bde3 04/30: company-inhibit-inside-symbols: New option, ELPA Syncer, 2024/07/13
- [elpa] externals/company 426e1830ff 06/30: company--unique-match-p: Also include suffix, ELPA Syncer, 2024/07/13
- [elpa] externals/company d7e77b9673 01/30: #1106 #340 Complete inside symbols, ELPA Syncer, 2024/07/13
- [elpa] externals/company 7ed2baeedd 05/30: Merge branch 'master' into completion_inside_symbol, ELPA Syncer, 2024/07/13
- [elpa] externals/company ebe5244443 07/30: Merge branch 'master' into completion_inside_symbol, ELPA Syncer, 2024/07/13
- [elpa] externals/company 10fcb21d46 09/30: Remove suffix after completion by company-dabbrev-code too,
ELPA Syncer <=
- [elpa] externals/company 2fefdc7ce3 02/30: Fix test failures, ELPA Syncer, 2024/07/13
- [elpa] externals/company 436b0d6247 10/30: New backend command `adjust-boundaries`, ELPA Syncer, 2024/07/13
- [elpa] externals/company 477799b362 18/30: Make suffix matching use "proper suffix" logic by default, ELPA Syncer, 2024/07/13
- [elpa] externals/company a011dbd892 27/30: Update company-files tests, ELPA Syncer, 2024/07/13
- [elpa] externals/company 277640481a 19/30: Render the "preview" overlay over the matching suffix text, ELPA Syncer, 2024/07/13
- [elpa] externals/company 54b0148ce4 16/30: Fix bytecomp warnings, ELPA Syncer, 2024/07/13
- [elpa] externals/company d4e01ed948 21/30: #1474 change the reference in NEWS, ELPA Syncer, 2024/07/13
- [elpa] externals/company 31f7ad52e4 30/30: Merge pull request #1474 from company-mode/completion_inside_symbol, ELPA Syncer, 2024/07/13
- [elpa] externals/company a253fa5505 25/30: company-files--prefix: Capture suffix as well, ELPA Syncer, 2024/07/13
- [elpa] externals/company bbe0bc031a 13/30: company--multi-backend-adapter: Support suffix and `adjust-boundaries`, ELPA Syncer, 2024/07/13