[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6a39f31 38/38: Merge commit '656ad10670512e135a0a5881f127b
From: |
Dmitry Gutov |
Subject: |
[elpa] master 6a39f31 38/38: Merge commit '656ad10670512e135a0a5881f127bb7a789ef8ca' from company |
Date: |
Sat, 25 Jul 2020 19:51:18 -0400 (EDT) |
branch: master
commit 6a39f31deebe5e2bae70e2d118cc8579e627b357
Merge: e58daf7 656ad10
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Merge commit '656ad10670512e135a0a5881f127bb7a789ef8ca' from company
---
packages/company/.travis.yml | 4 ++--
packages/company/NEWS.md | 14 +++++++++++++
packages/company/company-bbdb.el | 8 ++++---
packages/company/company-clang.el | 6 +++++-
packages/company/company-files.el | 7 +++++--
packages/company/company-keywords.el | 36 +++++++++++++++++++-------------
packages/company/company-tng.el | 39 +++++++++++++++++++----------------
packages/company/company-yasnippet.el | 37 +++++++++++++++++++++++++++++----
packages/company/company.el | 36 ++++++++++++++++++++------------
9 files changed, 130 insertions(+), 57 deletions(-)
diff --git a/packages/company/.travis.yml b/packages/company/.travis.yml
index 03933bf..18e928d 100644
--- a/packages/company/.travis.yml
+++ b/packages/company/.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/packages/company/NEWS.md b/packages/company/NEWS.md
index 45ab42a..f1f1d05 100644
--- a/packages/company/NEWS.md
+++ b/packages/company/NEWS.md
@@ -1,5 +1,19 @@
# History of user-visible changes
+## 2020-07-26 (0.9.13)
+
+* `company-clang`: error handling is more permissive.
+* `company-tng` stops disabling `post-completion` in backends
+ ([#946](https://github.com/company-mode/company-mode/pull/946)). Instead,
+ `company-tng-configure-default` disables snippet expansion in most popular
+ backends. If a backend you use needs this and is not covered, and you use
+ `company-tng`, disable snippet insertion by customizing a relevant option
+ provided by the backend. The result is better compatibility with LSP backends
+ because they currently depend on `post-completion` in all cases.
+* `company-keywords`: additions for C and C++.
+* `company-yasnippet` supports the `doc-buffer` action.
+* `company-bbdb` supports more headers.
+
## 2020-02-07 (0.9.12)
* Tooltip rendering bugfix.
diff --git a/packages/company/company-bbdb.el b/packages/company/company-bbdb.el
index 872e1fc..a68c34e 100644
--- a/packages/company/company-bbdb.el
+++ b/packages/company/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/packages/company/company-clang.el
b/packages/company/company-clang.el
index 272dd8f..1460e09 100644
--- a/packages/company/company-clang.el
+++ b/packages/company/company-clang.el
@@ -194,7 +194,11 @@ or automatically through a custom
`company-clang-prefix-guesser'."
(cmd (concat company-clang-executable " " (mapconcat 'identity args "
")))
(pattern (format company-clang--completion-pattern ""))
(message-truncate-lines t)
- (err (if (re-search-forward pattern nil t)
+ (err (if (and (re-search-forward pattern nil t)
+ ;; Something in the Windows build?
+ ;; Looks like Clang doesn't always include the error
text
+ ;; before completions (even if exited with error).
+ (> (match-beginning 0) (point-min)))
(buffer-substring-no-properties (point-min)
(1- (match-beginning 0)))
;; Warn the user more aggressively if no match was found.
diff --git a/packages/company/company-files.el
b/packages/company/company-files.el
index 91de1c6..8859266 100644
--- a/packages/company/company-files.el
+++ b/packages/company/company-files.el
@@ -127,6 +127,10 @@ The values should use the same format as
`completion-ignored-extensions'."
(and (equal (cdr old) (cdr new))
(string-prefix-p (car old) (car new))))
+(defun company-files--post-completion (arg)
+ (when (company-files--trailing-slash-p arg)
+ (delete-char -1)))
+
;;;###autoload
(defun company-files (command &optional arg &rest ignored)
"`company-mode' completion backend existing file names.
@@ -139,8 +143,7 @@ File paths with spaces are only supported inside strings."
(candidates (company-files--complete arg))
(location (cons (dired-noselect
(file-name-directory (directory-file-name arg))) 1))
- (post-completion (when (company-files--trailing-slash-p arg)
- (delete-char -1)))
+ (post-completion (company-files--post-completion arg))
(sorted t)
(no-cache t)))
diff --git a/packages/company/company-keywords.el
b/packages/company/company-keywords.el
index b6dfd1d..7cafb4c 100644
--- a/packages/company/company-keywords.el
+++ b/packages/company/company-keywords.el
@@ -35,22 +35,30 @@
(defvar company-keywords-alist
;; Please contribute corrections or additions.
`((c++-mode
- "alignas" "alignof" "asm" "auto" "bool" "break" "case" "catch" "char"
- "char16_t" "char32_t" "class" "const" "const_cast" "constexpr" "continue"
- "decltype" "default" "delete" "do" "double" "dynamic_cast" "else" "enum"
- "explicit" "export" "extern" "false" "final" "float" "for" "friend"
- "goto" "if" "inline" "int" "long" "mutable" "namespace" "new" "noexcept"
- "nullptr" "operator" "override"
- "private" "protected" "public" "register" "reinterpret_cast"
- "return" "short" "signed" "sizeof" "static" "static_assert"
- "static_cast" "struct" "switch" "template" "this" "thread_local"
- "throw" "true" "try" "typedef" "typeid" "typename"
- "union" "unsigned" "using" "virtual" "void" "volatile" "wchar_t" "while")
+ ;; from https://en.cppreference.com/w/cpp/keyword
+ "alignas" "alignof" "and" "and_eq" "asm" "atomic_cancel" "atomic_commit"
+ "atomic_noexcept" "auto" "bitand" "bitor" "bool" "break" "case" "catch"
+ "char" "char16_t" "char32_t" "char8_t" "class" "co_await" "co_return"
+ "co_yield" "compl" "concept" "const" "const_cast" "consteval" "constexpr"
+ "constinit" "continue" "decltype" "default" "delete" "do" "double"
+ "dynamic_cast" "else" "enum" "explicit" "export" "extern" "false" "final"
+ "float" "for" "friend" "goto" "if" "import" "inline" "int" "long" "module"
+ "mutable" "namespace" "new" "noexcept" "not" "not_eq" "nullptr" "operator"
+ "or" "or_eq" "override" "private" "protected" "public" "reflexpr"
"register"
+ "reinterpret_cast" "requires" "return" "short" "signed" "sizeof" "static"
+ "static_assert" "static_cast" "struct" "switch" "synchronized" "template"
+ "this" "thread_local" "throw" "true" "try" "typedef" "typeid" "typename"
+ "union" "unsigned" "using" "virtual" "void" "volatile" "wchar_t" "while"
+ "xor" "xor_eq")
(c-mode
+ ;; from https://en.cppreference.com/w/c/keyword
+ "_Alignas" "_Alignof" "_Atomic" "_Bool" "_Complex" "_Generic" "_Imaginary"
+ "_Noreturn" "_Static_assert" "_Thread_local"
"auto" "break" "case" "char" "const" "continue" "default" "do"
- "double" "else" "enum" "extern" "float" "for" "goto" "if" "int" "long"
- "register" "return" "short" "signed" "sizeof" "static" "struct"
- "switch" "typedef" "union" "unsigned" "void" "volatile" "while")
+ "double" "else" "enum" "extern" "float" "for" "goto" "if" "inline"
+ "int" "long" "register" "restrict" "return" "short" "signed" "sizeof"
+ "static" "struct" "switch" "typedef" "union" "unsigned" "void" "volatile"
+ "while")
(csharp-mode
"abstract" "add" "alias" "as" "base" "bool" "break" "byte" "case"
"catch" "char" "checked" "class" "const" "continue" "decimal" "default"
diff --git a/packages/company/company-tng.el b/packages/company/company-tng.el
index 9b495c6..404d436 100644
--- a/packages/company/company-tng.el
+++ b/packages/company/company-tng.el
@@ -1,6 +1,6 @@
;;; company-tng.el --- company-mode configuration for single-button interaction
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2020 Free Software Foundation, Inc.
;; Author: Nikita Leshenko
@@ -64,15 +64,19 @@
;; We recommend to disable `company-require-match' to allow free typing at any
;; point.
;;
-;; By default, company-tng doesn't work well with backends that use
-;; `post-completion' (for actions such as expanding snippets in
-;; company-yasnippet or company-template). In company-tng, completion
candidates
+;; By default, company-tng doesn't work well with backends that insert function
+;; arguments into the buffer and (optionally) expand them into a snippet
+;; (usually performed in `post-completion' using yasnippet or
company-template).
+;; In company-tng, completion candidates
;; are inserted into the buffer as the user selects them and the completion is
;; finished implicitly when the user continues typing after selecting a
;; candidate. Modifying the buffer (by expanding a snippet) when the user
;; continues typing would be surprising and undesirable, since the candidate
was
-;; already inserted into the buffer. For this reason company-tng disables
-;; `post-completion' in all backends.
+;; already inserted into the buffer.
+;;
+;; For this reason `company-tng-configure-default' disables arguments insertion
+;; for a number of popular backends. If the backend you are using is not among
+;; them, you might have to configure it not to do that yourself.
;;
;; YASnippet and company-tng both use TAB, which causes conflicts. The
;; recommended way to use YASnippet with company-tng is to choose a different
@@ -122,8 +126,12 @@ confirm the selection and finish the completion."
(when (and company-selection-changed
(not (company--company-command-p (this-command-keys))))
(company--unread-this-command-keys)
- (setq this-command 'company-complete-selection)
- (advice-add 'company-call-backend :before-until
'company-tng--supress-post-completion)))))
+ (setq this-command 'company-complete-selection)))))
+
+(defvar company-clang-insert-arguments)
+(defvar company-semantic-insert-arguments)
+(defvar company-rtags-insert-arguments)
+(defvar lsp-enable-snippet)
;;;###autoload
(defun company-tng-configure-default ()
@@ -132,6 +140,11 @@ confirm the selection and finish the completion."
(setq company-frontends '(company-tng-frontend
company-pseudo-tooltip-frontend
company-echo-metadata-frontend))
+ (setq company-clang-insert-arguments nil
+ company-semantic-insert-arguments nil
+ company-rtags-insert-arguments nil
+ lsp-enable-snippet nil)
+ (advice-add #'eglot--snippet-expansion-fn :override #'ignore)
(let ((keymap company-active-map))
(define-key keymap [return] nil)
(define-key keymap (kbd "RET") nil)
@@ -180,15 +193,5 @@ made explicitly (i.e. `company-selection-changed' is true)"
(setf (nth 3 args) nil))
args)
-(defun company-tng--supress-post-completion (command &rest args)
- "Installed as a :before-until advice on `company-call-backend' and
-prevents the 'post-completion command from being delivered to the backend
-for the next iteration. post-completion do things like expand snippets
-which are undesirable because completions are implicit in company-tng and
-visible side-effects after the completion are surprising."
- (when (eq command 'post-completion)
- (advice-remove 'company-call-backend 'company-tng--supress-post-completion)
- t))
-
(provide 'company-tng)
;;; company-tng.el ends here
diff --git a/packages/company/company-yasnippet.el
b/packages/company/company-yasnippet.el
index 5c88017..454ba83 100644
--- a/packages/company/company-yasnippet.el
+++ b/packages/company/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/packages/company/company.el b/packages/company/company.el
index 0b9dbe7..89e4051 100644
--- a/packages/company/company.el
+++ b/packages/company/company.el
@@ -5,7 +5,7 @@
;; Author: Nikolaj Schumacher
;; Maintainer: Dmitry Gutov <dgutov@yandex.ru>
;; URL: http://company-mode.github.io/
-;; Version: 0.9.12
+;; Version: 0.9.13
;; Keywords: abbrev, convenience, matching
;; Package-Requires: ((emacs "24.3"))
@@ -94,6 +94,8 @@ attention to case differences."
(((class color) (min-colors 88) (background light))
(:background "cornsilk"))
(((class color) (min-colors 88) (background dark))
+ (:background "yellow"))
+ (t
(:background "yellow")))
"Face used for the tooltip.")
@@ -858,7 +860,8 @@ means that `company-mode' is always turned on except in
`message-mode' buffers."
;; Hack:
;; Emacs calculates the active keymaps before reading the event. That means we
;; cannot change the keymap from a timer. So we send a bogus command.
-;; XXX: Even in Emacs 24.4, seems to be needed in the terminal.
+;; XXX: Seems not to be needed anymore in Emacs 24.4
+;; Apparently, starting with emacs-mirror/emacs@99d0d6dc23.
(defun company-ignore ()
(interactive)
(setq this-command last-command))
@@ -1146,7 +1149,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 ()
@@ -1445,7 +1449,8 @@ prefix match (same case) will be prioritized."
(eq tick (buffer-chars-modified-tick))
(eq pos (point))
(when (company-auto-begin)
- (company-input-noop)
+ (when (version< emacs-version "24.3.50")
+ (company-input-noop))
(let ((this-command 'company-idle-begin))
(company-post-command)))))
@@ -1574,9 +1579,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 +2286,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)
@@ -2455,11 +2460,16 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
(insert "\n")
(insert "Used backend: " (pp-to-string backend))
(insert "\n")
+ (when (if (listp backend)
+ (memq 'company-capf backend)
+ (eq backend 'company-capf))
+ (insert "Value of c-a-p-f: "
+ (pp-to-string completion-at-point-functions)))
(insert "Major mode: " mode)
(insert "\n")
(insert "Prefix: " (pp-to-string prefix))
(insert "\n")
- (insert (message "Completions:"))
+ (insert "Completions:")
(unless cc (insert " none"))
(if (eq annotations 'error)
(insert "(error fetching)")
@@ -2527,7 +2537,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 +2798,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
@@ -3165,7 +3175,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.
@@ -3174,10 +3184,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)
- [elpa] master 033358c 11/38: Merge pull request #965 from taigacute/master, (continued)
- [elpa] master 033358c 11/38: Merge pull request #965 from taigacute/master, Dmitry Gutov, 2020/07/25
- [elpa] master 04d3766 14/38: config the company-yasnippet-doc buffer-file-name, Dmitry Gutov, 2020/07/25
- [elpa] master e25c459 18/38: let-bind buffer-file-name instead of setting it, Dmitry Gutov, 2020/07/25
- [elpa] master d38d64b 20/38: Keyworks complete for c++-mode and c-mode, Dmitry Gutov, 2020/07/25
- [elpa] master b9b0577 22/38: Make company-auto-complete condition more reliable, Dmitry Gutov, 2020/07/25
- [elpa] master 56a846c 25/38: Add a NEWS entry, Dmitry Gutov, 2020/07/25
- [elpa] master 6cf5169 23/38: Update copyright years, Dmitry Gutov, 2020/07/25
- [elpa] master c59c85b 24/38: Merge branch 'master' into company-tng-with-post-completion, Dmitry Gutov, 2020/07/25
- [elpa] master e93b3dc 30/38: [company-files] Make post-completion command a dedicated function, Dmitry Gutov, 2020/07/25
- [elpa] master 1c7a872 31/38: Merge pull request #983 from qhuyduong/make-post-completion-command-dedicated-function, Dmitry Gutov, 2020/07/25
- [elpa] master 6a39f31 38/38: Merge commit '656ad10670512e135a0a5881f127bb7a789ef8ca' from company,
Dmitry Gutov <=
- [elpa] master 955f80e 19/38: company-doc-buffer: Make sure to reset the major mode, Dmitry Gutov, 2020/07/25
- [elpa] master db0596b 26/38: Merge branch 'master' of github.com:company-mode/company-mode, Dmitry Gutov, 2020/07/25
- [elpa] master 1f56bec 36/38: company-diag: Print out completion-at-point-functions too, Dmitry Gutov, 2020/07/25
- [elpa] master 6333fc4 29/38: Mention when, Dmitry Gutov, 2020/07/25
- [elpa] master f24b794 32/38: Make sure the error text is present before trying to use it, Dmitry Gutov, 2020/07/25
- [elpa] master 7d9d72c 33/38: Set tooltip background color for terminals with less than 88 colors, Dmitry Gutov, 2020/07/25
- [elpa] master 8ec972b 17/38: Defer company-reformat a little, Dmitry Gutov, 2020/07/25
- [elpa] master 61ddd9a 21/38: Merge pull request #968 from condy0919/master, Dmitry Gutov, 2020/07/25
- [elpa] master fdde3d1 27/38: Merge pull request #946 from company-mode/company-tng-with-post-completion, Dmitry Gutov, 2020/07/25
- [elpa] master 21f3b0f 28/38: Revert "company-input-noop still seems to be needed in the terminal", Dmitry Gutov, 2020/07/25