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

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

[elpa] externals/company c7bc412 2/2: Merge pull request #1240 from yyon


From: ELPA Syncer
Subject: [elpa] externals/company c7bc412 2/2: Merge pull request #1240 from yyoncho/deprecated
Date: Thu, 21 Oct 2021 04:57:11 -0400 (EDT)

branch: externals/company
commit c7bc41210cc0b217d45854b8388dee70b1cbc836
Merge: 4c08ef4 dac5b25
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: GitHub <noreply@github.com>

    Merge pull request #1240 from yyoncho/deprecated
    
    Add support for deprecated property
---
 NEWS.md                 |  4 +++-
 company-capf.el         |  4 ++++
 company.el              | 11 +++++++++++
 test/frontends-tests.el | 11 +++++++++++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/NEWS.md b/NEWS.md
index 7bb4c70..6780953 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
 
 ## Next
 
+* New backend command, `deprecated`. It returns whether the completion item is
+  deprecated or not.
 * `company-tooltip-common` highlightings with non-prefix and prefix matching
   backends are more compatible: if the non-prefix matching backend's 
completions
   all have a common part, and so the current prefix can be expanded with
@@ -134,7 +136,7 @@
 * `company-idle-delay` now accepts a function which generates the idle time or
   nil indicating no idle completion.
 * Add custom variable `company-show-numbers-function` to make numbers of
-  candidates customizable. 
+  candidates customizable.
 * When a symbol is already typed in full, calling `M-x company-complete` will
   now run its post-completion action (e.g. inserting method parameters
   template). Calling `M-x company-manual-begin` or invoking a backend command
diff --git a/company-capf.el b/company-capf.el
index 813b2aa..5a2a264 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -153,6 +153,10 @@ so we can't just use the preceding variable instead.")
      (let ((f (plist-get (nthcdr 4 company-capf--current-completion-data)
                          :company-kind)))
        (when f (funcall f arg))))
+    (`deprecated
+     (let ((f (plist-get (nthcdr 4 company-capf--current-completion-data)
+                         :company-deprecated)))
+       (when f (funcall f arg))))
     (`require-match
      (plist-get (nthcdr 4 (company--capf-data)) :company-require-match))
     (`init nil)      ;Don't bother: plenty of other ways to initialize the 
code.
diff --git a/company.el b/company.el
index d1ab486..0e35da1 100644
--- a/company.el
+++ b/company.el
@@ -92,6 +92,10 @@
     (t (:background "green")))
   "Face used for the selection in the tooltip.")
 
+(defface company-tooltip-deprecated
+  '((t (:inherit default :strike-through t)))
+  "Face used for the deprecated items.")
+
 (defface company-tooltip-search
   '((default :inherit highlight))
   "Face used for the search string in the tooltip.")
@@ -403,6 +407,9 @@ be kept if they have different annotations.  For that to 
work properly,
 backends should store the related information on candidates using text
 properties.
 
+`deprecated': The second argument is a completion candidate.  Return
+non-nil if the completion candidate is deprecated.
+
 `match': The second argument is a completion candidate.  Return a positive
 integer, the index after the end of text matching `prefix' within the
 candidate string.  Alternatively, return a list of (CHUNK-START
@@ -3054,6 +3061,10 @@ If SHOW-VERSION is non-nil, show the version in the echo 
area."
                                     nil line)))))
     (when selected
       (add-face-text-property 0 width 'company-tooltip-selection t line))
+
+    (when (company-call-backend 'deprecated value)
+      (add-face-text-property 0 width 'company-tooltip-deprecated t line))
+
     (add-face-text-property 0 width 'company-tooltip t line)
     line))
 
diff --git a/test/frontends-tests.el b/test/frontends-tests.el
index c07e0ad..ea54c9b 100644
--- a/test/frontends-tests.el
+++ b/test/frontends-tests.el
@@ -323,6 +323,17 @@
              #(" bar "
                0 5 (face (company-tooltip-selection company-tooltip) 
mouse-face (company-tooltip-mouse)))))))
 
+(ert-deftest company-fill-propertize-deprecated ()
+  (let ((company-search-string "foo")
+        (company-backend (lambda (c &rest _) (pcase c (`deprecated t))))
+        (company-prefix ""))
+    (should (ert-equal-including-properties
+             (company-fill-propertize "barfoo" nil 5 t "" " ")
+             #("barfo "
+               0 3 (face (company-tooltip-selection company-tooltip-deprecated 
company-tooltip) mouse-face (company-tooltip-mouse))
+               3 5 (face (company-tooltip-search-selection 
company-tooltip-selection company-tooltip-deprecated company-tooltip) 
mouse-face (company-tooltip-mouse))
+               5 6 (face (company-tooltip-selection company-tooltip-deprecated 
company-tooltip) mouse-face (company-tooltip-mouse)))))))
+
 (ert-deftest company-fill-propertize-overrides-face-property ()
   (let ((company-backend #'ignore)
         (company-prefix "")



reply via email to

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