X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/a95d7f1d6a25c11496f0606eb868343505db921b..971eea5ba3ff339ea6129cebff1fa2457fc9a6dc:/company-yasnippet.el diff --git a/company-yasnippet.el b/company-yasnippet.el index 665992609..e5fded4d1 100644 --- a/company-yasnippet.el +++ b/company-yasnippet.el @@ -1,6 +1,6 @@ ;;; company-yasnippet.el --- company-mode completion backend for Yasnippet -;; Copyright (C) 2014 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2015 Free Software Foundation, Inc. ;; Author: Dmitry Gutov @@ -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))) @@ -84,7 +86,7 @@ (maphash (lambda (name template) (push - (propertize (company-yasnippet--adjust-key key prefix key-prefix) + (propertize key 'yas-annotation name 'yas-template template 'yas-prefix-offset (- (length key-prefix) @@ -95,17 +97,6 @@ res)) tables)) -(defun company-yasnippet--adjust-key (key prefix key-prefix) - (let ((pl (length prefix)) - (kpl (length key-prefix))) - (cond - ((= pl kpl) - key) - ((> pl kpl) - (concat (substring prefix 0 (- pl kpl)) key)) - (t - (substring key (- kpl pl)))))) - ;;;###autoload (defun company-yasnippet (command &optional arg &rest ignore) "`company-mode' backend for `yasnippet'. @@ -143,6 +134,7 @@ shadow backends that come after it. Recommended usages: (unless company-tooltip-align-annotations " -> ") (get-text-property 0 'yas-annotation arg))) (candidates (company-yasnippet--candidates arg)) + (no-cache t) (post-completion (let ((template (get-text-property 0 'yas-template arg)) (prefix-offset (get-text-property 0 'yas-prefix-offset arg)))