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

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

[elpa] master edc5d03 29/29: Merge commit 'f1499404163d8148e7a6303a8598f


From: Dmitry Gutov
Subject: [elpa] master edc5d03 29/29: Merge commit 'f1499404163d8148e7a6303a8598f9c0f696d1cb' from company
Date: Tue, 28 Mar 2017 20:50:38 -0400 (EDT)

branch: master
commit edc5d0336c68f6bc77d6a7950d1e72e7bd8db03f
Merge: 4f12749 f149940
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Merge commit 'f1499404163d8148e7a6303a8598f9c0f696d1cb' from company
---
 packages/company/.elpaignore             |   2 +-
 packages/company/NEWS.md                 |  14 +++
 packages/company/company-clang.el        |   6 +-
 packages/company/company-gtags.el        |   2 +-
 packages/company/company-keywords.el     |   3 +-
 packages/company/company.el              | 162 ++++++++++++++++---------------
 packages/company/test/clang-tests.el     |   6 ++
 packages/company/test/core-tests.el      |  27 +++++-
 packages/company/test/frontends-tests.el |   6 +-
 9 files changed, 142 insertions(+), 86 deletions(-)

diff --git a/packages/company/.elpaignore b/packages/company/.elpaignore
index 9f31d8a..2203be3 100644
--- a/packages/company/.elpaignore
+++ b/packages/company/.elpaignore
@@ -1,5 +1,5 @@
 .travis.yml
 .gitignore
 Makefile
-test/
+test
 company-tests.el
diff --git a/packages/company/NEWS.md b/packages/company/NEWS.md
index 32d05b3..7d8ae3e 100644
--- a/packages/company/NEWS.md
+++ b/packages/company/NEWS.md
@@ -1,5 +1,19 @@
 # History of user-visible changes
 
+## 2017-03-29 (0.9.3)
+
+* New variable `company-echo-truncate-lines`.
+* `company-auto-complete` improved compatibility with `electric-pair-mode`.
+* Use of `overriding-terminal-local-map` does not disable completion.
+* `company-clang` and `company-gtags` can work over Tramp.
+* New frontend `company-preview-common-frontend`.
+* `company-clang` calls Clang using a pipe instead of pty.
+* The minimum required version of Emacs is now 24.3.
+
+## 2016-11-14 (0.9.2)
+
+* Miscellaneous fixes and docstring improvements.
+
 ## 2016-11-12 (0.9.1)
 
 * `company-indent-or-complete-common` skips trying to indent if
diff --git a/packages/company/company-clang.el 
b/packages/company/company-clang.el
index 54d4b9b..599491d 100644
--- a/packages/company/company-clang.el
+++ b/packages/company/company-clang.el
@@ -161,6 +161,7 @@ or automatically through a custom 
`company-clang-prefix-guesser'."
      ((null meta) nil)
      ((string-match "[^:]:[^:]" meta)
       (substring meta (1+ (match-beginning 0))))
+     ((string-match "(anonymous)" meta) nil)
      ((string-match "\\((.*)[ a-z]*\\'\\)" meta)
       (let ((paren (match-beginning 1)))
         (if (not (eq (aref meta (1- paren)) ?>))
@@ -208,8 +209,9 @@ or automatically through a custom 
`company-clang-prefix-guesser'."
       (with-current-buffer buf
         (erase-buffer)
         (setq buffer-undo-list t))
-      (let ((process (apply #'start-process "company-clang" buf
-                            company-clang-executable args)))
+      (let* ((process-connection-type nil)
+             (process (apply #'start-file-process "company-clang" buf
+                             company-clang-executable args)))
         (set-process-sentinel
          process
          (lambda (proc status)
diff --git a/packages/company/company-gtags.el 
b/packages/company/company-gtags.el
index 82b8032..02513ca 100644
--- a/packages/company/company-gtags.el
+++ b/packages/company/company-gtags.el
@@ -65,7 +65,7 @@ completion."
 (defun company-gtags--fetch-tags (prefix)
   (with-temp-buffer
     (let (tags)
-      (when (= 0 (call-process company-gtags-executable nil
+      (when (= 0 (process-file company-gtags-executable nil
                                ;; "-T" goes through all the tag files listed 
in GTAGSLIBPATH
                                (list (current-buffer) nil) nil "-xGqT" (concat 
"^" prefix)))
         (goto-char (point-min))
diff --git a/packages/company/company-keywords.el 
b/packages/company/company-keywords.el
index fac37f5..bceb7f8 100644
--- a/packages/company/company-keywords.el
+++ b/packages/company/company-keywords.el
@@ -239,7 +239,8 @@
     (js-jsx-mode . javascript-mode)
     (cperl-mode . perl-mode)
     (jde-mode . java-mode)
-    (ess-julia-mode . julia-mode))
+    (ess-julia-mode . julia-mode)
+    (enh-ruby-mode . ruby-mode))
   "Alist mapping major-modes to sorted keywords for `company-keywords'.")
 
 ;;;###autoload
diff --git a/packages/company/company.el b/packages/company/company.el
index 32b4b1a..e48c2d9 100644
--- a/packages/company/company.el
+++ b/packages/company/company.el
@@ -1,13 +1,13 @@
 ;;; company.el --- Modular text completion framework  -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2009-2016  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2017  Free Software Foundation, Inc.
 
 ;; Author: Nikolaj Schumacher
 ;; Maintainer: Dmitry Gutov <address@hidden>
 ;; URL: http://company-mode.github.io/
-;; Version: 0.9.2
+;; Version: 0.9.3
 ;; Keywords: abbrev, convenience, matching
-;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
+;; Package-Requires: ((emacs "24.3"))
 
 ;; This file is part of GNU Emacs.
 
@@ -63,28 +63,9 @@
 (require 'newcomment)
 (require 'pcase)
 
-;; FIXME: Use `user-error'.
-(add-to-list 'debug-ignored-errors "^.* frontend cannot be used twice$")
-(add-to-list 'debug-ignored-errors "^Echo area cannot be used twice$")
-(add-to-list 'debug-ignored-errors "^No \\(document\\|loc\\)ation available$")
-(add-to-list 'debug-ignored-errors "^Company not ")
-(add-to-list 'debug-ignored-errors "^No candidate number ")
-(add-to-list 'debug-ignored-errors "^Cannot complete at point$")
-(add-to-list 'debug-ignored-errors "^No other backend$")
-
 ;;; Compatibility
 (eval-and-compile
-  ;; `defvar-local' for Emacs 24.2 and below
-  (unless (fboundp 'defvar-local)
-    (defmacro defvar-local (var val &optional docstring)
-      "Define VAR as a buffer-local variable with default value VAL.
-Like `defvar' but additionally marks the variable as being automatically
-buffer-local wherever it is set."
-      (declare (debug defvar) (doc-string 3))
-      `(progn
-         (defvar ,var ,val ,docstring)
-         (make-variable-buffer-local ',var))))
-
+  ;; Defined in Emacs 24.4
   (unless (fboundp 'string-suffix-p)
     (defun string-suffix-p (suffix string  &optional ignore-case)
       "Return non-nil if SUFFIX is a suffix of STRING.
@@ -206,15 +187,20 @@ attention to case differences."
                   (memq 'company-pseudo-tooltip-frontend value))
              (and (memq 
'company-pseudo-tooltip-unless-just-one-frontend-with-delay value)
                   (memq 'company-pseudo-tooltip-unless-just-one-frontend 
value)))
-         (error "Pseudo tooltip frontend cannot be used more than once"))
-    (and (memq 'company-preview-if-just-one-frontend value)
-         (memq 'company-preview-frontend value)
-         (error "Preview frontend cannot be used twice"))
+         (user-error "Pseudo tooltip frontend cannot be used more than once"))
+    (and (or (and (memq 'company-preview-if-just-one-frontend value)
+                  (memq 'company-preview-frontend value))
+             (and (memq 'company-preview-if-just-one-frontend value)
+                  (memq 'company-preview-common-frontend value))
+             (and (memq 'company-preview-frontend value)
+                  (memq 'company-preview-common-frontend value))
+             )
+         (user-error "Preview frontend cannot be used twice"))
     (and (memq 'company-echo value)
          (memq 'company-echo-metadata-frontend value)
-         (error "Echo area cannot be used twice"))
+         (user-error "Echo area cannot be used twice"))
     ;; Preview must come last.
-    (dolist (f '(company-preview-if-just-one-frontend 
company-preview-frontend))
+    (dolist (f '(company-preview-if-just-one-frontend company-preview-frontend 
company-preview-common-frontend))
       (when (cdr (memq f value))
         (setq value (append (delq f value) (list f)))))
     (set variable value)))
@@ -256,6 +242,8 @@ The visualized data is stored in `company-prefix', 
`company-candidates',
                          (const :tag "preview" company-preview-frontend)
                          (const :tag "preview, unique only"
                                 company-preview-if-just-one-frontend)
+                         (const :tag "preview, common"
+                                company-preview-common-frontend)
                          (function :tag "custom function" nil))))
 
 (defcustom company-tooltip-limit 10
@@ -795,7 +783,7 @@ means that `company-mode' is always turned on except in 
`message-mode' buffers."
 (defsubst company-assert-enabled ()
   (unless company-mode
     (company-uninstall-map)
-    (error "Company not enabled")))
+    (user-error "Company not enabled")))
 
 ;;; keymaps 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -1105,7 +1093,7 @@ can retrieve meta-data for them."
 
 (defun company--should-complete ()
   (and (eq company-idle-delay 'now)
-       (not (or buffer-read-only overriding-terminal-local-map
+       (not (or buffer-read-only
                 overriding-local-map))
        ;; Check if in the middle of entering a key combination.
        (or (equal (this-command-keys-vector) [])
@@ -1437,7 +1425,7 @@ prefix match (same case) will be prioritized."
       (when (ignore-errors (company-begin-backend backend))
         (cl-return t))))
   (unless company-candidates
-    (error "No other backend")))
+    (user-error "No other backend")))
 
 (defun company-require-match-p ()
   (let ((backend-value (company-call-backend 'require-match)))
@@ -1469,32 +1457,24 @@ prefix match (same case) will be prioritized."
               company-prefix)))
 
 (defun company--continue-failed (new-prefix)
-  (let ((input (buffer-substring-no-properties (point) company-point)))
-    (cond
-     ((company-auto-complete-p input)
-      ;; auto-complete
-      (save-excursion
-        (goto-char company-point)
-        (let ((company--auto-completion t))
-          (company-complete-selection))
-        nil))
-     ((and (or (not (company-require-match-p))
-               ;; Don't require match if the new prefix
-               ;; doesn't continue the old one, and the latter was a match.
-               (not (stringp new-prefix))
-               (<= (length new-prefix) (length company-prefix)))
-           (member company-prefix company-candidates))
-      ;; Last input was a success,
-      ;; but we're treating it as an abort + input anyway,
-      ;; like the `unique' case below.
-      (company-cancel 'non-unique))
-     ((company-require-match-p)
-      ;; Wrong incremental input, but required match.
-      (delete-char (- (length input)))
-      (ding)
-      (message "Matching input is required")
-      company-candidates)
-     (t (company-cancel)))))
+  (cond
+   ((and (or (not (company-require-match-p))
+             ;; Don't require match if the new prefix
+             ;; doesn't continue the old one, and the latter was a match.
+             (not (stringp new-prefix))
+             (<= (length new-prefix) (length company-prefix)))
+         (member company-prefix company-candidates))
+    ;; Last input was a success,
+    ;; but we're treating it as an abort + input anyway,
+    ;; like the `unique' case below.
+    (company-cancel 'non-unique))
+   ((company-require-match-p)
+    ;; Wrong incremental input, but required match.
+    (delete-char (- company-point (point)))
+    (ding)
+    (message "Matching input is required")
+    company-candidates)
+   (t (company-cancel))))
 
 (defun company--good-prefix-p (prefix)
   (and (stringp (company--prefix-str prefix)) ;excludes 'stop
@@ -1529,6 +1509,14 @@ prefix match (same case) will be prioritized."
       (setq company-prefix new-prefix)
       (company-update-candidates c)
       c)
+     ((company-auto-complete-p (buffer-substring-no-properties
+                                (point) company-point))
+      ;; auto-complete
+      (save-excursion
+        (goto-char company-point)
+        (let ((company--auto-completion t))
+          (company-complete-selection))
+        nil))
      ((not (company--incremental-p))
       (company-cancel))
      (t (company--continue-failed new-prefix)))))
@@ -1782,7 +1770,7 @@ each one wraps a part of the input string."
                company-search-filtering
                (lambda (candidate) (string-match re candidate))))
          (cc (company-calculate-candidates company-prefix)))
-    (unless cc (error "No match"))
+    (unless cc (user-error "No match"))
     (company-update-candidates cc)))
 
 (defun company--search-update-string (new)
@@ -1795,7 +1783,7 @@ each one wraps a part of the input string."
 (defun company--search-assert-input ()
   (company--search-assert-enabled)
   (when (string= company-search-string "")
-    (error "Empty search string")))
+    (user-error "Empty search string")))
 
 (defun company-search-repeat-forward ()
   "Repeat the incremental search in completion candidates forward."
@@ -1922,7 +1910,7 @@ Don't start this directly, use 
`company-search-candidates' or
   (company-assert-enabled)
   (unless company-search-mode
     (company-uninstall-map)
-    (error "Company not in search mode")))
+    (user-error "Company not in search mode")))
 
 (defun company-search-candidates ()
   "Start searching the completion candidates incrementally.
@@ -2159,7 +2147,7 @@ character, stripping the modifiers.  That character must 
be a digit."
   (when (company-manual-begin)
     (and (or (< n 1) (> n (- company-candidates-length
                              company-tooltip-offset)))
-         (error "No candidate number %d" n))
+         (user-error "No candidate number %d" n))
     (cl-decf n)
     (company-finish (nth (+ n company-tooltip-offset)
                          company-candidates))))
@@ -2251,7 +2239,7 @@ character, stripping the modifiers.  That character must 
be a digit."
     (company--electric-do
       (let* ((selected (nth company-selection company-candidates))
              (doc-buffer (or (company-call-backend 'doc-buffer selected)
-                             (error "No documentation available")))
+                             (user-error "No documentation available")))
              start)
         (when (consp doc-buffer)
           (setq start (cdr doc-buffer)
@@ -2268,7 +2256,7 @@ character, stripping the modifiers.  That character must 
be a digit."
     (company--electric-do
       (let* ((selected (nth company-selection company-candidates))
              (location (company-call-backend 'location selected))
-             (pos (or (cdr location) (error "No location available")))
+             (pos (or (cdr location) (user-error "No location available")))
              (buffer (or (and (bufferp (car location)) (car location))
                          (find-file-noselect (car location) t))))
         (setq other-window-scroll-buffer (get-buffer buffer))
@@ -2305,7 +2293,7 @@ character, stripping the modifiers.  That character must 
be a digit."
   (setq company-backend backend)
   ;; Return non-nil if active.
   (or (company-manual-begin)
-      (error "Cannot complete at point")))
+      (user-error "Cannot complete at point")))
 
 (defun company-begin-with (candidates
                            &optional prefix-length require-match callback)
@@ -2357,7 +2345,7 @@ If SHOW-VERSION is non-nil, show the version in the echo 
area."
                                     (setq backend b)
                                     (company-call-backend 'prefix))))
          cc annotations)
-    (when (stringp prefix)
+    (when (or (stringp prefix) (consp prefix))
       (let ((company-backend backend))
         (setq cc (company-call-backend 'candidates prefix)
               annotations
@@ -2860,8 +2848,9 @@ Returns a negative number if the tooltip should be 
displayed above point."
       (overlay-put ov 'window (selected-window)))))
 
 (defun company-pseudo-tooltip-guard ()
-  (cons
+  (list
    (save-excursion (beginning-of-visual-line))
+   (window-width)
    (let ((ov company-pseudo-tooltip-overlay)
          (overhang (save-excursion (end-of-visual-line)
                                    (- (line-end-position) (point)))))
@@ -2928,14 +2917,13 @@ Delay is determined by `company-tooltip-idle-delay'."
 
 (defvar-local company-preview-overlay nil)
 
-(defun company-preview-show-at-point (pos)
+(defun company-preview-show-at-point (pos completion)
   (company-preview-hide)
 
-  (let ((completion (nth company-selection company-candidates)))
-    (setq completion (copy-sequence (company--pre-render completion)))
-    (font-lock-append-text-property 0 (length completion)
-                                    'face 'company-preview
-                                    completion)
+  (setq completion (copy-sequence (company--pre-render completion)))
+  (font-lock-append-text-property 0 (length completion)
+                                  'face 'company-preview
+                                  completion)
     (font-lock-prepend-text-property 0 (length company-common)
                                      'face 'company-preview-common
                                      completion)
@@ -2972,7 +2960,7 @@ Delay is determined by `company-tooltip-idle-delay'."
       (let ((ov company-preview-overlay))
         (overlay-put ov (if ptf-workaround 'display 'after-string)
                      completion)
-        (overlay-put ov 'window (selected-window))))))
+        (overlay-put ov 'window (selected-window)))))
 
 (defun company-preview-hide ()
   (when company-preview-overlay
@@ -2983,7 +2971,8 @@ Delay is determined by `company-tooltip-idle-delay'."
   "`company-mode' frontend showing the selection as if it had been inserted."
   (pcase command
     (`pre-command (company-preview-hide))
-    (`post-command (company-preview-show-at-point (point)))
+    (`post-command (company-preview-show-at-point (point)
+                                                  (nth company-selection 
company-candidates)))
     (`hide (company-preview-hide))))
 
 (defun company-preview-if-just-one-frontend (command)
@@ -3003,6 +2992,21 @@ Delay is determined by `company-tooltip-idle-delay'."
   (when (overlayp company-pseudo-tooltip-overlay)
     (not (overlay-get company-pseudo-tooltip-overlay 'invisible))))
 
+(defun company-preview-common--show-p ()
+  "Returns whether the preview of common can be showed or not"
+  (and company-common
+       (or (eq (company-call-backend 'ignore-case) 'keep-prefix)
+           (string-prefix-p company-prefix company-common))))
+
+(defun company-preview-common-frontend (command)
+  "`company-mode' frontend preview the common part of candidates."
+  (when (or (not (eq command 'post-command))
+            (company-preview-common--show-p))
+    (pcase command
+      (`pre-command (company-preview-hide))
+      (`post-command (company-preview-show-at-point (point) company-common))
+      (`hide (company-preview-hide)))))
+
 ;;; echo 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defvar-local company-echo-last-msg nil)
@@ -3011,10 +3015,16 @@ Delay is determined by `company-tooltip-idle-delay'."
 
 (defvar company-echo-delay .01)
 
+(defcustom company-echo-truncate-lines t
+  "Whether frontend messages written to the echo area should be truncated."
+  :type 'boolean
+  :package-version '(company . "0.9.3"))
+
 (defun company-echo-show (&optional getter)
   (when getter
     (setq company-echo-last-msg (funcall getter)))
-  (let ((message-log-max nil))
+  (let ((message-log-max nil)
+        (message-truncate-lines company-echo-truncate-lines))
     (if company-echo-last-msg
         (message "%s" company-echo-last-msg)
       (message ""))))
diff --git a/packages/company/test/clang-tests.el 
b/packages/company/test/clang-tests.el
index 2b8b105..86f7382 100644
--- a/packages/company/test/clang-tests.el
+++ b/packages/company/test/clang-tests.el
@@ -43,3 +43,9 @@
 (ert-deftest company-clang-null-annotation ()
   (let ((str "char"))
     (should (null (company-clang 'annotation str)))))
+
+(ert-deftest company-clang-anon-union-annotation ()
+  (let ((u (propertize "u" 'meta "union (anonymous) u"))
+        (s (propertize "s" 'meta "struct (anonymous) s")))
+    (should (null (company-clang 'annotation u)))
+    (should (null (company-clang 'annotation s)))))
diff --git a/packages/company/test/core-tests.el 
b/packages/company/test/core-tests.el
index 89543b0..977f1cf 100644
--- a/packages/company/test/core-tests.el
+++ b/packages/company/test/core-tests.el
@@ -1,6 +1,6 @@
 ;;; core-tests.el --- company-mode tests  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015, 2016  Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2016, 2017  Free Software Foundation, Inc.
 
 ;; Author: Dmitry Gutov
 
@@ -333,6 +333,31 @@
         (company-call 'self-insert-command 1))
       (should (string= "abcd " (buffer-string))))))
 
+(ert-deftest company-auto-complete-with-electric-pair ()
+  (with-temp-buffer
+    (insert "foo(ab)")
+    (forward-char -1)
+    (company-mode)
+    (let (company-frontends
+          (company-auto-complete t)
+          (company-auto-complete-chars '(? ?\)))
+          (company-backends
+           (list (lambda (command &optional _)
+                   (cl-case command
+                     (prefix (buffer-substring 5 (point)))
+                     (candidates '("abcd" "abef"))))))
+          (electric-pair electric-pair-mode))
+      (unwind-protect
+          (progn
+            (electric-pair-mode)
+            (let (this-command)
+              (company-complete))
+            (let ((last-command-event ?\)))
+              (company-call 'self-insert-command 1)))
+        (unless electric-pair
+          (electric-pair-mode -1)))
+      (should (string= "foo(abcd)" (buffer-string))))))
+
 (ert-deftest company-no-auto-complete-when-idle ()
   (with-temp-buffer
     (insert "ab")
diff --git a/packages/company/test/frontends-tests.el 
b/packages/company/test/frontends-tests.el
index 9592bed..0f7c19e 100644
--- a/packages/company/test/frontends-tests.el
+++ b/packages/company/test/frontends-tests.el
@@ -83,10 +83,8 @@
     (save-window-excursion
       (set-window-buffer nil (current-buffer))
       (save-excursion (insert "\n"))
-      (let ((company-candidates-length 1)
-            (company-candidates '("123"))
-            (company-backend #'ignore))
-        (company-preview-show-at-point (point))
+      (let ((company-backend #'ignore))
+        (company-preview-show-at-point (point) "123")
         (let* ((ov company-preview-overlay)
                (str (overlay-get ov 'after-string)))
           (should (string= str "123"))



reply via email to

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