From: Dmitry Gutov Date: Tue, 1 Dec 2015 23:08:50 +0000 (+0200) Subject: Ignore trigger key prefixes that are shorter than symbol-at-point X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/a3858bee55c3f11800309b92428aa8f9c11409c8 Ignore trigger key prefixes that are shorter than symbol-at-point Closes #422 --- diff --git a/NEWS.md b/NEWS.md index fbbd3c384..6e92cce57 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 93e6eb299..e5fded4d1 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))