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

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

[elpa] master a3858be 086/173: Ignore trigger key prefixes that are shor


From: Dmitry Gutov
Subject: [elpa] master a3858be 086/173: Ignore trigger key prefixes that are shorter than symbol-at-point
Date: Thu, 23 Jun 2016 00:28:40 +0000 (UTC)

branch: master
commit a3858bee55c3f11800309b92428aa8f9c11409c8
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Ignore trigger key prefixes that are shorter than symbol-at-point
    
    Closes #422
---
 NEWS.md              |    7 +++++--
 company-yasnippet.el |   10 ++++------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index fbbd3c3..6e92cce 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,8 +2,11 @@
 
 ## Next
 
-* `company-yasnippet` respects `yas-key-syntaxes`. But we use them in the
-  reverse order, preferring the longest key prefix that matches anything.
+* `company-yasnippet` supports `yas-key-syntaxes` better. But we use them in 
the
+  reverse order, preferring the longest key prefix that matches anything. And 
we
+  only consider trigger key prefixes that are at least as long as the symbol at
+  point, which effectively means skipping the `"w"` element
+  ([#422](https://github.com/company-mode/company-mode/issues/422)).
 * New user option `company-search-regexp-function`.
 * Completion is not started automatically when a keyboard macro is being
   recorded ([#374](https://github.com/company-mode/company-mode/issues/374)).
diff --git a/company-yasnippet.el b/company-yasnippet.el
index 93e6eb2..e5fded4 100644
--- a/company-yasnippet.el
+++ b/company-yasnippet.el
@@ -67,6 +67,8 @@
   ;; matches, so the longest prefix with any matches should be the most useful.
   (cl-loop with tables = (yas--get-snippet-tables)
            for key-prefix in (company-yasnippet--key-prefixes)
+           ;; Only consider keys at least as long as the symbol at point.
+           when (>= (length key-prefix) (length prefix))
            thereis (company-yasnippet--completions-for-prefix prefix
                                                               key-prefix
                                                               tables)))
@@ -87,12 +89,8 @@
                   (propertize key
                               'yas-annotation name
                               'yas-template template
-                              'yas-prefix-offset
-                              (let ((pl (length prefix))
-                                    (kpl (length key-prefix)))
-                                (if (> kpl pl)
-                                    (- kpl pl)
-                                  0)))
+                              'yas-prefix-offset (- (length key-prefix)
+                                                    (length prefix)))
                   res))
                value)))
           keyhash))



reply via email to

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