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

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

[elpa] master c59c85b 24/38: Merge branch 'master' into company-tng-with


From: Dmitry Gutov
Subject: [elpa] master c59c85b 24/38: Merge branch 'master' into company-tng-with-post-completion
Date: Sat, 25 Jul 2020 19:51:15 -0400 (EDT)

branch: master
commit c59c85b31e68e650beaad6684ab756459e4a6931
Merge: 6cf5169 b9b0577
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Merge branch 'master' into company-tng-with-post-completion
---
 .travis.yml          |  4 ++--
 NEWS.md              |  6 +++---
 company-bbdb.el      |  8 +++++---
 company-yasnippet.el | 37 +++++++++++++++++++++++++++++++++----
 company.el           | 24 +++++++++++++-----------
 5 files changed, 56 insertions(+), 23 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 03933bf..18e928d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,5 @@
 language: generic
 
-sudo: false
-
 env:
   global:
     - CURL="curl -fsSkL --retry 9 --retry-delay 9"
@@ -10,6 +8,8 @@ env:
     - EMACS_VERSION=25.3
     - EMACS_VERSION=26.1
     - EMACS_VERSION=master
+    
+matrix:
   allow_failures:
     - env: EMACS_VERSION=master
 
diff --git a/NEWS.md b/NEWS.md
index c8f2711..45ab42a 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,7 +1,8 @@
 # History of user-visible changes
 
-## Next
+## 2020-02-07 (0.9.12)
 
+* Tooltip rendering bugfix.
 * `company-indent-or-complete-common` is better compatible with
   `indent-for-tab-command`
   
([comment](https://github.com/company-mode/company-mode/issues/94#issuecomment-571265393)).
@@ -19,8 +20,7 @@
 * Snippet/template field interaction is inhibited while completion is active
   (where by default `TAB` calls `company-complete-common`, clashing with 
snippet
   map binding `TAB` to "jump to the next field"). Affects both
-  `company-template` and `yasnippet` (requires changes from 2019-04-21,
-  currently unreleased).
+  `company-template` and `yasnippet` (requires version 0.14.0).
 
 ## 2019-04-15 (0.9.10)
 
diff --git a/company-bbdb.el b/company-bbdb.el
index 872e1fc..a68c34e 100644
--- a/company-bbdb.el
+++ b/company-bbdb.el
@@ -50,9 +50,11 @@
     (interactive (company-begin-backend 'company-bbdb))
     (prefix (and (memq major-mode company-bbdb-modes)
                  (featurep 'bbdb-com)
-                 (looking-back "^\\(To\\|Cc\\|Bcc\\): *.*? *\\([^,;]*\\)"
-                               (line-beginning-position))
-                 (match-string-no-properties 2)))
+                 (let ((case-fold-search t))
+                   (looking-back
+                    "^\\([^ :]*-\\)?\\(To\\|B?Cc\\|From\\):.*? *\\([^,;]*\\)"
+                    (line-beginning-position)))
+                 (match-string-no-properties 3)))
     (candidates (company-bbdb--candidates arg))
     (sorted t)
     (no-cache t)))
diff --git a/company-yasnippet.el b/company-yasnippet.el
index e5fded4..c2c2688 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, 2015  Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2015, 2020  Free Software Foundation, Inc.
 
 ;; Author: Dmitry Gutov
 
@@ -35,6 +35,14 @@
 (declare-function yas--template-expand-env "yasnippet")
 (declare-function yas--warning "yasnippet")
 
+(defvar company-yasnippet-annotation-fn
+  (lambda (name)
+    (concat
+     (unless company-tooltip-align-annotations " -> ")
+     name))
+  "Function to format completion annotation.
+It has to accept one argument: the snippet's name.")
+
 (defun company-yasnippet--key-prefixes ()
   ;; Mostly copied from `yas--templates-for-key-at-point'.
   (defvar yas-key-syntaxes)
@@ -97,6 +105,27 @@
        res))
    tables))
 
+(defun company-yasnippet--doc (arg)
+  (let ((template (get-text-property 0 'yas-template arg))
+        (mode major-mode)
+        (file-name (buffer-file-name)))
+    (with-current-buffer (company-doc-buffer)
+      (let ((buffer-file-name file-name))
+        (yas-minor-mode 1)
+        (condition-case error
+            (yas-expand-snippet (yas--template-content template))
+          (error
+           (message "%s"  (error-message-string error))))
+        (delay-mode-hooks
+          (let ((inhibit-message t))
+            (if (eq mode 'web-mode)
+                (progn
+                  (setq mode 'html-mode)
+                  (funcall mode))
+              (funcall mode)))
+          (ignore-errors (font-lock-ensure))))
+      (current-buffer))))
+
 ;;;###autoload
 (defun company-yasnippet (command &optional arg &rest ignore)
   "`company-mode' backend for `yasnippet'.
@@ -130,10 +159,10 @@ shadow backends that come after it.  Recommended usages:
      (and (bound-and-true-p yas-minor-mode)
           (company-grab-symbol)))
     (annotation
-     (concat
-      (unless company-tooltip-align-annotations " -> ")
-      (get-text-property 0 'yas-annotation arg)))
+     (funcall company-yasnippet-annotation-fn
+              (get-text-property 0 'yas-annotation arg)))
     (candidates (company-yasnippet--candidates arg))
+    (doc-buffer (company-yasnippet--doc arg))
     (no-cache t)
     (post-completion
      (let ((template (get-text-property 0 'yas-template arg))
diff --git a/company.el b/company.el
index df01c96..7072540 100644
--- a/company.el
+++ b/company.el
@@ -5,7 +5,7 @@
 ;; Author: Nikolaj Schumacher
 ;; Maintainer: Dmitry Gutov <dgutov@yandex.ru>
 ;; URL: http://company-mode.github.io/
-;; Version: 0.9.11
+;; Version: 0.9.12
 ;; Keywords: abbrev, convenience, matching
 ;; Package-Requires: ((emacs "24.3"))
 
@@ -1146,7 +1146,8 @@ can retrieve meta-data for them."
   ;; It's mory efficient to fix it only when they are displayed.
   ;; FIXME: Adopt the current text's capitalization instead?
   (if (eq (company-call-backend 'ignore-case) 'keep-prefix)
-      (concat company-prefix (substring candidate (length company-prefix)))
+      (let ((prefix (company--clean-string company-prefix)))
+        (concat prefix (substring candidate (length prefix))))
     candidate))
 
 (defun company--should-complete ()
@@ -1574,9 +1575,8 @@ prefix match (same case) will be prioritized."
       (setq company-prefix new-prefix)
       (company-update-candidates c)
       c)
-     ((and (> (point) company-point)
-           (company-auto-complete-p (buffer-substring-no-properties
-                                     (point) company-point)))
+     ((and (characterp last-command-event)
+           (company-auto-complete-p (string last-command-event)))
       ;; auto-complete
       (save-excursion
         (goto-char company-point)
@@ -2282,6 +2282,7 @@ character, stripping the modifiers.  That character must 
be a digit."
 (defun company-doc-buffer (&optional string)
   (with-current-buffer (get-buffer-create "*company-documentation*")
     (erase-buffer)
+    (fundamental-mode)
     (when string
       (save-excursion
         (insert string)
@@ -2527,7 +2528,7 @@ If SHOW-VERSION is non-nil, show the version in the echo 
area."
                      (if company-common
                          (string-width company-common)
                        0)))
-         (_ (setq value (company--pre-render value)
+         (_ (setq value (company-reformat (company--pre-render value))
                   annotation (and annotation (company--pre-render annotation 
t))))
          (ann-ralign company-tooltip-align-annotations)
          (ann-truncate (< width
@@ -2788,7 +2789,7 @@ If SHOW-VERSION is non-nil, show the version in the echo 
area."
     (dotimes (_ len)
       (let* ((value (pop lines-copy))
              (annotation (company-call-backend 'annotation value)))
-        (setq value (company--clean-string (company-reformat value)))
+        (setq value (company--clean-string value))
         (when annotation
           (setq annotation (company--clean-string annotation))
           (when company-tooltip-align-annotations
@@ -2933,7 +2934,8 @@ Returns a negative number if the tooltip should be 
displayed above point."
     (overlay-put company-pseudo-tooltip-overlay 'invisible nil)
     (overlay-put company-pseudo-tooltip-overlay 'line-prefix nil)
     (overlay-put company-pseudo-tooltip-overlay 'after-string nil)
-    (overlay-put company-pseudo-tooltip-overlay 'display nil)))
+    (overlay-put company-pseudo-tooltip-overlay 'display nil)
+    (overlay-put company-pseudo-tooltip-overlay 'face nil)))
 
 (defun company-pseudo-tooltip-unhide ()
   (when company-pseudo-tooltip-overlay
@@ -3164,7 +3166,7 @@ Delay is determined by `company-tooltip-idle-delay'."
         comp msg)
 
     (while candidates
-      (setq comp (company-reformat (pop candidates))
+      (setq comp (company-reformat (company--clean-string (pop candidates)))
             len (+ len 1 (length comp)))
       (if (< i 10)
           ;; Add number.
@@ -3173,10 +3175,10 @@ Delay is determined by `company-tooltip-idle-delay'."
                                    'face 'company-echo))
             (cl-incf len 3)
             (cl-incf i)
-            (add-text-properties 3 (+ 3 (length company-common))
+            (add-text-properties 3 (+ 3 (string-width company-common))
                                  '(face company-echo-common) comp))
         (setq comp (propertize comp 'face 'company-echo))
-        (add-text-properties 0 (length company-common)
+        (add-text-properties 0 (string-width company-common)
                              '(face company-echo-common) comp))
       (if (>= len limit)
           (setq candidates nil)



reply via email to

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