From 9dee38b55b95950d93eeb2f12449d8da08a0d58a Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sat, 21 Dec 2024 17:34:53 +0100 Subject: [PATCH] update company Signed-off-by: Andreas Gerler --- .../company-dabbrev-code.el | 105 -- elpa/company-20230703.2021/company-elisp.el | 226 --- elpa/company-20230703.2021/company-pkg.el | 14 - .../company-abbrev.el | 16 +- .../company-autoloads.el | 206 +-- .../company-bbdb.el | 12 +- .../company-capf.el | 222 +-- .../company-clang.el | 4 +- .../company-cmake.el | 13 +- .../company-css.el | 0 .../company-dabbrev-code.el | 177 ++ .../company-dabbrev.el | 81 +- .../company-etags.el | 60 +- .../company-files.el | 62 +- .../company-gtags.el | 11 +- .../company-ispell.el | 58 +- .../company-keywords.el | 21 +- .../company-nxml.el | 15 +- .../company-oddmuse.el | 6 +- elpa/company-20241210.2019/company-pkg.el | 9 + .../company-semantic.el | 14 +- .../company-template.el | 5 +- .../company-tempo.el | 6 +- .../company-tng.el | 8 +- .../company-yasnippet.el | 28 +- .../company.el | 1427 +++++++++++++---- .../company.info | 594 ++++--- .../dir | 0 .../images/small/echo-meta.png | Bin .../images/small/echo-qa.png | Bin .../images/small/echo-strip-qa.png | Bin .../images/small/echo-strip.png | Bin .../images/small/echo.png | Bin .../images/small/preview-dark.png | Bin .../images/small/preview-light.png | Bin .../images/small/tooltip-annotations.png | Bin .../images/small/tooltip-faces-light.png | Bin .../images/small/tooltip-filter.png | Bin .../images/small/tooltip-flip.png | Bin .../images/small/tooltip-icon-bg.png | Bin .../images/small/tooltip-icon-face.png | Bin .../images/small/tooltip-icons-dot.png | Bin .../images/small/tooltip-icons-text.png | Bin .../images/small/tooltip-icons-vscode.png | Bin .../images/small/tooltip-limit.png | Bin .../images/small/tooltip-margin.png | Bin .../images/small/tooltip-minimum-above.png | Bin .../images/small/tooltip-minimum-below.png | Bin .../images/small/tooltip-offset-display.png | Bin .../images/small/tooltip-qa-faces-light.png | Bin .../images/small/tooltip-quick-access.png | Bin .../images/small/tooltip-search.png | Bin 52 files changed, 2047 insertions(+), 1353 deletions(-) delete mode 100644 elpa/company-20230703.2021/company-dabbrev-code.el delete mode 100644 elpa/company-20230703.2021/company-elisp.el delete mode 100644 elpa/company-20230703.2021/company-pkg.el rename elpa/{company-20230703.2021 => company-20241210.2019}/company-abbrev.el (76%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-autoloads.el (67%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-bbdb.el (86%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-capf.el (52%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-clang.el (99%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-cmake.el (96%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-css.el (100%) create mode 100644 elpa/company-20241210.2019/company-dabbrev-code.el rename elpa/{company-20230703.2021 => company-20241210.2019}/company-dabbrev.el (75%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-etags.el (58%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-files.el (75%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-gtags.el (95%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-ispell.el (56%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-keywords.el (97%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-nxml.el (93%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-oddmuse.el (91%) create mode 100644 elpa/company-20241210.2019/company-pkg.el rename elpa/{company-20230703.2021 => company-20241210.2019}/company-semantic.el (94%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-template.el (98%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-tempo.el (92%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-tng.el (97%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company-yasnippet.el (88%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company.el (74%) rename elpa/{company-20230703.2021 => company-20241210.2019}/company.info (83%) rename elpa/{company-20230703.2021 => company-20241210.2019}/dir (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/echo-meta.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/echo-qa.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/echo-strip-qa.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/echo-strip.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/echo.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/preview-dark.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/preview-light.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-annotations.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-faces-light.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-filter.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-flip.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-icon-bg.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-icon-face.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-icons-dot.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-icons-text.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-icons-vscode.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-limit.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-margin.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-minimum-above.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-minimum-below.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-offset-display.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-qa-faces-light.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-quick-access.png (100%) rename elpa/{company-20230703.2021 => company-20241210.2019}/images/small/tooltip-search.png (100%) diff --git a/elpa/company-20230703.2021/company-dabbrev-code.el b/elpa/company-20230703.2021/company-dabbrev-code.el deleted file mode 100644 index 6e26bff5..00000000 --- a/elpa/company-20230703.2021/company-dabbrev-code.el +++ /dev/null @@ -1,105 +0,0 @@ -;;; company-dabbrev-code.el --- dabbrev-like company-mode backend for code -*- lexical-binding: t -*- - -;; Copyright (C) 2009-2011, 2013-2016, 2021 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; This file is part of GNU Emacs. - -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - - -;;; Commentary: -;; - -;;; Code: - -(require 'company) -(require 'company-dabbrev) -(require 'cl-lib) - -(defgroup company-dabbrev-code nil - "dabbrev-like completion backend for code." - :group 'company) - -(defcustom company-dabbrev-code-modes - '(prog-mode - batch-file-mode csharp-mode css-mode erlang-mode haskell-mode jde-mode - lua-mode python-mode) - "Modes that use `company-dabbrev-code'. -In all these modes (and their derivatives) `company-dabbrev-code' will -complete only symbols, not text in comments or strings. In other modes -`company-dabbrev-code' will pass control to other backends -\(e.g. `company-dabbrev'\). Value t means complete in all modes." - :type '(choice (repeat :tag "Some modes" (symbol :tag "Major mode")) - (const :tag "All modes" t))) - -(defcustom company-dabbrev-code-other-buffers t - "Determines whether `company-dabbrev-code' should search other buffers. -If `all', search all other buffers, except the ignored ones. If t, search -buffers with the same major mode. If `code', search all buffers with major -modes in `company-dabbrev-code-modes', or derived from one of them. See -also `company-dabbrev-code-time-limit'." - :type '(choice (const :tag "Off" nil) - (const :tag "Same major mode" t) - (const :tag "Code major modes" code) - (const :tag "All" all))) - -(defcustom company-dabbrev-code-time-limit .1 - "Determines how long `company-dabbrev-code' should look for matches." - :type '(choice (const :tag "Off" nil) - (number :tag "Seconds"))) - -(defcustom company-dabbrev-code-everywhere nil - "Non-nil to offer completions in comments and strings." - :type 'boolean) - -(defcustom company-dabbrev-code-ignore-case nil - "Non-nil to ignore case when collecting completion candidates." - :type 'boolean) - -(defun company-dabbrev-code--make-regexp (prefix) - (concat "\\_<" (if (equal prefix "") - "\\([a-zA-Z]\\|\\s_\\)" - (regexp-quote prefix)) - "\\(\\sw\\|\\s_\\)*\\_>")) - -;;;###autoload -(defun company-dabbrev-code (command &optional arg &rest _ignored) - "dabbrev-like `company-mode' backend for code. -The backend looks for all symbols in the current buffer that aren't in -comments or strings." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-dabbrev-code)) - (prefix (and (or (eq t company-dabbrev-code-modes) - (apply #'derived-mode-p company-dabbrev-code-modes)) - (or company-dabbrev-code-everywhere - (not (company-in-string-or-comment))) - (or (company-grab-symbol) 'stop))) - (candidates (let ((case-fold-search company-dabbrev-code-ignore-case)) - (company-dabbrev--search - (company-dabbrev-code--make-regexp arg) - company-dabbrev-code-time-limit - (pcase company-dabbrev-code-other-buffers - (`t (list major-mode)) - (`code company-dabbrev-code-modes) - (`all `all)) - (not company-dabbrev-code-everywhere)))) - (kind 'text) - (ignore-case company-dabbrev-code-ignore-case) - (duplicates t))) - -(provide 'company-dabbrev-code) -;;; company-dabbrev-code.el ends here diff --git a/elpa/company-20230703.2021/company-elisp.el b/elpa/company-20230703.2021/company-elisp.el deleted file mode 100644 index 98d01482..00000000 --- a/elpa/company-20230703.2021/company-elisp.el +++ /dev/null @@ -1,226 +0,0 @@ -;;; company-elisp.el --- company-mode completion backend for Emacs Lisp -*- lexical-binding: t -*- - -;; Copyright (C) 2009-2015, 2017, 2020 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; This file is part of GNU Emacs. - -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - - -;;; Commentary: -;; -;; In newer versions of Emacs, company-capf is used instead. - -;;; Code: - -(require 'company) -(require 'cl-lib) -(require 'help-mode) -(require 'find-func) - -(defgroup company-elisp nil - "Completion backend for Emacs Lisp." - :group 'company) - -(defcustom company-elisp-detect-function-context t - "If enabled, offer Lisp functions only in appropriate contexts. -Functions are offered for completion only after \\=' and \(." - :type '(choice (const :tag "Off" nil) - (const :tag "On" t))) - -(defcustom company-elisp-show-locals-first t - "If enabled, locally bound variables and functions are displayed -first in the candidates list." - :type '(choice (const :tag "Off" nil) - (const :tag "On" t))) - -(defun company-elisp--prefix () - (let ((prefix (company-grab-symbol))) - (if prefix - (when (if (company-in-string-or-comment) - (= (char-before (- (point) (length prefix))) ?`) - (company-elisp--should-complete)) - prefix) - 'stop))) - -(defun company-elisp--predicate (symbol) - (or (boundp symbol) - (fboundp symbol) - (facep symbol) - (featurep symbol))) - -(defun company-elisp--fns-regexp (&rest names) - (concat "\\_<\\(?:cl-\\)?" (regexp-opt names) "\\*?\\_>")) - -(defvar company-elisp-parse-limit 30) -(defvar company-elisp-parse-depth 100) - -(defvar company-elisp-defun-names '("defun" "defmacro" "defsubst")) - -(defvar company-elisp-var-binding-regexp - (apply #'company-elisp--fns-regexp "let" "lambda" "lexical-let" - company-elisp-defun-names) - "Regular expression matching head of a multiple variable bindings form.") - -(defvar company-elisp-var-binding-regexp-1 - (company-elisp--fns-regexp "dolist" "dotimes") - "Regular expression matching head of a form with one variable binding.") - -(defvar company-elisp-fun-binding-regexp - (company-elisp--fns-regexp "flet" "labels") - "Regular expression matching head of a function bindings form.") - -(defvar company-elisp-defuns-regexp - (concat "([ \t\n]*" - (apply #'company-elisp--fns-regexp company-elisp-defun-names))) - -(defun company-elisp--should-complete () - (let ((start (point)) - (depth (car (syntax-ppss)))) - (not - (when (> depth 0) - (save-excursion - (up-list (- depth)) - (when (looking-at company-elisp-defuns-regexp) - (forward-char) - (forward-sexp 1) - (unless (= (point) start) - (condition-case nil - (let ((args-end (scan-sexps (point) 2))) - (or (null args-end) - (> args-end start))) - (scan-error - t))))))))) - -(defun company-elisp--locals (prefix functions-p) - (let ((regexp (concat "[ \t\n]*\\(\\_<" (regexp-quote prefix) - "\\(?:\\sw\\|\\s_\\)*\\_>\\)")) - (pos (point)) - res) - (condition-case nil - (save-excursion - (dotimes (_ company-elisp-parse-depth) - (up-list -1) - (save-excursion - (when (eq (char-after) ?\() - (forward-char 1) - (when (ignore-errors - (save-excursion (forward-list) - (<= (point) pos))) - (skip-chars-forward " \t\n") - (cond - ((looking-at (if functions-p - company-elisp-fun-binding-regexp - company-elisp-var-binding-regexp)) - (down-list 1) - (condition-case nil - (dotimes (_ company-elisp-parse-limit) - (save-excursion - (when (looking-at "[ \t\n]*(") - (down-list 1)) - (when (looking-at regexp) - (cl-pushnew (match-string-no-properties 1) res))) - (forward-sexp)) - (scan-error nil))) - ((unless functions-p - (looking-at company-elisp-var-binding-regexp-1)) - (down-list 1) - (when (looking-at regexp) - (cl-pushnew (match-string-no-properties 1) res))))))))) - (scan-error nil)) - res)) - -(defun company-elisp-candidates (prefix) - (let* ((predicate (company-elisp--candidates-predicate prefix)) - (locals (company-elisp--locals prefix (eq predicate 'fboundp))) - (globals (company-elisp--globals prefix predicate)) - (locals (cl-loop for local in locals - when (not (member local globals)) - collect local))) - (if company-elisp-show-locals-first - (append (sort locals 'string<) - (sort globals 'string<)) - (append locals globals)))) - -(defun company-elisp--globals (prefix predicate) - (all-completions prefix obarray predicate)) - -(defun company-elisp--candidates-predicate (prefix) - (let* ((completion-ignore-case nil) - (beg (- (point) (length prefix))) - (before (char-before beg))) - (if (and company-elisp-detect-function-context - (not (memq before '(?' ?`)))) - (if (and (eq before ?\() - (not - (save-excursion - (ignore-errors - (goto-char (1- beg)) - (or (company-elisp--before-binding-varlist-p) - (progn - (up-list -1) - (company-elisp--before-binding-varlist-p))))))) - 'fboundp - 'boundp) - 'company-elisp--predicate))) - -(defun company-elisp--before-binding-varlist-p () - (save-excursion - (and (prog1 (search-backward "(") - (forward-char 1)) - (looking-at company-elisp-var-binding-regexp)))) - -(defun company-elisp--doc (symbol) - (let* ((symbol (intern symbol)) - (doc (if (fboundp symbol) - (documentation symbol t) - (documentation-property symbol 'variable-documentation t)))) - (and (stringp doc) - (string-match ".*$" doc) - (match-string 0 doc)))) - -;;;###autoload -(defun company-elisp (command &optional arg &rest _ignored) - "`company-mode' completion backend for Emacs Lisp." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-elisp)) - (prefix (and (derived-mode-p 'emacs-lisp-mode 'inferior-emacs-lisp-mode) - (company-elisp--prefix))) - (candidates (company-elisp-candidates arg)) - (sorted company-elisp-show-locals-first) - (meta (company-elisp--doc arg)) - (doc-buffer (let ((symbol (intern arg))) - (save-window-excursion - (ignore-errors - (cond - ((fboundp symbol) (describe-function symbol)) - ((boundp symbol) (describe-variable symbol)) - ((featurep symbol) (describe-package symbol)) - ((facep symbol) (describe-face symbol)) - (t (signal 'user-error nil))) - (help-buffer))))) - (location (let ((sym (intern arg))) - (cond - ((fboundp sym) (find-definition-noselect sym nil)) - ((boundp sym) (find-definition-noselect sym 'defvar)) - ((featurep sym) (cons (find-file-noselect (find-library-name - (symbol-name sym))) - 0)) - ((facep sym) (find-definition-noselect sym 'defface))))))) - -(provide 'company-elisp) -;;; company-elisp.el ends here diff --git a/elpa/company-20230703.2021/company-pkg.el b/elpa/company-20230703.2021/company-pkg.el deleted file mode 100644 index 1405e1e2..00000000 --- a/elpa/company-20230703.2021/company-pkg.el +++ /dev/null @@ -1,14 +0,0 @@ -(define-package "company" "20230703.2021" "Modular text completion framework" - '((emacs "25.1")) - :commit "3ec40b0a0ea751b6c48f24abd58c8304deb53014" :authors - '(("Nikolaj Schumacher")) - :maintainers - '(("Dmitry Gutov" . "dgutov@yandex.ru")) - :maintainer - '("Dmitry Gutov" . "dgutov@yandex.ru") - :keywords - '("abbrev" "convenience" "matching") - :url "http://company-mode.github.io/") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/company-20230703.2021/company-abbrev.el b/elpa/company-20241210.2019/company-abbrev.el similarity index 76% rename from elpa/company-20230703.2021/company-abbrev.el rename to elpa/company-20241210.2019/company-abbrev.el index b8f81c47..e074d3af 100644 --- a/elpa/company-20230703.2021/company-abbrev.el +++ b/elpa/company-20241210.2019/company-abbrev.el @@ -1,6 +1,6 @@ -;;; company-abbrev.el --- company-mode completion backend for abbrev +;;; company-abbrev.el --- company-mode completion backend for abbrev -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2015, 2021 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2015, 2021, 2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -29,21 +29,23 @@ (require 'cl-lib) (require 'abbrev) -(defun company-abbrev-insert (match) +(defun company-abbrev-insert (_match) "Replace MATCH with the expanded abbrev." (expand-abbrev)) ;;;###autoload -(defun company-abbrev (command &optional arg &rest ignored) +(defun company-abbrev (command &optional arg &rest _ignored) "`company-mode' completion backend for abbrev." (interactive (list 'interactive)) (cl-case command (interactive (company-begin-backend 'company-abbrev 'company-abbrev-insert)) (prefix (company-grab-symbol)) - (candidates (nconc - (delete "" (all-completions arg global-abbrev-table)) - (delete "" (all-completions arg local-abbrev-table)))) + (candidates (apply + #'nconc + (mapcar (lambda (table) + (delete "" (all-completions arg table))) + (abbrev--active-tables)))) (kind 'snippet) (meta (abbrev-expansion arg)) (post-completion (expand-abbrev)))) diff --git a/elpa/company-20230703.2021/company-autoloads.el b/elpa/company-20241210.2019/company-autoloads.el similarity index 67% rename from elpa/company-20230703.2021/company-autoloads.el rename to elpa/company-20241210.2019/company-autoloads.el index 12a21673..73f3ebb8 100644 --- a/elpa/company-20230703.2021/company-autoloads.el +++ b/elpa/company-20241210.2019/company-autoloads.el @@ -1,33 +1,22 @@ -;;; company-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; company-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + ;;; Code: -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (autoloads nil "company" "company.el" (0 0 0 0)) ;;; Generated autoloads from company.el (autoload 'company-mode "company" "\ \"complete anything\"; is an in-buffer completion framework. + Completion starts automatically, depending on the values `company-idle-delay' and `company-minimum-prefix-length'. -This is a minor mode. If called interactively, toggle the -`Company mode' mode. If the prefix argument is positive, enable -the mode, and if it is zero or negative, disable the mode. - -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. - -To check whether the minor mode is enabled in the current buffer, -evaluate `company-mode'. - -The mode's hook is called both when the mode is enabled and when -it is disabled. - Completion can be controlled with the commands: `company-complete-common', `company-complete-selection', `company-complete', `company-select-next', `company-select-previous'. If these commands are @@ -51,10 +40,22 @@ keymap during active completions (`company-active-map'): \\{company-active-map} -\(fn &optional ARG)" t nil) +This is a minor mode. If called interactively, toggle the `Company +mode' mode. If the prefix argument is positive, enable the mode, and if +it is zero or negative, disable the mode. -(put 'global-company-mode 'globalized-minor-mode t) +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate the variable `company-mode'. +The mode's hook is called both when the mode is enabled and when it is +disabled. + +(fn &optional ARG)" t) +(put 'global-company-mode 'globalized-minor-mode t) (defvar global-company-mode nil "\ Non-nil if Global Company mode is enabled. See the `global-company-mode' command @@ -62,9 +63,7 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `global-company-mode'.") - (custom-autoload 'global-company-mode "company" nil) - (autoload 'global-company-mode "company" "\ Toggle Company mode in all buffers. With prefix ARG, enable Global Company mode if ARG is positive; @@ -79,93 +78,71 @@ do it. See `company-mode' for more information on Company mode. -\(fn &optional ARG)" t nil) - -(autoload 'company-manual-begin "company" nil t nil) +(fn &optional ARG)" t) +(autoload 'company-manual-begin "company" "\ +Start the completion interface. +Unlike `company-complete-selection' or `company-complete', this command +doesn't cause any immediate changes to the buffer text." t) (autoload 'company-complete "company" "\ Insert the common part of all candidates or the current selection. The first time this is called, the common part is inserted, the second time, or when the selection has been changed, the selected candidate is -inserted." t nil) - +inserted." t) (register-definition-prefixes "company" '("company-")) -;;;*** -;;;### (autoloads nil "company-abbrev" "company-abbrev.el" (0 0 0 -;;;;;; 0)) ;;; Generated autoloads from company-abbrev.el (autoload 'company-abbrev "company-abbrev" "\ `company-mode' completion backend for abbrev. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-abbrev" '("company-abbrev-insert")) -;;;*** -;;;### (autoloads nil "company-bbdb" "company-bbdb.el" (0 0 0 0)) ;;; Generated autoloads from company-bbdb.el (autoload 'company-bbdb "company-bbdb" "\ `company-mode' completion backend for BBDB. -\(fn COMMAND &optional ARG &rest IGNORE)" t nil) - +(fn COMMAND &optional ARG &rest IGNORE)" t) (register-definition-prefixes "company-bbdb" '("company-bbdb-")) -;;;*** -;;;### (autoloads nil "company-capf" "company-capf.el" (0 0 0 0)) ;;; Generated autoloads from company-capf.el (register-definition-prefixes "company-capf" '("company-")) -;;;*** -;;;### (autoloads nil "company-clang" "company-clang.el" (0 0 0 0)) ;;; Generated autoloads from company-clang.el (register-definition-prefixes "company-clang" '("company-clang")) -;;;*** -;;;### (autoloads nil "company-cmake" "company-cmake.el" (0 0 0 0)) ;;; Generated autoloads from company-cmake.el (register-definition-prefixes "company-cmake" '("company-cmake")) -;;;*** -;;;### (autoloads nil "company-css" "company-css.el" (0 0 0 0)) ;;; Generated autoloads from company-css.el (autoload 'company-css "company-css" "\ `company-mode' completion backend for `css-mode'. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-css" '("company-css-")) -;;;*** -;;;### (autoloads nil "company-dabbrev" "company-dabbrev.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from company-dabbrev.el (autoload 'company-dabbrev "company-dabbrev" "\ dabbrev-like `company-mode' completion backend. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-dabbrev" '("company-dabbrev-")) -;;;*** -;;;### (autoloads nil "company-dabbrev-code" "company-dabbrev-code.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from company-dabbrev-code.el (autoload 'company-dabbrev-code "company-dabbrev-code" "\ @@ -173,37 +150,19 @@ dabbrev-like `company-mode' backend for code. The backend looks for all symbols in the current buffer that aren't in comments or strings. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -(register-definition-prefixes "company-dabbrev-code" '("company-dabbrev-code-")) +(fn COMMAND &optional ARG &rest REST)" t) +(register-definition-prefixes "company-dabbrev-code" '("company-dabbrev-")) -;;;*** -;;;### (autoloads nil "company-elisp" "company-elisp.el" (0 0 0 0)) -;;; Generated autoloads from company-elisp.el - -(autoload 'company-elisp "company-elisp" "\ -`company-mode' completion backend for Emacs Lisp. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -(register-definition-prefixes "company-elisp" '("company-elisp-")) - -;;;*** - -;;;### (autoloads nil "company-etags" "company-etags.el" (0 0 0 0)) ;;; Generated autoloads from company-etags.el (autoload 'company-etags "company-etags" "\ `company-mode' completion backend for etags. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest REST)" t) (register-definition-prefixes "company-etags" '("company-etags-")) -;;;*** -;;;### (autoloads nil "company-files" "company-files.el" (0 0 0 0)) ;;; Generated autoloads from company-files.el (autoload 'company-files "company-files" "\ @@ -211,109 +170,78 @@ comments or strings. Completions works for proper absolute and relative files paths. File paths with spaces are only supported inside strings. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest REST)" t) (register-definition-prefixes "company-files" '("company-file")) -;;;*** -;;;### (autoloads nil "company-gtags" "company-gtags.el" (0 0 0 0)) ;;; Generated autoloads from company-gtags.el (autoload 'company-gtags "company-gtags" "\ `company-mode' completion backend for GNU Global. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-gtags" '("company-gtags-")) -;;;*** -;;;### (autoloads nil "company-ispell" "company-ispell.el" (0 0 0 -;;;;;; 0)) ;;; Generated autoloads from company-ispell.el (autoload 'company-ispell "company-ispell" "\ `company-mode' completion backend using Ispell. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -(register-definition-prefixes "company-ispell" '("company-ispell-")) +(fn COMMAND &optional ARG &rest IGNORED)" t) +(register-definition-prefixes "company-ispell" '("company-")) -;;;*** -;;;### (autoloads nil "company-keywords" "company-keywords.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from company-keywords.el (autoload 'company-keywords "company-keywords" "\ `company-mode' backend for programming language keywords. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-keywords" '("company-keywords-")) -;;;*** -;;;### (autoloads nil "company-nxml" "company-nxml.el" (0 0 0 0)) ;;; Generated autoloads from company-nxml.el (autoload 'company-nxml "company-nxml" "\ `company-mode' completion backend for `nxml-mode'. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-nxml" '("company-nxml-")) -;;;*** -;;;### (autoloads nil "company-oddmuse" "company-oddmuse.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from company-oddmuse.el (autoload 'company-oddmuse "company-oddmuse" "\ `company-mode' completion backend for `oddmuse-mode'. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-oddmuse" '("company-oddmuse-")) -;;;*** -;;;### (autoloads nil "company-semantic" "company-semantic.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from company-semantic.el (autoload 'company-semantic "company-semantic" "\ `company-mode' completion backend using CEDET Semantic. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-semantic" '("company-semantic-")) -;;;*** -;;;### (autoloads nil "company-template" "company-template.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from company-template.el (register-definition-prefixes "company-template" '("company-template-")) -;;;*** -;;;### (autoloads nil "company-tempo" "company-tempo.el" (0 0 0 0)) ;;; Generated autoloads from company-tempo.el (autoload 'company-tempo "company-tempo" "\ `company-mode' completion backend for tempo. -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - +(fn COMMAND &optional ARG &rest IGNORED)" t) (register-definition-prefixes "company-tempo" '("company-tempo-")) -;;;*** -;;;### (autoloads nil "company-tng" "company-tng.el" (0 0 0 0)) ;;; Generated autoloads from company-tng.el (autoload 'company-tng-frontend "company-tng" "\ @@ -322,11 +250,8 @@ frontend will display the candidate in the buffer as if it's already there and any key outside of `company-active-map' will confirm the selection and finish the completion. -\(fn COMMAND)" nil nil) - -(define-obsolete-function-alias 'company-tng-configure-default 'company-tng-mode "0.9.14" "\ -Applies the default configuration to enable company-tng.") - +(fn COMMAND)") +(define-obsolete-function-alias 'company-tng-configure-default 'company-tng-mode "0.10.0" "Applies the default configuration to enable company-tng.") (defvar company-tng-mode nil "\ Non-nil if Company-Tng mode is enabled. See the `company-tng-mode' command @@ -334,34 +259,28 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `company-tng-mode'.") - (custom-autoload 'company-tng-mode "company-tng" nil) - (autoload 'company-tng-mode "company-tng" "\ This minor mode enables `company-tng-frontend'. -This is a minor mode. If called interactively, toggle the -`Company-Tng mode' mode. If the prefix argument is positive, -enable the mode, and if it is zero or negative, disable the mode. +This is a global minor mode. If called interactively, toggle the +`Company-Tng mode' mode. If the prefix argument is positive, enable the +mode, and if it is zero or negative, disable the mode. -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, evaluate `(default-value \\='company-tng-mode)'. -The mode's hook is called both when the mode is enabled and when -it is disabled. - -\(fn &optional ARG)" t nil) +The mode's hook is called both when the mode is enabled and when it is +disabled. +(fn &optional ARG)" t) (register-definition-prefixes "company-tng" '("company-tng-")) -;;;*** -;;;### (autoloads nil "company-yasnippet" "company-yasnippet.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from company-yasnippet.el (autoload 'company-yasnippet "company-yasnippet" "\ @@ -387,20 +306,19 @@ shadow backends that come after it. Recommended usages: (global-set-key (kbd \"C-c y\") \\='company-yasnippet) -\(fn COMMAND &optional ARG &rest IGNORE)" t nil) - +(fn COMMAND &optional ARG &rest IGNORE)" t) (register-definition-prefixes "company-yasnippet" '("company-yasnippet-")) - -;;;*** -;;;### (autoloads nil nil ("company-pkg.el") (0 0 0 0)) +;;; End of scraped data + +(provide 'company-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; company-autoloads.el ends here diff --git a/elpa/company-20230703.2021/company-bbdb.el b/elpa/company-20241210.2019/company-bbdb.el similarity index 86% rename from elpa/company-20230703.2021/company-bbdb.el rename to elpa/company-20241210.2019/company-bbdb.el index 1016e2aa..d95e140b 100644 --- a/elpa/company-20230703.2021/company-bbdb.el +++ b/elpa/company-20241210.2019/company-bbdb.el @@ -1,6 +1,6 @@ -;;; company-bbdb.el --- company-mode completion backend for BBDB in message-mode +;;; company-bbdb.el --- company-mode completion backend for BBDB in message-mode -*- lexical-binding: t -*- -;; Copyright (C) 2013-2016, 2020 Free Software Foundation, Inc. +;; Copyright (C) 2013-2016, 2020, 2023 Free Software Foundation, Inc. ;; Author: Jan Tatarik @@ -23,9 +23,7 @@ (require 'cl-lib) (declare-function bbdb-record-get-field "bbdb") -(declare-function bbdb-records "bbdb") (declare-function bbdb-dwim-mail "bbdb-com") -(declare-function bbdb-search "bbdb-com") (defgroup company-bbdb nil "Completion backend for BBDB." @@ -40,10 +38,12 @@ (cl-mapcan (lambda (record) (mapcar (lambda (mail) (bbdb-dwim-mail record mail)) (bbdb-record-get-field record 'mail))) - (eval '(bbdb-search (bbdb-records) arg nil arg)))) + (eval `(let ((arg ,arg)) + (bbdb-search (bbdb-records) :all-names arg :mail arg)) + t))) ;;;###autoload -(defun company-bbdb (command &optional arg &rest ignore) +(defun company-bbdb (command &optional arg &rest _ignore) "`company-mode' completion backend for BBDB." (interactive (list 'interactive)) (cl-case command diff --git a/elpa/company-20230703.2021/company-capf.el b/elpa/company-20241210.2019/company-capf.el similarity index 52% rename from elpa/company-20230703.2021/company-capf.el rename to elpa/company-20241210.2019/company-capf.el index 5a2f3db1..baeacaa2 100644 --- a/elpa/company-20230703.2021/company-capf.el +++ b/elpa/company-20241210.2019/company-capf.el @@ -1,6 +1,6 @@ ;;; company-capf.el --- company-mode completion-at-point-functions backend -*- lexical-binding: t -*- -;; Copyright (C) 2013-2022 Free Software Foundation, Inc. +;; Copyright (C) 2013-2024 Free Software Foundation, Inc. ;; Author: Stefan Monnier @@ -19,7 +19,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . - ;;; Commentary: ;; ;; The CAPF back-end provides a bridge to the standard @@ -32,13 +31,27 @@ (require 'company) (require 'cl-lib) +(defgroup company-capf nil + "Completion backend as adapter for `completion-at-point-functions'." + :group 'company) + +(defcustom company-capf-disabled-functions '(tags-completion-at-point-function + ispell-completion-at-point) + "List of completion functions which should be ignored in this backend. + +By default it contains the functions that duplicate the built-in backends +but don't support the corresponding configuration options and/or alter the +intended priority of the default backends' configuration." + :type 'hook + :package-version '(company . "1.0.0")) + ;; Amortizes several calls to a c-a-p-f from the same position. (defvar company--capf-cache nil) ;; FIXME: Provide a way to save this info once in Company itself ;; (https://github.com/company-mode/company-mode/pull/845). (defvar-local company-capf--current-completion-data nil - "Value last returned by `company-capf' when called with `candidates'. + "Value last returned by `company-capf' in response to `candidates'. For most properties/actions, this is just what we need: the exact values that accompanied the completion table that's currently is use. @@ -46,6 +59,9 @@ that accompanied the completion table that's currently is use. a completion session (most importantly, by `company-sort-by-occurrence'), so we can't just use the preceding variable instead.") +(defvar-local company-capf--current-completion-metadata nil + "Metadata computed with the current prefix and data above.") + (defun company--capf-data () (let ((cache company--capf-cache)) (if (and (equal (current-buffer) (car cache)) @@ -57,105 +73,60 @@ so we can't just use the preceding variable instead.") (list (current-buffer) (point) (buffer-chars-modified-tick) data)) data)))) -(defun company--contains (elt lst) - (when-let ((cur (car lst))) - (cond - ((symbolp cur) - (or (eq elt cur) - (company--contains elt (cdr lst)))) - ((listp cur) - (or (company--contains elt cur) - (company--contains elt (cdr lst))))))) - (defun company--capf-data-real () - (cl-letf* (((default-value 'completion-at-point-functions) - (if (company--contains 'company-etags company-backends) - ;; Ignore tags-completion-at-point-function because it subverts - ;; company-etags in the default value of company-backends, where - ;; the latter comes later. - (remove 'tags-completion-at-point-function - (default-value 'completion-at-point-functions)) - (default-value 'completion-at-point-functions))) - (completion-at-point-functions (company--capf-workaround)) - (data (run-hook-wrapped 'completion-at-point-functions - ;; Ignore misbehaving functions. - #'company--capf-wrapper 'optimist))) + (let ((data (run-hook-wrapped 'completion-at-point-functions + ;; Ignore disabled and misbehaving functions. + #'company--capf-wrapper 'optimist))) (when (and (consp (cdr data)) (integer-or-marker-p (nth 1 data))) data))) (defun company--capf-wrapper (fun which) - (let ((buffer-read-only t) - (inhibit-read-only nil) - (completion-in-region-function - (lambda (beg end coll pred) - (throw 'company--illegal-completion-in-region - (list fun beg end coll :predicate pred))))) - (catch 'company--illegal-completion-in-region - (condition-case nil - (completion--capf-wrapper fun which) - (buffer-read-only nil))))) + ;; E.g. tags-completion-at-point-function subverts company-etags in the + ;; default value of company-backends, where the latter comes later. + (unless (memq fun company-capf-disabled-functions) + (let ((buffer-read-only t) + (inhibit-read-only nil) + (completion-in-region-function + (lambda (beg end coll pred) + (throw 'company--illegal-completion-in-region + (list fun beg end coll :predicate pred))))) + (catch 'company--illegal-completion-in-region + (condition-case nil + (completion--capf-wrapper fun which) + (buffer-read-only nil)))))) (declare-function python-shell-get-process "python") -(defun company--capf-workaround () - ;; For http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18067 - (if (or (not (listp completion-at-point-functions)) - (not (memq 'python-completion-complete-at-point completion-at-point-functions)) - (python-shell-get-process)) - completion-at-point-functions - (remq 'python-completion-complete-at-point completion-at-point-functions))) - -(defun company-capf--save-current-data (data) - (setq company-capf--current-completion-data data) +(defun company-capf--save-current-data (data metadata) + (setq company-capf--current-completion-data data + company-capf--current-completion-metadata metadata) (add-hook 'company-after-completion-hook #'company-capf--clear-current-data nil t)) (defun company-capf--clear-current-data (_ignored) - (setq company-capf--current-completion-data nil)) + (setq company-capf--current-completion-data nil + company-capf--current-completion-metadata nil)) (defvar-local company-capf--sorted nil) +(defvar-local company-capf--current-boundaries nil) -(defun company-capf (command &optional arg &rest _args) +(defun company-capf (command &optional arg &rest rest) "`company-mode' backend using `completion-at-point-functions'." (interactive (list 'interactive)) (pcase command (`interactive (company-begin-backend 'company-capf)) (`prefix - (let ((res (company--capf-data))) - (when res - (let ((length (plist-get (nthcdr 4 res) :company-prefix-length)) - (prefix (buffer-substring-no-properties (nth 1 res) (point)))) - (cond - ((> (nth 2 res) (point)) 'stop) - (length (cons prefix length)) - (t prefix)))))) + (company-capf--prefix)) (`candidates - (company-capf--candidates arg)) + (company-capf--candidates arg (car rest))) (`sorted company-capf--sorted) (`match ;; Ask the for the `:company-match' function. If that doesn't help, ;; fallback to sniffing for face changes to get a suitable value. - (let ((f (plist-get (nthcdr 4 company-capf--current-completion-data) - :company-match))) - (if f (funcall f arg) - (let* ((match-start nil) (pos -1) - (prop-value nil) (faces nil) - (has-face-p nil) chunks - (limit (length arg))) - (while (< pos limit) - (setq pos - (if (< pos 0) 0 (next-property-change pos arg limit))) - (setq prop-value (or - (get-text-property pos 'face arg) - (get-text-property pos 'font-lock-face arg)) - faces (if (listp prop-value) prop-value (list prop-value)) - has-face-p (memq 'completions-common-part faces)) - (cond ((and (not match-start) has-face-p) - (setq match-start pos)) - ((and match-start (not has-face-p)) - (push (cons match-start pos) chunks) - (setq match-start nil)))) - (nreverse chunks))))) + (let ((f (or (plist-get (nthcdr 4 company-capf--current-completion-data) + :company-match) + #'company--match-from-capf-face))) + (funcall f arg))) (`duplicates t) (`no-cache t) ;Not much can be done here, as long as we handle ;non-prefix matches. @@ -185,20 +156,35 @@ so we can't just use the preceding variable instead.") (plist-get (nthcdr 4 (company--capf-data)) :company-require-match)) (`init nil) ;Don't bother: plenty of other ways to initialize the code. (`post-completion - (company--capf-post-completion arg)) + (company-capf--post-completion arg)) + (`adjust-boundaries + (company--capf-boundaries + company-capf--current-boundaries)) + (`expand-common + (company-capf--expand-common arg (car rest))) )) +(defun company-capf--prefix () + (let ((res (company--capf-data))) + (when res + (let ((length (plist-get (nthcdr 4 res) :company-prefix-length)) + (prefix (buffer-substring-no-properties (nth 1 res) (point))) + (suffix (buffer-substring-no-properties (point) (nth 2 res)))) + (list prefix suffix length))))) + +(defun company-capf--expand-common (prefix suffix) + (let* ((data company-capf--current-completion-data) + (table (nth 3 data)) + (pred (plist-get (nthcdr 4 data) :predicate))) + (company--capf-expand-common prefix suffix table pred + company-capf--current-completion-metadata))) + (defun company-capf--annotation (arg) (let* ((f (or (plist-get (nthcdr 4 company-capf--current-completion-data) :annotation-function) ;; FIXME: Add a test. (cdr (assq 'annotation-function - (completion-metadata - (buffer-substring (nth 1 company-capf--current-completion-data) - (nth 2 company-capf--current-completion-data)) - (nth 3 company-capf--current-completion-data) - (plist-get (nthcdr 4 company-capf--current-completion-data) - :predicate)))))) + company-capf--current-completion-metadata)))) (annotation (when f (funcall f arg)))) (if (and company-format-margin-function (equal annotation " ") ; elisp-completion-at-point, pre-icons @@ -207,40 +193,54 @@ so we can't just use the preceding variable instead.") nil annotation))) -(defun company-capf--candidates (input) - (let ((res (company--capf-data))) - (company-capf--save-current-data res) - (when res - (let* ((table (nth 3 res)) - (pred (plist-get (nthcdr 4 res) :predicate)) - (meta (completion-metadata - (buffer-substring (nth 1 res) (nth 2 res)) - table pred)) - (candidates (completion-all-completions input table pred - (length input) - meta)) +(defun company-capf--candidates (input suffix) + (let* ((current-capf (car company-capf--current-completion-data)) + (res (company--capf-data)) + (table (nth 3 res)) + (pred (plist-get (nthcdr 4 res) :predicate)) + (meta (and res + (completion-metadata + (buffer-substring (nth 1 res) (nth 2 res)) + table pred)))) + (when (and res + (or (not current-capf) + (equal current-capf (car res)))) + (let* ((interrupt (plist-get (nthcdr 4 res) :company-use-while-no-input)) + (all-result (company-capf--candidates-1 input suffix + table pred + meta + (and non-essential + (eq interrupt t)))) (sortfun (cdr (assq 'display-sort-function meta))) - (last (last candidates)) - (base-size (and (numberp (cdr last)) (cdr last)))) - (when base-size - (setcdr last nil)) + (candidates (assoc-default :completions all-result))) (setq company-capf--sorted (functionp sortfun)) + (when candidates + (company-capf--save-current-data res meta) + (setq company-capf--current-boundaries + (company--capf-boundaries-markers + (assoc-default :boundaries all-result) + company-capf--current-boundaries))) (when sortfun (setq candidates (funcall sortfun candidates))) - (if (not (zerop (or base-size 0))) - (let ((before (substring input 0 base-size))) - (mapcar (lambda (candidate) - (concat before candidate)) - candidates)) - candidates))))) - -(defun company--capf-post-completion (arg) + candidates)))) + +(defun company-capf--candidates-1 (prefix suffix table pred meta interrupt-on-input) + (if (not interrupt-on-input) + (company--capf-completions prefix suffix table pred meta) + (let (res) + (and (while-no-input + (setq res + (company--capf-completions prefix suffix table pred meta)) + nil) + (throw 'interrupted 'new-input)) + res))) + +(defun company-capf--post-completion (arg) (let* ((res company-capf--current-completion-data) (exit-function (plist-get (nthcdr 4 res) :exit-function)) (table (nth 3 res))) (if exit-function - ;; We can more or less know when the user is done with completion, - ;; so we do something different than `completion--done'. + ;; Follow the example of `completion--done'. (funcall exit-function arg ;; FIXME: Should probably use an additional heuristic: ;; completion-at-point doesn't know when the user picked a @@ -249,7 +249,7 @@ so we can't just use the preceding variable instead.") ;; RET (or use implicit completion with company-tng). (if (= (car (completion-boundaries arg table nil "")) (length arg)) - 'sole + 'exact 'finished))))) (provide 'company-capf) diff --git a/elpa/company-20230703.2021/company-clang.el b/elpa/company-20241210.2019/company-clang.el similarity index 99% rename from elpa/company-20230703.2021/company-clang.el rename to elpa/company-20241210.2019/company-clang.el index f7e6e1ba..16020788 100644 --- a/elpa/company-20230703.2021/company-clang.el +++ b/elpa/company-20241210.2019/company-clang.el @@ -335,8 +335,8 @@ or automatically through a custom `company-clang-prefix-guesser'." (defun company-clang--prefix () (if company-clang-begin-after-member-access - (company-grab-symbol-cons "\\.\\|->\\|::" 2) - (company-grab-symbol))) + (company-grab-symbol-parts "\\.\\|->\\|::" 2) + (company-grab-symbol-parts))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/elpa/company-20230703.2021/company-cmake.el b/elpa/company-20241210.2019/company-cmake.el similarity index 96% rename from elpa/company-20230703.2021/company-cmake.el rename to elpa/company-20241210.2019/company-cmake.el index a072be1f..724ed23a 100644 --- a/elpa/company-20230703.2021/company-cmake.el +++ b/elpa/company-20241210.2019/company-cmake.el @@ -1,9 +1,8 @@ -;;; company-cmake.el --- company-mode completion backend for CMake +;;; company-cmake.el --- company-mode completion backend for CMake -*- lexical-binding: t -*- -;; Copyright (C) 2013-2015, 2017-2018, 2020 Free Software Foundation, Inc. +;; Copyright (C) 2013-2015, 2017-2018, 2020, 2023 Free Software Foundation, Inc. ;; Author: Chen Bin -;; Version: 0.2 ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -49,7 +48,7 @@ They affect which types of symbols we get completion candidates for.") "^\\(%s[a-zA-Z0-9_<>]%s\\)$" "Regexp to match the candidates.") -(defvar company-cmake-modes '(cmake-mode) +(defvar company-cmake-modes '(cmake-mode cmake-ts-mode) "Major modes in which cmake may complete.") (defvar company-cmake--candidates-cache nil @@ -94,12 +93,10 @@ They affect which types of symbols we get completion candidates for.") )) (defun company-cmake--parse (prefix content cmd) - (let ((start 0) - (pattern (format company-cmake--completion-pattern + (let ((pattern (format company-cmake--completion-pattern (regexp-quote prefix) (if (zerop (length prefix)) "+" "*"))) (lines (split-string content "\n")) - match rlt) (dolist (line lines) (when (string-match pattern line) @@ -185,7 +182,7 @@ They affect which types of symbols we get completion candidates for.") (and (eq (char-before (point)) ?\{) (eq (char-before (1- (point))) ?$)))) -(defun company-cmake (command &optional arg &rest ignored) +(defun company-cmake (command &optional arg &rest _ignored) "`company-mode' completion backend for CMake. CMake is a cross-platform, open-source make system." (interactive (list 'interactive)) diff --git a/elpa/company-20230703.2021/company-css.el b/elpa/company-20241210.2019/company-css.el similarity index 100% rename from elpa/company-20230703.2021/company-css.el rename to elpa/company-20241210.2019/company-css.el diff --git a/elpa/company-20241210.2019/company-dabbrev-code.el b/elpa/company-20241210.2019/company-dabbrev-code.el new file mode 100644 index 00000000..4da6388e --- /dev/null +++ b/elpa/company-20241210.2019/company-dabbrev-code.el @@ -0,0 +1,177 @@ +;;; company-dabbrev-code.el --- dabbrev-like company-mode backend for code -*- lexical-binding: t -*- + +;; Copyright (C) 2009-2011, 2013-2016, 2021-2024 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + + +;;; Commentary: +;; + +;;; Code: + +(require 'company) +(require 'company-dabbrev) +(require 'cl-lib) + +(defgroup company-dabbrev-code nil + "dabbrev-like completion backend for code." + :group 'company) + +(defcustom company-dabbrev-code-modes + '(prog-mode + batch-file-mode csharp-mode css-mode erlang-mode haskell-mode jde-mode + lua-mode python-mode) + "Modes that use `company-dabbrev-code'. +In all these modes (and their derivatives) `company-dabbrev-code' will +complete only symbols, not text in comments or strings. In other modes +`company-dabbrev-code' will pass control to other backends +\(e.g. `company-dabbrev'\). Value t means complete in all modes." + :type '(choice (repeat :tag "Some modes" (symbol :tag "Major mode")) + (const :tag "All modes" t))) + +(defcustom company-dabbrev-code-other-buffers t + "Determines whether `company-dabbrev-code' should search other buffers. +If `all', search all other buffers, except the ignored ones. If t, search +buffers with the same major mode. If `code', search all +buffers with major modes in `company-dabbrev-code-modes', or derived from one of +them. This can also be a function that takes the current buffer as +parameter and returns a list of major modes to search. See also +`company-dabbrev-code-time-limit'." + :type '(choice (const :tag "Off" nil) + (const :tag "Same major mode" t) + (const :tag "Code major modes" code) + (const :tag "All" all) + (function :tag "Function to return similar major-modes" group))) + +(defcustom company-dabbrev-code-time-limit .1 + "Determines how long `company-dabbrev-code' should look for matches." + :type '(choice (const :tag "Off" nil) + (number :tag "Seconds"))) + +(defcustom company-dabbrev-code-everywhere nil + "Non-nil to offer completions in comments and strings." + :type 'boolean) + +(defcustom company-dabbrev-code-ignore-case nil + "Non-nil to ignore case when collecting completion candidates." + :type 'boolean) + +(defcustom company-dabbrev-code-completion-styles nil + "Non-nil to use the completion styles for fuzzy matching." + :type '(choice (const :tag "Prefix matching only" nil) + (const :tag "Matching according to `completion-styles'" t) + (list :tag "Custom list of styles" symbol)) + :package-version '(company . "1.0.0")) + +(defvar-local company-dabbrev--boundaries nil) + +(defun company-dabbrev-code--make-regexp (prefix) + (let ((prefix-re + (cond + ((string-empty-p prefix) + "\\([a-zA-Z]\\|\\s_\\)") + ((not company-dabbrev-code-completion-styles) + (regexp-quote prefix)) + (t + ;; Use the cache at least after 2 chars. We could also cache + ;; earlier, for users who set company-min-p-l to 1 or 0. + (let ((prefix (if (>= (length prefix) 2) + (substring prefix 0 2) + prefix))) + (mapconcat #'regexp-quote + (mapcar #'string prefix) + "\\(\\sw\\|\\s_\\)*")))))) + (concat "\\_<" prefix-re "\\(\\sw\\|\\s_\\)*\\_>"))) + +;;;###autoload +(defun company-dabbrev-code (command &optional arg &rest rest) + "dabbrev-like `company-mode' backend for code. +The backend looks for all symbols in the current buffer that aren't in +comments or strings." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-dabbrev-code)) + (prefix (and (or (eq t company-dabbrev-code-modes) + (cl-some #'derived-mode-p company-dabbrev-code-modes)) + (or company-dabbrev-code-everywhere + (not (company-in-string-or-comment))) + (company-grab-symbol-parts))) + (candidates (company-dabbrev--candidates arg (car rest))) + (adjust-boundaries (and company-dabbrev-code-completion-styles + (company--capf-boundaries + company-dabbrev--boundaries))) + (expand-common (company-dabbrev-code--expand-common arg (car rest))) + (kind 'text) + (no-cache t) + (ignore-case company-dabbrev-code-ignore-case) + (match (when company-dabbrev-code-completion-styles + (company--match-from-capf-face arg))) + (duplicates t))) + +(defun company-dabbrev-code--expand-common (prefix suffix) + (when company-dabbrev-code-completion-styles + (let ((completion-styles (if (listp company-dabbrev-code-completion-styles) + company-dabbrev-code-completion-styles + completion-styles))) + (company--capf-expand-common prefix suffix + (company-dabbrev-code--table prefix))))) + +(defun company-dabbrev--candidates (prefix suffix) + (let* ((case-fold-search company-dabbrev-code-ignore-case)) + (company-dabbrev-code--filter + prefix suffix + (company-dabbrev-code--table prefix)))) + +(defun company-dabbrev-code--table (prefix) + (let ((regexp (company-dabbrev-code--make-regexp prefix))) + (company-cache-fetch + 'dabbrev-code-candidates + (lambda () + (company-dabbrev--search + regexp + company-dabbrev-code-time-limit + (pcase company-dabbrev-code-other-buffers + (`t (list major-mode)) + (`code company-dabbrev-code-modes) + ((pred functionp) (funcall company-dabbrev-code-other-buffers (current-buffer))) + (`all `all)) + (not company-dabbrev-code-everywhere))) + :expire t + :check-tag + (cons regexp company-dabbrev-code-completion-styles)))) + +(defun company-dabbrev-code--filter (prefix suffix table) + (let ((completion-ignore-case company-dabbrev-code-ignore-case) + (completion-styles (if (listp company-dabbrev-code-completion-styles) + company-dabbrev-code-completion-styles + completion-styles)) + res) + (if (not company-dabbrev-code-completion-styles) + (all-completions prefix table) + (setq res (company--capf-completions + prefix suffix + table)) + (setq company-dabbrev--boundaries + (company--capf-boundaries-markers + (assoc-default :boundaries res) + company-dabbrev--boundaries)) + (assoc-default :completions res)))) + +(provide 'company-dabbrev-code) +;;; company-dabbrev-code.el ends here diff --git a/elpa/company-20230703.2021/company-dabbrev.el b/elpa/company-20241210.2019/company-dabbrev.el similarity index 75% rename from elpa/company-20230703.2021/company-dabbrev.el rename to elpa/company-20241210.2019/company-dabbrev.el index bb23007a..2bd8e8d7 100644 --- a/elpa/company-20230703.2021/company-dabbrev.el +++ b/elpa/company-20241210.2019/company-dabbrev.el @@ -1,6 +1,6 @@ ;;; company-dabbrev.el --- dabbrev-like company-mode completion backend -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2018, 2021 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2018, 2021-2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -35,10 +35,13 @@ (defcustom company-dabbrev-other-buffers 'all "Determines whether `company-dabbrev' should search other buffers. If `all', search all other buffers, except the ignored ones. If t, search -buffers with the same major mode. See also `company-dabbrev-time-limit'." +buffers with the same major mode. This can also be a function that takes +the current buffer as parameter and returns a list of major modes to +search. See also `company-dabbrev-time-limit'." :type '(choice (const :tag "Off" nil) (const :tag "Same major mode" t) - (const :tag "All" all))) + (const :tag "All" all) + (function :tag "Function to return similar major-modes" group))) (defcustom company-dabbrev-ignore-buffers "\\`[ *]" "Regexp matching the names of buffers to ignore. @@ -70,10 +73,7 @@ candidate is inserted, even some of its characters have different case." The value of nil means keep them as-is. `case-replace' means use the value of `case-replace'. -Any other value means downcase. - -If you set this value to nil, you may also want to set -`company-dabbrev-ignore-case' to any value other than `keep-prefix'." +Any other value means downcase." :type '(choice (const :tag "Keep as-is" nil) (const :tag "Downcase" t) @@ -114,7 +114,7 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'." (when (and (>= (length match) company-dabbrev-minimum-length) (not (and company-dabbrev-ignore-invisible (invisible-p (match-beginning 0))))) - (push match symbols))))) + (puthash match t symbols))))) (goto-char (if pos (1- pos) (point-min))) ;; Search before pos. (let ((tmp-end (point))) @@ -147,7 +147,9 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'." (defun company-dabbrev--search (regexp &optional limit other-buffer-modes ignore-comments) (let* ((start (current-time)) - (symbols (company-dabbrev--search-buffer regexp (point) nil start limit + (symbols (company-dabbrev--search-buffer regexp (point) + (make-hash-table :test 'equal) + start limit ignore-comments))) (when other-buffer-modes (cl-dolist (buffer (delq (current-buffer) (buffer-list))) @@ -157,7 +159,7 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'." (funcall company-dabbrev-ignore-buffers buffer)) (with-current-buffer buffer (when (or (eq other-buffer-modes 'all) - (apply #'derived-mode-p other-buffer-modes)) + (cl-some #'derived-mode-p other-buffer-modes)) (setq symbols (company-dabbrev--search-buffer regexp nil symbols start limit ignore-comments))))) @@ -167,16 +169,38 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'." symbols)) (defun company-dabbrev--prefix () - ;; Not in the middle of a word. - (unless (looking-at company-dabbrev-char-regexp) - ;; Emacs can't do greedy backward-search. - (company-grab-line (format "\\(?:^\\| \\)[^ ]*?\\(\\(?:%s\\)*\\)" - company-dabbrev-char-regexp) - 1))) + ;; Emacs can't do greedy backward-search. + (list + (company-grab-line (format "\\(?:^\\| \\)[^ ]*?\\(\\(?:%s\\)*\\)" + company-dabbrev-char-regexp) + 1) + (and (looking-at (format "\\(?:%s\\)*" company-dabbrev-char-regexp)) + (match-string 0)))) (defun company-dabbrev--filter (prefix candidates) - (let ((completion-ignore-case company-dabbrev-ignore-case)) - (all-completions prefix candidates))) + (let* ((completion-ignore-case company-dabbrev-ignore-case) + (filtered (all-completions prefix candidates)) + (lp (length prefix)) + (downcase (if (eq company-dabbrev-downcase 'case-replace) + case-replace + company-dabbrev-downcase))) + (when downcase + (let ((ptr filtered)) + (while ptr + (setcar ptr (downcase (car ptr))) + (setq ptr (cdr ptr))))) + (if (and (eq company-dabbrev-ignore-case 'keep-prefix) + (not (= lp 0))) + (company-substitute-prefix prefix filtered) + filtered))) + +(defun company-dabbrev--fetch () + (company-dabbrev--search (company-dabbrev--make-regexp) + company-dabbrev-time-limit + (pcase company-dabbrev-other-buffers + (`t (list major-mode)) + ((pred functionp) (funcall company-dabbrev-other-buffers (current-buffer))) + (`all `all)))) ;;;###autoload (defun company-dabbrev (command &optional arg &rest _ignored) @@ -186,21 +210,14 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'." (interactive (company-begin-backend 'company-dabbrev)) (prefix (company-dabbrev--prefix)) (candidates - (let* ((case-fold-search company-dabbrev-ignore-case) - (words (company-dabbrev--search (company-dabbrev--make-regexp) - company-dabbrev-time-limit - (pcase company-dabbrev-other-buffers - (`t (list major-mode)) - (`all `all)))) - (downcase-p (if (eq company-dabbrev-downcase 'case-replace) - case-replace - company-dabbrev-downcase))) - (setq words (company-dabbrev--filter arg words)) - (if downcase-p - (mapcar 'downcase words) - words))) + (company-dabbrev--filter + arg + ;; FIXME: Only cache the result of non-interrupted scans? + (company-cache-fetch 'dabbrev-candidates #'company-dabbrev--fetch + :expire t))) (kind 'text) - (ignore-case company-dabbrev-ignore-case) + (no-cache t) + (ignore-case (and company-dabbrev-ignore-case t)) (duplicates t))) (provide 'company-dabbrev) diff --git a/elpa/company-20230703.2021/company-etags.el b/elpa/company-20241210.2019/company-etags.el similarity index 58% rename from elpa/company-20230703.2021/company-etags.el rename to elpa/company-20241210.2019/company-etags.el index 0bd093aa..e4946421 100644 --- a/elpa/company-20230703.2021/company-etags.el +++ b/elpa/company-20241210.2019/company-etags.el @@ -1,6 +1,6 @@ -;;; company-etags.el --- company-mode completion backend for etags +;;; company-etags.el --- company-mode completion backend for etags -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2015, 2018-2019 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2015, 2018-2019, 2023-2024 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -54,10 +54,18 @@ Set it to t or to a list of major modes." (symbol :tag "Major mode"))) :package-version '(company . "0.9.0")) +(defcustom company-etags-completion-styles nil + "Non-nil to use the completion styles for fuzzy matching." + :type '(choice (const :tag "Prefix matching only" nil) + (const :tag "Matching according to `completion-styles'" t) + (list :tag "Custom list of styles" symbol)) + :package-version '(company . "1.0.0")) + (defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode jde-mode pascal-mode perl-mode python-mode)) (defvar-local company-etags-buffer-table 'unknown) +(defvar-local company-etags--boundaries nil) (defun company-etags-find-table () (let ((file (expand-file-name @@ -74,34 +82,64 @@ Set it to t or to a list of major modes." (setq company-etags-buffer-table (company-etags-find-table)) company-etags-buffer-table))) -(defun company-etags--candidates (prefix) +(defun company-etags--candidates (prefix suffix) + (let ((completion-ignore-case company-etags-ignore-case) + (completion-styles (if (listp company-etags-completion-styles) + company-etags-completion-styles + completion-styles)) + (table (company-etags--table))) + (and table + (if company-etags-completion-styles + (let ((res (company--capf-completions prefix suffix table))) + (setq company-etags--boundaries + (company--capf-boundaries-markers + (assoc-default :boundaries res) + company-etags--boundaries)) + (assoc-default :completions res)) + (all-completions prefix table))))) + +(defun company-etags--table () (let ((tags-table-list (company-etags-buffer-table)) - (tags-file-name tags-file-name) - (completion-ignore-case company-etags-ignore-case)) + (tags-file-name tags-file-name)) (and (or tags-file-name tags-table-list) (fboundp 'tags-completion-table) (save-excursion (visit-tags-table-buffer) - (all-completions prefix (tags-completion-table)))))) + (tags-completion-table))))) + +(defun company-etags--expand-common (prefix suffix) + (when company-etags-completion-styles + (let ((completion-styles (if (listp company-etags-completion-styles) + company-etags-completion-styles + completion-styles))) + (company--capf-expand-common prefix suffix + (company-etags--table))))) ;;;###autoload -(defun company-etags (command &optional arg &rest ignored) +(defun company-etags (command &optional arg &rest rest) "`company-mode' completion backend for etags." (interactive (list 'interactive)) (cl-case command (interactive (company-begin-backend 'company-etags)) - (prefix (and (apply #'derived-mode-p company-etags-modes) + (prefix (and (cl-some #'derived-mode-p company-etags-modes) (or (eq t company-etags-everywhere) - (apply #'derived-mode-p company-etags-everywhere) + (cl-some #'derived-mode-p company-etags-everywhere) (not (company-in-string-or-comment))) (company-etags-buffer-table) - (or (company-grab-symbol) 'stop))) - (candidates (company-etags--candidates arg)) + (company-grab-symbol-parts))) + (candidates (company-etags--candidates arg (car rest))) + (adjust-boundaries (and company-etags-completion-styles + (company--capf-boundaries + company-etags--boundaries))) + (expand-common (company-etags--expand-common arg (car rest))) + (no-cache company-etags-completion-styles) (location (let ((tags-table-list (company-etags-buffer-table))) (when (fboundp 'find-tag-noselect) (save-excursion (let ((buffer (find-tag-noselect arg))) (cons buffer (with-current-buffer buffer (point)))))))) + (match (when company-etags-completion-styles + (company--match-from-capf-face arg))) (ignore-case company-etags-ignore-case))) (provide 'company-etags) diff --git a/elpa/company-20230703.2021/company-files.el b/elpa/company-20241210.2019/company-files.el similarity index 75% rename from elpa/company-20230703.2021/company-files.el rename to elpa/company-20241210.2019/company-files.el index 0eb6cfe4..73880960 100644 --- a/elpa/company-20230703.2021/company-files.el +++ b/elpa/company-20241210.2019/company-files.el @@ -1,6 +1,6 @@ -;;; company-files.el --- company-mode completion backend for file names +;;; company-files.el --- company-mode completion backend for file names -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2021 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2024 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -38,22 +38,14 @@ The values should use the same format as `completion-ignored-extensions'." :type '(repeat (string :tag "File extension or directory name")) :package-version '(company . "0.9.1")) -(defcustom company-files-chop-trailing-slash t - "Non-nil to remove the trailing slash after inserting directory name. - -This way it's easy to continue completion by typing `/' again. - -Set this to nil to disable that behavior." - :type 'boolean) - (defun company-files--directory-files (dir prefix) ;; Don't use directory-files. It produces directories without trailing /. - (condition-case err + (condition-case _err (let ((comp (sort (file-name-all-completions prefix dir) (lambda (s1 s2) (string-lessp (downcase s1) (downcase s2)))))) (when company-files-exclusions (setq comp (company-files--exclusions-filtered comp))) - (if (equal prefix "") + (if (string-empty-p prefix) (delete "../" (delete "./" comp)) comp)) (file-error nil))) @@ -105,54 +97,58 @@ Set this to nil to disable that behavior." (defvar company-files--completion-cache nil) -(defun company-files--complete (prefix) - (let* ((dir (file-name-directory prefix)) - (file (file-name-nondirectory prefix)) +(defun company-files--complete (_prefix) + (let* ((full-prefix (company-files--grab-existing-name)) + (dir (file-name-directory full-prefix)) + (file (file-name-nondirectory full-prefix)) (key (list file (expand-file-name dir) (nth 5 (file-attributes dir)))) (completion-ignore-case read-file-name-completion-ignore-case)) - (unless (company-file--keys-match-p key (car company-files--completion-cache)) - (let* ((candidates (mapcar (lambda (f) (concat dir f)) - (company-files--directory-files dir file))) + (unless (or (company-file--keys-match-p key (car company-files--completion-cache)) + (not (company-files--connected-p dir))) + (let* ((candidates (company-files--directory-files dir file)) (directories (unless (file-remote-p dir) (cl-remove-if-not (lambda (f) - (and (company-files--trailing-slash-p f) - (not (file-remote-p f)) - (company-files--connected-p f))) + (company-files--trailing-slash-p f)) candidates))) (children (and directories (cl-mapcan (lambda (d) - (mapcar (lambda (c) (concat d c)) - (company-files--directory-files d ""))) + (company-files--directory-files d "")) directories)))) (setq company-files--completion-cache (cons key (append candidates children))))) - (all-completions prefix - (cdr company-files--completion-cache)))) + (all-completions file (cdr company-files--completion-cache)))) + +(defun company-files--prefix () + (let ((existing (company-files--grab-existing-name))) + (when existing + (list existing (company-grab-suffix "[^ '\"\t\n\r/]*/?"))))) (defun company-file--keys-match-p (new old) (and (equal (cdr old) (cdr new)) (string-prefix-p (car old) (car new)))) -(defun company-files--post-completion (arg) - (when (and company-files-chop-trailing-slash - (company-files--trailing-slash-p arg)) - (delete-char -1))) +(defun company-files--adjust-boundaries (_file prefix suffix) + (cons + (file-name-nondirectory prefix) + suffix)) ;;;###autoload -(defun company-files (command &optional arg &rest ignored) +(defun company-files (command &optional arg &rest rest) "`company-mode' completion backend existing file names. Completions works for proper absolute and relative files paths. File paths with spaces are only supported inside strings." (interactive (list 'interactive)) (cl-case command (interactive (company-begin-backend 'company-files)) - (prefix (company-files--grab-existing-name)) - (candidates (company-files--complete arg)) + (prefix (company-files--prefix)) + (candidates + (company-files--complete arg)) + (adjust-boundaries + (company-files--adjust-boundaries arg (nth 0 rest) (nth 1 rest))) (location (cons (dired-noselect (file-name-directory (directory-file-name arg))) 1)) - (post-completion (company-files--post-completion arg)) (kind (if (string-suffix-p "/" arg) 'folder 'file)) (sorted t) (no-cache t))) diff --git a/elpa/company-20230703.2021/company-gtags.el b/elpa/company-20241210.2019/company-gtags.el similarity index 95% rename from elpa/company-20230703.2021/company-gtags.el rename to elpa/company-20241210.2019/company-gtags.el index 8c08c83a..9934338a 100644 --- a/elpa/company-20230703.2021/company-gtags.el +++ b/elpa/company-20241210.2019/company-gtags.el @@ -1,6 +1,6 @@ -;;; company-gtags.el --- company-mode completion backend for GNU Global +;;; company-gtags.el --- company-mode completion backend for GNU Global -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2021 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2021, 2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -97,7 +97,6 @@ completion." (defun company-gtags--fetch-tags (prefix) (with-temp-buffer - (let (tags) ;; For some reason Global v 6.6.3 is prone to returning exit status 1 ;; even on successful searches when '-T' is used. (when (/= 3 (process-file (company-gtags--executable) nil @@ -118,7 +117,7 @@ completion." 'meta (match-string 4) 'location (cons (expand-file-name (match-string 3)) (string-to-number (match-string 2))) - )))))) + ))))) (defun company-gtags--annotation (arg) (let ((meta (get-text-property 0 'meta arg))) @@ -135,14 +134,14 @@ completion." start (point))))))) ;;;###autoload -(defun company-gtags (command &optional arg &rest ignored) +(defun company-gtags (command &optional arg &rest _ignored) "`company-mode' completion backend for GNU Global." (interactive (list 'interactive)) (cl-case command (interactive (company-begin-backend 'company-gtags)) (prefix (and (company-gtags--executable) buffer-file-name - (apply #'derived-mode-p company-gtags-modes) + (cl-some #'derived-mode-p company-gtags-modes) (not (company-in-string-or-comment)) (company-gtags--tags-available-p) (or (company-grab-symbol) 'stop))) diff --git a/elpa/company-20230703.2021/company-ispell.el b/elpa/company-20241210.2019/company-ispell.el similarity index 56% rename from elpa/company-20230703.2021/company-ispell.el rename to elpa/company-20241210.2019/company-ispell.el index 3cb7c5d6..6c5d8332 100644 --- a/elpa/company-20230703.2021/company-ispell.el +++ b/elpa/company-20241210.2019/company-ispell.el @@ -1,6 +1,6 @@ -;;; company-ispell.el --- company-mode completion backend using Ispell +;;; company-ispell.el --- company-mode completion backend using Ispell -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2016, 2018, 2021 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2016, 2018, 2021, 2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -33,51 +33,67 @@ "Completion backend using Ispell." :group 'company) +(defun company--set-dictionary (symbol value) + (set-default-toplevel-value symbol value) + (company-cache-delete 'ispell-candidates)) + (defcustom company-ispell-dictionary nil "Dictionary to use for `company-ispell'. -If nil, use `ispell-complete-word-dict'." + +If nil, use `ispell-complete-word-dict' or `ispell-alternate-dictionary'." :type '(choice (const :tag "default (nil)" nil) - (file :tag "dictionary" t))) + (file :tag "dictionary" t)) + :set #'company--set-dictionary) (defvar company-ispell-available 'unknown) -(defalias 'company-ispell--lookup-words - (if (fboundp 'ispell-lookup-words) - 'ispell-lookup-words - 'lookup-words)) - (defun company-ispell-available () (when (eq company-ispell-available 'unknown) (condition-case err (progn - (company-ispell--lookup-words "WHATEVER") + (ispell-lookup-words "WHATEVER") (setq company-ispell-available t)) (error (message "Company-Ispell: %s" (error-message-string err)) (setq company-ispell-available nil)))) company-ispell-available) +(defun company--ispell-dict () + "Determine which dictionary to use." + (let ((dict (or company-ispell-dictionary + ispell-complete-word-dict + ispell-alternate-dictionary))) + (when dict + (expand-file-name dict)))) + ;;;###autoload -(defun company-ispell (command &optional arg &rest ignored) +(defun company-ispell (command &optional arg &rest _ignored) "`company-mode' completion backend using Ispell." (interactive (list 'interactive)) (cl-case command (interactive (company-begin-backend 'company-ispell)) (prefix (when (company-ispell-available) - (company-grab-word))) + (list + (company-grab-word) + (company-grab-word-suffix)))) (candidates - (let ((words (company-ispell--lookup-words - arg - (or company-ispell-dictionary ispell-complete-word-dict))) - (completion-ignore-case t)) - (if (string= arg "") + (let* ((dict (company--ispell-dict)) + (all-words + (company-cache-fetch 'ispell-candidates + (lambda () (ispell-lookup-words "" dict)) + :check-tag dict)) + (completion-ignore-case t)) + (if (string-empty-p arg) ;; Small optimization. - words - ;; Work around issue #284. - (all-completions arg words)))) + all-words + (company-substitute-prefix + arg + ;; Work around issue #284. + (all-completions arg all-words))))) (kind 'text) + (no-cache t) (sorted t) - (ignore-case 'keep-prefix))) + (ignore-case t))) (provide 'company-ispell) ;;; company-ispell.el ends here diff --git a/elpa/company-20230703.2021/company-keywords.el b/elpa/company-20241210.2019/company-keywords.el similarity index 97% rename from elpa/company-20230703.2021/company-keywords.el rename to elpa/company-20241210.2019/company-keywords.el index 57ec28d6..b4063582 100644 --- a/elpa/company-20230703.2021/company-keywords.el +++ b/elpa/company-20241210.2019/company-keywords.el @@ -1,6 +1,6 @@ -;;; company-keywords.el --- A company backend for programming language keywords +;;; company-keywords.el --- A company backend for programming language keywords -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2018, 2020-2022 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2018, 2020-2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -403,7 +403,21 @@ "i16" "i32" "i64" "include" "list" "map" "oneway" "optional" "required" "service" "set" "string" "struct" "throws" "typedef" "void" ) + (tuareg-mode + ;; ocaml, from https://v2.ocaml.org/manual/lex.html#sss:keywords + "and" "as" "asr" "assert" "begin" "class" + "constraint" "do" "done" "downto" "else" "end" + "exception" "external" "false" "for" "fun" "function" + "functor" "if" "in" "include" "inherit" "initializer" + "land" "lazy" "let" "lor" "lsl" "lsr" + "lxor" "match" "method" "mod" "module" "mutable" + "new" "nonrec" "object" "of" "open" "or" + "private" "rec" "sig" "struct" "then" "to" + "true" "try" "type" "val" "virtual" "when" + "while" "with" + ) ;; aliases + (caml-mode . tuareg-mode) (js2-mode . javascript-mode) (js2-jsx-mode . javascript-mode) (espresso-mode . javascript-mode) @@ -413,6 +427,7 @@ (cperl-mode . perl-mode) (jde-mode . java-mode) (ess-julia-mode . julia-mode) + (php-ts-mode . php-mode) (phps-mode . php-mode) (enh-ruby-mode . ruby-mode)) "Alist mapping major-modes to sorted keywords for `company-keywords'.") @@ -439,7 +454,7 @@ (makefile-mode . makefile-statements)))) ;;;###autoload -(defun company-keywords (command &optional arg &rest ignored) +(defun company-keywords (command &optional arg &rest _ignored) "`company-mode' backend for programming language keywords." (interactive (list 'interactive)) (cl-case command diff --git a/elpa/company-20230703.2021/company-nxml.el b/elpa/company-20241210.2019/company-nxml.el similarity index 93% rename from elpa/company-20230703.2021/company-nxml.el rename to elpa/company-20241210.2019/company-nxml.el index c72685c0..2a77e367 100644 --- a/elpa/company-20230703.2021/company-nxml.el +++ b/elpa/company-20241210.2019/company-nxml.el @@ -1,6 +1,6 @@ -;;; company-nxml.el --- company-mode completion backend for nxml-mode +;;; company-nxml.el --- company-mode completion backend for nxml-mode -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2015, 2017-2018 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2015, 2017-2018, 2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -71,12 +71,11 @@ (defmacro company-nxml-prepared (&rest body) (declare (indent 0) (debug t)) - `(let ((lt-pos (save-excursion (search-backward "<" nil t))) - xmltok-dtd) + `(let ((lt-pos (save-excursion (search-backward "<" nil t)))) (when (and lt-pos (= (rng-set-state-after lt-pos) lt-pos)) ,@body))) -(defun company-nxml-tag (command &optional arg &rest ignored) +(defun company-nxml-tag (command &optional arg &rest _ignored) (cl-case command (prefix (and (derived-mode-p 'nxml-mode) rng-validate-mode @@ -86,7 +85,7 @@ arg (rng-match-possible-start-tag-names)))) (sorted t))) -(defun company-nxml-attribute (command &optional arg &rest ignored) +(defun company-nxml-attribute (command &optional arg &rest _ignored) (cl-case command (prefix (and (derived-mode-p 'nxml-mode) rng-validate-mode @@ -99,7 +98,7 @@ arg (rng-match-possible-attribute-names))))) (sorted t))) -(defun company-nxml-attribute-value (command &optional arg &rest ignored) +(defun company-nxml-attribute-value (command &optional arg &rest _ignored) (cl-case command (prefix (and (derived-mode-p 'nxml-mode) rng-validate-mode @@ -121,7 +120,7 @@ arg (rng-match-possible-value-strings)))))))) ;;;###autoload -(defun company-nxml (command &optional arg &rest ignored) +(defun company-nxml (command &optional arg &rest _ignored) "`company-mode' completion backend for `nxml-mode'." (interactive (list 'interactive)) (cl-case command diff --git a/elpa/company-20230703.2021/company-oddmuse.el b/elpa/company-20241210.2019/company-oddmuse.el similarity index 91% rename from elpa/company-20230703.2021/company-oddmuse.el rename to elpa/company-20241210.2019/company-oddmuse.el index 78ede68b..fd0b2563 100644 --- a/elpa/company-20230703.2021/company-oddmuse.el +++ b/elpa/company-20241210.2019/company-oddmuse.el @@ -1,6 +1,6 @@ -;;; company-oddmuse.el --- company-mode completion backend for oddmuse-mode +;;; company-oddmuse.el --- company-mode completion backend for oddmuse-mode -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2016, 2022 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2016, 2022, 2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -41,7 +41,7 @@ (oddmuse-make-completion-table oddmuse-wiki))))) ;;;###autoload -(defun company-oddmuse (command &optional arg &rest ignored) +(defun company-oddmuse (command &optional arg &rest _ignored) "`company-mode' completion backend for `oddmuse-mode'." (interactive (list 'interactive)) (cl-case command diff --git a/elpa/company-20241210.2019/company-pkg.el b/elpa/company-20241210.2019/company-pkg.el new file mode 100644 index 00000000..471e736e --- /dev/null +++ b/elpa/company-20241210.2019/company-pkg.el @@ -0,0 +1,9 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "company" "20241210.2019" + "Modular text completion framework." + '((emacs "26.1")) + :url "https://github.com/company-mode/company-mode" + :commit "7805174a9ffae3194d5bbde16febcf26761f0ad7" + :revdesc "7805174a9ffa" + :keywords '("abbrev" "convenience" "matching") + :maintainers '(("Dmitry Gutov" . "dmitry@gutov.dev"))) diff --git a/elpa/company-20230703.2021/company-semantic.el b/elpa/company-20241210.2019/company-semantic.el similarity index 94% rename from elpa/company-20230703.2021/company-semantic.el rename to elpa/company-20241210.2019/company-semantic.el index cd567646..de26744b 100644 --- a/elpa/company-20230703.2021/company-semantic.el +++ b/elpa/company-20241210.2019/company-semantic.el @@ -1,6 +1,6 @@ -;;; company-semantic.el --- company-mode completion backend using Semantic +;;; company-semantic.el --- company-mode completion backend using Semantic -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2018 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2018, 2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -126,11 +126,11 @@ and `c-electric-colon', for automatic completion right after \">\" and (defun company-semantic--prefix () (if company-semantic-begin-after-member-access - (company-grab-symbol-cons "\\.\\|->\\|::" 2) - (company-grab-symbol))) + (company-grab-symbol-parts "\\.\\|->\\|::" 2) + (company-grab-symbol-parts))) ;;;###autoload -(defun company-semantic (command &optional arg &rest ignored) +(defun company-semantic (command &optional arg &rest _ignored) "`company-mode' completion backend using CEDET Semantic." (interactive (list 'interactive)) (cl-case command @@ -140,7 +140,7 @@ and `c-electric-colon', for automatic completion right after \">\" and (memq major-mode company-semantic-modes) (not (company-in-string-or-comment)) (or (company-semantic--prefix) 'stop))) - (candidates (if (and (equal arg "") + (candidates (if (and (string-empty-p arg) (not (looking-back "->\\|\\.\\|::" (- (point) 2)))) (company-semantic-completions-raw arg) (company-semantic-completions arg))) @@ -151,7 +151,7 @@ and `c-electric-colon', for automatic completion right after \">\" and (doc-buffer (company-semantic-doc-buffer (assoc arg company-semantic--current-tags))) ;; Because "" is an empty context and doesn't return local variables. - (no-cache (equal arg "")) + (no-cache (string-empty-p arg)) (duplicates t) (location (let ((tag (assoc arg company-semantic--current-tags))) (when (buffer-live-p (semantic-tag-buffer tag)) diff --git a/elpa/company-20230703.2021/company-template.el b/elpa/company-20241210.2019/company-template.el similarity index 98% rename from elpa/company-20230703.2021/company-template.el rename to elpa/company-20241210.2019/company-template.el index 57d5d488..8511bc40 100644 --- a/elpa/company-20230703.2021/company-template.el +++ b/elpa/company-20241210.2019/company-template.el @@ -1,6 +1,6 @@ -;;; company-template.el --- utility library for template expansion +;;; company-template.el --- utility library for template expansion -*- lexical-binding: t -*- -;; Copyright (C) 2009-2010, 2013-2017, 2019 Free Software Foundation, Inc. +;; Copyright (C) 2009-2010, 2013-2017, 2019, 2023-2024 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -205,6 +205,7 @@ after deleting a field in `company-template-remove-field'." (let* ((end (point-marker)) (beg (- (point) (length call))) (templ (company-template-declare-template beg end)) + forward-sexp-function paren-open paren-close) (with-syntax-table (make-syntax-table (syntax-table)) (modify-syntax-entry ?< "(") diff --git a/elpa/company-20230703.2021/company-tempo.el b/elpa/company-20241210.2019/company-tempo.el similarity index 92% rename from elpa/company-20230703.2021/company-tempo.el rename to elpa/company-20241210.2019/company-tempo.el index 639de95c..61260339 100644 --- a/elpa/company-20230703.2021/company-tempo.el +++ b/elpa/company-20241210.2019/company-tempo.el @@ -1,6 +1,6 @@ -;;; company-tempo.el --- company-mode completion backend for tempo +;;; company-tempo.el --- company-mode completion backend for tempo -*- lexical-binding: t -*- -;; Copyright (C) 2009-2011, 2013-2016 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2016, 2023 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -56,7 +56,7 @@ (car (split-string doc "\n" t))))) ;;;###autoload -(defun company-tempo (command &optional arg &rest ignored) +(defun company-tempo (command &optional arg &rest _ignored) "`company-mode' completion backend for tempo." (interactive (list 'interactive)) (cl-case command diff --git a/elpa/company-20230703.2021/company-tng.el b/elpa/company-20241210.2019/company-tng.el similarity index 97% rename from elpa/company-20230703.2021/company-tng.el rename to elpa/company-20241210.2019/company-tng.el index 55124a30..41e65b9b 100644 --- a/elpa/company-20230703.2021/company-tng.el +++ b/elpa/company-20241210.2019/company-tng.el @@ -1,6 +1,6 @@ -;;; company-tng.el --- company-mode configuration for single-button interaction +;;; company-tng.el --- company-mode configuration for single-button interaction -*- lexical-binding: t -*- -;; Copyright (C) 2017-2021 Free Software Foundation, Inc. +;; Copyright (C) 2017-2024 Free Software Foundation, Inc. ;; Author: Nikita Leshenko @@ -111,7 +111,7 @@ confirm the selection and finish the completion." (let* ((ov company-tng--overlay) (selected (and company-selection (nth company-selection company-candidates))) - (prefix (length company-prefix))) + (prefix (length (car (company--boundaries))))) (move-overlay ov (- (point) prefix) (point)) (overlay-put ov (if (= prefix 0) 'after-string 'display) @@ -140,7 +140,7 @@ confirm the selection and finish the completion." :type 'boolean) ;;;###autoload -(define-obsolete-function-alias 'company-tng-configure-default 'company-tng-mode "0.9.14" +(define-obsolete-function-alias 'company-tng-configure-default 'company-tng-mode "0.10.0" "Applies the default configuration to enable company-tng.") (declare-function eglot--snippet-expansion-fn "eglot") diff --git a/elpa/company-20230703.2021/company-yasnippet.el b/elpa/company-20241210.2019/company-yasnippet.el similarity index 88% rename from elpa/company-20230703.2021/company-yasnippet.el rename to elpa/company-20241210.2019/company-yasnippet.el index fb676742..f5d6d90d 100644 --- a/elpa/company-20230703.2021/company-yasnippet.el +++ b/elpa/company-20241210.2019/company-yasnippet.el @@ -1,6 +1,6 @@ -;;; company-yasnippet.el --- company-mode completion backend for Yasnippet +;;; company-yasnippet.el --- company-mode completion backend for Yasnippet -*- lexical-binding: t -*- -;; Copyright (C) 2014-2015, 2020-2022 Free Software Foundation, Inc. +;; Copyright (C) 2014-2015, 2020-2023 Free Software Foundation, Inc. ;; Author: Dmitry Gutov @@ -72,7 +72,7 @@ It has to accept one argument: the snippet's name.") (let ((prefix (buffer-substring-no-properties (point) original))) (unless (equal prefix (car prefixes)) (push prefix prefixes)))) - prefixes))) + (nreverse prefixes)))) (defun company-yasnippet--candidates (prefix) ;; Process the prefixes in reverse: unlike Yasnippet, we look for prefix @@ -135,8 +135,24 @@ It has to accept one argument: the snippet's name.") (ignore-errors (font-lock-ensure)))) (current-buffer)))) +(defun company-yasnippet--prefix () + ;; We can avoid the prefix length manipulations after GH#426 is fixed. + (let* ((prefix (company-grab-symbol)) + (tables (yas--get-snippet-tables)) + (key-prefixes (company-yasnippet--key-prefixes)) + key-prefix) + (while (and key-prefixes + (setq key-prefix (pop key-prefixes))) + (when (company-yasnippet--completions-for-prefix + prefix key-prefix tables) + ;; Stop iteration. + (setq key-prefixes nil))) + (if (equal key-prefix prefix) + prefix + (cons prefix (length key-prefix))))) + ;;;###autoload -(defun company-yasnippet (command &optional arg &rest ignore) +(defun company-yasnippet (command &optional arg &rest _ignore) "`company-mode' backend for `yasnippet'. This backend should be used with care, because as long as there are @@ -163,10 +179,8 @@ shadow backends that come after it. Recommended usages: (cl-case command (interactive (company-begin-backend 'company-yasnippet)) (prefix - ;; Should probably use `yas--current-key', but that's bound to be slower. - ;; How many trigger keys start with non-symbol characters anyway? (and (bound-and-true-p yas-minor-mode) - (company-grab-symbol))) + (company-yasnippet--prefix))) (annotation (funcall company-yasnippet-annotation-fn (get-text-property 0 'yas-annotation arg))) diff --git a/elpa/company-20230703.2021/company.el b/elpa/company-20241210.2019/company.el similarity index 74% rename from elpa/company-20230703.2021/company.el rename to elpa/company-20241210.2019/company.el index 212ff13a..f1e1f251 100644 --- a/elpa/company-20230703.2021/company.el +++ b/elpa/company-20241210.2019/company.el @@ -1,13 +1,14 @@ ;;; company.el --- Modular text completion framework -*- lexical-binding: t -*- -;; Copyright (C) 2009-2023 Free Software Foundation, Inc. +;; Copyright (C) 2009-2024 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher -;; Maintainer: Dmitry Gutov +;; Maintainer: Dmitry Gutov ;; URL: http://company-mode.github.io/ -;; Version: 0.9.13 +;; Package-Version: 20241210.2019 +;; Package-Revision: 7805174a9ffa ;; Keywords: abbrev, convenience, matching -;; Package-Requires: ((emacs "25.1")) +;; Package-Requires: ((emacs "26.1")) ;; This file is part of GNU Emacs. @@ -134,21 +135,21 @@ (defface company-tooltip-quick-access '((default :inherit company-tooltip-annotation)) "Face used for the quick-access hints shown in the tooltip." - :package-version '(company . "0.9.14")) + :package-version '(company . "0.10.0")) (defface company-tooltip-quick-access-selection '((default :inherit company-tooltip-annotation-selection)) "Face used for the selected quick-access hints shown in the tooltip." - :package-version '(company . "0.9.14")) + :package-version '(company . "0.10.0")) (define-obsolete-face-alias 'company-scrollbar-fg 'company-tooltip-scrollbar-thumb - "0.9.14") + "0.10.0") (defface company-tooltip-scrollbar-thumb '((((background light)) - :background "darkred") + :background "indian red") (((background dark)) :background "gray33")) "Face used for the tooltip scrollbar thumb (bar).") @@ -156,7 +157,7 @@ (define-obsolete-face-alias 'company-scrollbar-bg 'company-tooltip-scrollbar-track - "0.9.14") + "0.10.0") (defface company-tooltip-scrollbar-track '((((background light)) @@ -286,7 +287,7 @@ This doesn't include the margins and the scroll bar." (defcustom company-tooltip-width-grow-only nil "When non-nil, the tooltip width is not allowed to decrease." :type 'boolean - :package-version '(company . "0.9.14")) + :package-version '(company . "0.10.0")) (defcustom company-tooltip-margin 1 "Width of margin columns to show around the toolip." @@ -299,6 +300,11 @@ This doesn't include the margins and the scroll bar." :type '(choice (const :tag "Scrollbar" scrollbar) (const :tag "Two lines" lines))) +(defcustom company-tooltip-scrollbar-width 0.4 + "Width of the scrollbar thumb, in columns." + :type 'number + :package-version '(company . "1.0.0")) + (defcustom company-tooltip-align-annotations nil "When non-nil, align annotations to the right tooltip border." :type 'boolean @@ -317,7 +323,7 @@ padding is either 0 or 1 space. This variable allows to override that value to increase the padding. When annotations are right-aligned, it sets the minimum padding, and otherwise just the constant one." :type 'number - :package-version '(company "0.9.14")) + :package-version '(company "0.10.0")) (defvar company-safe-backends '((company-abbrev . "Abbrev") @@ -371,26 +377,32 @@ one (see below). `company-begin-backend' can be used to start a specific backend, `company-other-backend' will skip to the next matching backend in the list. +To debug which backend is currently in use, try `M-x company-diag'. + Each backend is a function that takes a variable number of arguments. The first argument is the command requested from the backend. It is one of the following: -`prefix': The backend should return the text to be completed. It must be -text immediately before point. Returning nil from this command passes -control to the next backend. The function should return `stop' if it -should complete but cannot (e.g. when in the middle of a symbol). -Instead of a string, the backend may return a cons (PREFIX . LENGTH) -where LENGTH is a number used in place of PREFIX's length when -comparing against `company-minimum-prefix-length'. LENGTH can also -be just t, and in the latter case the test automatically succeeds. +`prefix': The backend should return the text to be completed. Returning +nil from this command passes control to the next backend. + +The expected return value looks like (PREFIX SUFFIX &optional PREFIX-LEN). +Where PREFIX is the text to be completed before point, SUFFIX - the +remainder after point (when e.g. inside a symbol), and PREFIX-LEN, when +non-nil, is the number to use in place of PREFIX's length when comparing +against `company-minimum-prefix-length'. PREFIX-LEN can also be just t, +and in the latter case the test automatically succeeds. + +The return value can also be just PREFIX, in which case SUFFIX is taken to +be an empty string. `candidates': The second argument is the prefix to be completed. The return value should be a list of candidates that match the prefix. Non-prefix matches are also supported (candidates that don't start with the prefix, but match it in some backend-defined way). Backends that use this -feature must disable cache (return t to `no-cache') and might also want to -respond to `match'. +feature must disable cache (return t in response to `no-cache') and might +also want to handle `match'. Optional commands ================= @@ -460,6 +472,19 @@ modify it, e.g. to expand a snippet. describing the kind of the candidate. Refer to `company-vscode-icons-mapping' for the possible values. +`adjust-boundaries': The second argument is prefix and the third argument +is suffix (previously returned by the `prefix' command). Return a +cons (NEW-PREFIX . NEW-SUFFIX) where both parts correspond to the +completion candidate. + +`expand-common': The first argument is prefix and the second argument is +suffix. Return a cons (NEW-PREFIX . NEW-SUFFIX) that denote an edit in the +current buffer which would be performed by `company-complete-common'. It +should try to make the combined length of the prefix and suffix longer, +while ensuring that the completions for the new inputs are the same. +Othewise return the original inputs. If there are no matching completions, +return the symbol `no-match'. + The backend should return nil for all commands it does not support or does not know about. It should also be callable interactively and use `company-begin-backend' to start itself in that case. @@ -513,9 +538,10 @@ even if the backend uses the asynchronous calling convention." (defcustom company-transformers nil "Functions to change the list of candidates received from backends. -Each function gets called with the return value of the previous one. +Each function is called with the return value of the previous one. The first one gets passed the list of candidates, already sorted and -without duplicates." +without duplicates (candidates with different annotations are considered to +be distinct)." :type '(choice (const :tag "None" nil) (const :tag "Sort by occurrence" (company-sort-by-occurrence)) @@ -587,12 +613,12 @@ this." (define-obsolete-variable-alias 'company-auto-complete 'company-insertion-on-trigger - "0.9.14") + "0.10.0") (define-obsolete-variable-alias 'company-auto-commit 'company-insertion-on-trigger - "0.9.14") + "0.10.0") (defcustom company-insertion-on-trigger nil "If enabled, allow triggering insertion of the selected candidate. @@ -606,17 +632,17 @@ triggers." (const :tag "On, if user interaction took place" company-explicit-action-p) (const :tag "On" t)) - :package-version '(company . "0.9.14")) + :package-version '(company . "0.10.0")) (define-obsolete-variable-alias 'company-auto-complete-chars 'company-insertion-triggers - "0.9.14") + "0.10.0") (define-obsolete-variable-alias 'company-auto-commit-chars 'company-insertion-triggers - "0.9.14") + "0.10.0") (defcustom company-insertion-triggers '(?\ ?\) ?.) "Determine triggers for `company-insertion-on-trigger'. @@ -648,7 +674,7 @@ insertion." (const :tag "Generic string fence." ?|) (const :tag "Generic comment fence." ?!)) (function :tag "Predicate function")) - :package-version '(company . "0.9.14")) + :package-version '(company . "0.10.0")) (defcustom company-idle-delay .2 "The idle delay in seconds until completion starts automatically. @@ -666,6 +692,15 @@ happens. The value of nil means no idle completion." (const :tag "immediate (0)" 0) (number :tag "seconds"))) +(defcustom company-inhibit-inside-symbols nil + "Non-nil to inhibit idle completion when typing in the middle of a symbol. +The symbol is in a generalized sense, indicated by the `prefix' backend +action returning a non-empty SUFFIX element. When this variable is +non-nil, completion inside symbol will onlytriggered by an explicit command +invocation, such as \\[company-complete-common]." + :type 'boolean + :package-version '(company . "1.0.0")) + (defcustom company-begin-commands '(self-insert-command org-self-insert-command orgtbl-self-insert-command @@ -687,7 +722,9 @@ treated as if it was on this list." (defcustom company-continue-commands '(not save-buffer save-some-buffers save-buffers-kill-terminal save-buffers-kill-emacs - completion-at-point) + completion-at-point + complete-symbol + completion-help-at-point) "A list of commands that are allowed during completion. If this is t, or if `company-begin-commands' is t, any command is allowed. Otherwise, the value must be a list of symbols. If it starts with `not', @@ -702,15 +739,18 @@ commands in the `company-' namespace, abort completion." (defun company-custom--set-quick-access (option value) "Re-bind quick-access key sequences on OPTION VALUE change." - (when (boundp 'company-active-map) - (company-keymap--unbind-quick-access company-active-map)) - (when (boundp 'company-search-map) - (company-keymap--unbind-quick-access company-search-map)) + ;; When upgrading from an earlier version of company, might not be. + (when (fboundp #'company-keymap--unbind-quick-access) + (when (boundp 'company-active-map) + (company-keymap--unbind-quick-access company-active-map)) + (when (boundp 'company-search-map) + (company-keymap--unbind-quick-access company-search-map))) (custom-set-default option value) - (when (boundp 'company-active-map) - (company-keymap--bind-quick-access company-active-map)) - (when (boundp 'company-search-map) - (company-keymap--bind-quick-access company-search-map))) + (when (fboundp #'company-keymap--bind-quick-access) + (when (boundp 'company-active-map) + (company-keymap--bind-quick-access company-active-map)) + (when (boundp 'company-search-map) + (company-keymap--bind-quick-access company-search-map)))) (defcustom company-quick-access-keys '("1" "2" "3" "4" "5" "6" "7" "8" "9" "0") "Character strings used as a part of quick-access key sequences. @@ -728,7 +768,7 @@ beside the candidates." ;; TODO un-comment on removal of `M-n' `company--select-next-and-warn'. ;; (const :tag "Dvorak home row" ("a" "o" "e" "u" "i" "d" "h" "t" "n" "s")) (repeat :tag "User defined" string)) - :package-version '(company . "0.9.14")) + :package-version '(company . "0.10.0")) (defcustom company-quick-access-modifier 'meta "Modifier key used for quick-access keys sequences. @@ -739,15 +779,15 @@ See `company-quick-access-keys' for more details." (const :tag "Super key" super) (const :tag "Hyper key" hyper) (const :tag "Control key" control)) - :package-version '(company . "0.9.14")) + :package-version '(company . "0.10.0")) (defun company-keymap--quick-access-modifier () "Return string representation of the `company-quick-access-modifier'." - (if-let ((modifier (assoc-default company-quick-access-modifier - '((meta . "M") - (super . "s") - (hyper . "H") - (control . "C"))))) + (if-let* ((modifier (assoc-default company-quick-access-modifier + '((meta . "M") + (super . "s") + (hyper . "H") + (control . "C"))))) modifier (warn "company-quick-access-modifier value unknown: %S" company-quick-access-modifier) @@ -774,7 +814,7 @@ See `company-quick-access-keys' for more details." (define-obsolete-variable-alias 'company-show-numbers 'company-show-quick-access - "0.9.14") + "0.10.0") (defcustom company-show-quick-access nil "If non-nil, show quick-access hints beside the candidates. @@ -801,7 +841,7 @@ return a string prefixed with one space." 'company-show-numbers-function "use `company-quick-access-hint-function' instead, but adjust the expected values appropriately." - "0.9.14") + "0.10.0") (defcustom company-quick-access-hint-function #'company-quick-access-hint-key "Function called to get quick-access hints for the candidates. @@ -865,8 +905,9 @@ asynchronous call into synchronous.") (define-key keymap [up-mouse-3] 'ignore) (define-key keymap [return] 'company-complete-selection) (define-key keymap (kbd "RET") 'company-complete-selection) - (define-key keymap [tab] 'company-complete-common) - (define-key keymap (kbd "TAB") 'company-complete-common) + (define-key keymap [tab] 'company-complete-common-or-cycle) + (define-key keymap (kbd "TAB") 'company-complete-common-or-cycle) + (define-key keymap [backtab] 'company-cycle-backward) (define-key keymap (kbd "") 'company-show-doc-buffer) (define-key keymap (kbd "C-h") 'company-show-doc-buffer) (define-key keymap "\C-w" 'company-show-location) @@ -985,8 +1026,7 @@ keymap during active completions (`company-active-map'): (remove-hook 'pre-command-hook 'company-pre-command t) (remove-hook 'post-command-hook 'company-post-command t) (remove-hook 'yas-keymap-disable-hook 'company--active-p t) - (company-cancel) - (kill-local-variable 'company-point))) + (company-cancel))) (defcustom company-global-modes t "Modes for which `company-mode' mode is turned on by `global-company-mode'. @@ -1041,10 +1081,10 @@ means that `company-mode' is always turned on except in `message-mode' buffers." (defun company-install-map () (unless (or (cdar company-emulation-alist) (null company-my-keymap)) - (setf (cdar company-emulation-alist) company-my-keymap))) + (setq-local company-emulation-alist `((t . ,company-my-keymap))))) (defun company-uninstall-map () - (setf (cdar company-emulation-alist) nil)) + (kill-local-variable 'company-emulation-alist)) (defun company--company-command-p (keys) "Checks if the keys are part of company's overriding keymap" @@ -1055,14 +1095,19 @@ means that `company-mode' is always turned on except in `message-mode' buffers." (declare-function line-number-display-width "indent.c") (defun company--posn-col-row (posn) - (let ((col (car (posn-col-row posn))) - ;; `posn-col-row' doesn't work well with lines of different height. - ;; `posn-actual-col-row' doesn't handle multiple-width characters. - (row (cdr (or (posn-actual-col-row posn) - ;; When position is non-visible for some reason. - (posn-col-row posn))))) + (let* ((col-row (if (>= emacs-major-version 29) + (with-no-warnings ;with 2 arguments, but accepts only 1 + (posn-col-row posn t)) + (posn-col-row posn))) + (col (car col-row)) + ;; `posn-col-row' doesn't work well with lines of different height. + ;; `posn-actual-col-row' doesn't handle multiple-width characters. + (row (cdr (or (posn-actual-col-row posn) + ;; When position is non-visible for some reason. + col-row)))) ;; posn-col-row return value relative to the left (when (eq (current-bidi-paragraph-direction) 'right-to-left) + ;; `remap' as 3rd argument to window-body-width is E30+ only :-( (let ((ww (window-body-width))) (setq col (- ww col)))) (when (bound-and-true-p display-line-numbers) @@ -1083,6 +1128,10 @@ means that `company-mode' is always turned on except in `message-mode' buffers." (when (looking-back regexp limit) (or (match-string-no-properties (or expression 0)) ""))) +(defun company-grab-suffix (regexp &optional expression) + (when (looking-at regexp) + (or (match-string-no-properties (or expression 0)) ""))) + (defun company-grab-line (regexp &optional expression) "Return a match string for REGEXP if it matches text before point. If EXPRESSION is non-nil, return the match string for the respective @@ -1092,36 +1141,49 @@ Matching is limited to the current line." (company-grab regexp expression (line-beginning-position)))) (defun company-grab-symbol () - "If point is at the end of a symbol, return it. -Otherwise, if point is not inside a symbol, return an empty string." - (if (looking-at "\\_>") - (buffer-substring (point) (save-excursion (skip-syntax-backward "w_") - (point))) - (unless (and (char-after) (memq (char-syntax (char-after)) '(?w ?_))) - ""))) + "Return buffer substring from the beginning of the symbol until point." + (buffer-substring (point) (save-excursion (skip-syntax-backward "w_") + (point)))) + +(defun company-grab-symbol-suffix () + "Return buffer substring from point until the end of the symbol." + (buffer-substring (point) (save-excursion (skip-syntax-forward "w_") + (point)))) (defun company-grab-word () - "If point is at the end of a word, return it. -Otherwise, if point is not inside a symbol, return an empty string." - (if (looking-at "\\>") - (buffer-substring (point) (save-excursion (skip-syntax-backward "w") - (point))) - (unless (and (char-after) (eq (char-syntax (char-after)) ?w)) - ""))) - -(defun company-grab-symbol-cons (idle-begin-after-re &optional max-len) - "Return a string SYMBOL or a cons (SYMBOL . t). -SYMBOL is as returned by `company-grab-symbol'. If the text before point -matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." - (let ((symbol (company-grab-symbol))) - (when symbol + "Return buffer substring from the beginning of the word until point." + (buffer-substring (point) (save-excursion (skip-syntax-backward "w") + (point)))) + +(defun company-grab-word-suffix () + "Return buffer substring from the beginning of the word until point." + (buffer-substring (point) (save-excursion (skip-syntax-forward "w") + (point)))) + +(defun company-grab-symbol-parts (&optional idle-begin-after-re max-len) + "Return a list (PREFIX SUFFIX &optional OVERRIDE). + +IDLE-BEGIN-AFTER-RE, if non-nil, must be a regexp. + +Where OVERRIDE might be t is IDLE-BEGIN-AFTER-RE is non-nil and the text +before prefix matches it. PREFIX and SUFFIX are as returned by +`company-grab-symbol' and `company-grab-symbol-suffix'. +MAX-LEN is how far back to try to match the IDLE-BEGIN-AFTER-RE regexp." + (let ((prefix (company-grab-symbol)) + suffix override) + (setq suffix (company-grab-symbol-suffix)) + (when idle-begin-after-re (save-excursion - (forward-char (- (length symbol))) - (if (looking-back idle-begin-after-re (if max-len - (- (point) max-len) - (line-beginning-position))) - (cons symbol t) - symbol))))) + (forward-char (- (length prefix))) + (when (looking-back idle-begin-after-re (if max-len + (- (point) max-len) + (line-beginning-position))) + (setq override t)))) + (list prefix suffix override))) + +(define-obsolete-function-alias + 'company-grab-symbol-cons + 'company-grab-symbol-parts "1.0") (defun company-in-string-or-comment () "Return non-nil if point is within a string or comment." @@ -1130,6 +1192,133 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." (car (setq ppss (cdr ppss))) (nth 3 ppss)))) +(defun company-substitute-prefix (prefix strings) + (let ((len (length prefix))) + (mapcar + (lambda (s) + (if (eq t (compare-strings prefix 0 len s 0 len)) + s + (concat prefix (substring s len)))) + strings))) + +(defun company--match-from-capf-face (str) + "Compute `match' result from a CAPF's completion fontification." + (let* ((match-start nil) (pos -1) + (prop-value nil) (faces nil) + (has-face-p nil) chunks + (limit (length str))) + (while (< pos limit) + (setq pos + (if (< pos 0) 0 (next-property-change pos str limit))) + (setq prop-value (or (get-text-property pos 'face str) + (get-text-property pos 'font-lock-face str)) + faces (if (listp prop-value) prop-value (list prop-value)) + has-face-p (memq 'completions-common-part faces)) + (cond ((and (not match-start) has-face-p) + (setq match-start pos)) + ((and match-start (not has-face-p)) + (push (cons match-start pos) chunks) + (setq match-start nil)))) + (nreverse chunks))) + +(defun company--capf-completions (prefix suffix table &optional pred meta) + (cl-letf* ((keep-suffix t) + (wrapper + (lambda (&rest args) + ;; If emacs22 style is used, suffix is ignored. + ;; That's the only popular completion style that does this. + (let ((res (apply #'completion-emacs22-all-completions args))) + (when res (setq keep-suffix nil)) + res))) + (completion-styles-alist (copy-tree completion-styles-alist)) + ((nth 2 (assoc 'emacs22 completion-styles-alist)) + wrapper) + (all (completion-all-completions (concat prefix suffix) + table pred + (length prefix) + meta)) + (last (last all)) + (base-size (or (cdr last) 0)) + ;; base-suffix-size is not available, but it's usually simple. + (bounds (completion-boundaries prefix table pred suffix))) + (when last + (setcdr last nil)) + (unless keep-suffix + (setcdr bounds 0)) + `((:completions . ,all) + (:boundaries . ,(cons (substring prefix base-size) + (substring suffix 0 (cdr bounds))))))) + +(defun company--capf-expand-common (prefix suffix table &optional pred metadata) + (let* ((res + (completion-try-completion (concat prefix suffix) + table pred (length prefix) metadata))) + (cond + ((null res) + 'no-match) + ((memq res '(t nil)) + (cons prefix suffix)) + (t + (cons + (substring (car res) 0 (cdr res)) + (substring (car res) (cdr res))))))) + +;; We store boundaries as markers because when the `unhide' frontend action is +;; called, the completions are still being fetched. So the capf boundaries info +;; can't be relied to be fresh by other means. +(defun company--capf-boundaries-markers (string-pair &optional markers) + "STRING-PAIR is (PREFIX . SUFFIX) and MARKERS is a pair to reuse." + (when (or (not markers) + (stringp (car markers))) + (setq markers (cons (make-marker) + (make-marker)))) + (move-marker (car markers) (- (point) (length (car string-pair)))) + (move-marker (cdr markers) (+ (point) (length (cdr string-pair)))) + markers) + +(defun company--capf-boundaries (markers) + (let* ((beg (car markers)) + (end (cdr markers)) + res) + (when (> (point) end) (setq end (point))) + (setq res (cons (buffer-substring beg (point)) + (buffer-substring (point) end))) + res)) + +(defvar company--cache (make-hash-table :test #'equal :size 10)) + +(cl-defun company-cache-fetch (key + fetcher + &key expire check-tag) + "Fetch the value assigned to KEY in the cache. +When not found, or when found to be stale, calls FETCHER to compute the +result. When EXPIRE is non-nil, the value will be deleted at the end of +completion. CHECK-TAG, when present, is saved as well, and the entry will +be recomputed when this value changes." + ;; We could make EXPIRE accept a time value as well. + (let ((res (gethash key company--cache 'none)) + value) + (if (and (not (eq res 'none)) + (or (not check-tag) + (equal check-tag (assoc-default :check-tag res)))) + (assoc-default :value res) + (setq res (list (cons :value (setq value (funcall fetcher))))) + (if expire (push '(:expire . t) res)) + (if check-tag (push `(:check-tag . ,check-tag) res)) + (puthash key res company--cache) + value))) + +(defun company-cache-delete (key) + "Delete KEY from cache." + (remhash key company--cache)) + +(defun company-cache-expire () + "Delete all keys from the cache that are set to be expired." + (maphash (lambda (k v) + (when (assoc-default :expire v) + (remhash k company--cache))) + company--cache)) + (defun company-call-backend (&rest args) (company--force-sync #'company-call-backend-raw args company-backend)) @@ -1165,6 +1354,9 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." (error (error "Company: backend %s error \"%s\" with args %s" company-backend (error-message-string err) args)))) +(defvar-local company--multi-uncached-backends nil) +(defvar-local company--multi-min-prefix nil) + (defun company--multi-backend-adapter (backends command &rest args) (let ((backends (cl-loop for b in backends when (or (keywordp b) @@ -1172,17 +1364,35 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." collect b)) (separate (memq :separate backends))) - (when (eq command 'prefix) - (setq backends (butlast backends (length (member :with backends))))) - - (setq backends (cl-delete-if #'keywordp backends)) + (unless (eq command 'prefix) + (setq backends (cl-delete-if #'keywordp backends))) (pcase command (`candidates - (company--multi-backend-adapter-candidates backends (car args) separate)) + (company--multi-backend-adapter-candidates backends + (or company--multi-min-prefix 0) + separate)) + (`set-min-prefix (setq company--multi-min-prefix (car args))) (`sorted separate) (`duplicates (not separate)) - ((or `prefix `ignore-case `no-cache `require-match) + ((and `no-cache + (pred (lambda (_) + (let* (found + (uncached company--multi-uncached-backends)) + (dolist (backend backends) + (when + (and (member backend uncached) + (company--good-prefix-p + (let ((company-backend backend)) + (company-call-backend 'prefix)) + (or company--multi-min-prefix 0))) + (setq found t + company--multi-uncached-backends + (delete backend + company--multi-uncached-backends)))) + found)))) + t) + ((or `ignore-case `no-cache `require-match) (let (value) (cl-dolist (backend backends) (when (setq value (company--force-sync @@ -1191,6 +1401,24 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." (eq value 'keep-prefix)) (setq value t)) (cl-return value))))) + (`prefix (company--multi-prefix backends)) + (`adjust-boundaries + (let ((arg (car args))) + (when (> (length arg) 0) + (let* ((backend (or (get-text-property 0 'company-backend arg) + (car backends))) + (entity (company--force-sync backend '(prefix) backend)) + (prefix (company--prefix-str entity)) + (suffix (company--suffix-str entity))) + (setq args (list arg prefix suffix)) + (or + (apply backend command args) + (cons prefix suffix)))))) + (`expand-common + (apply #'company--multi-expand-common + backends + (or company--multi-min-prefix 0) + args)) (_ (let ((arg (car args))) (when (> (length arg) 0) @@ -1198,20 +1426,135 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." (car backends)))) (apply backend command args)))))))) -(defun company--multi-backend-adapter-candidates (backends prefix separate) - (let ((pairs (cl-loop for backend in backends - when (equal (company--prefix-str - (let ((company-backend backend)) - (company-call-backend 'prefix))) - prefix) - collect (cons (funcall backend 'candidates prefix) - (company--multi-candidates-mapper - backend - separate - ;; Small perf optimization: don't tag the - ;; candidates received from the first - ;; backend in the group. - (not (eq backend (car backends)))))))) +(defun company--multi-prefix (backends) + (let* ((backends-after-with (cdr (member :with backends))) + prefix suffix len) + + (dolist (backend backends) + (let* ((entity (and + (not (keywordp backend)) + (company--force-sync backend '(prefix) backend))) + (new-len (company--prefix-len entity))) + (when (stringp (company--prefix-str entity)) + (or (not backends-after-with) + (unless (memq backend backends-after-with) + (setq backends-after-with nil))) + (when (or + (null prefix) + (> (length (company--prefix-str entity)) + (length prefix))) + (setq prefix (company--prefix-str entity))) + (when (> (length (company--suffix-str entity)) + (length suffix)) + (setq suffix (company--suffix-str entity))) + (when (or (eq t new-len) + (and new-len + (not (eq t len)) + (or (not len) (> new-len len)))) + (setq len new-len))))) + (when (and prefix + (not backends-after-with)) + (list prefix suffix len)))) + +(defun company--multi-expand-common (backends min-length prefix suffix) + (let ((tuples + (cl-loop for backend in backends + for bp = (let ((company-backend backend)) + (company-call-backend 'prefix)) + for expansion = + (when (company--good-prefix-p bp min-length) + (let ((inhibit-redisplay t) + (company-backend backend)) + (company--expand-common (company--prefix-str bp) + (company--suffix-str bp)))) + when (consp expansion) + collect + (list backend bp expansion))) + replacements) + (dolist (tuple tuples) + (cl-assert (string-suffix-p (company--prefix-str (nth 1 tuple)) + prefix)) + (cl-assert (string-prefix-p (company--suffix-str (nth 1 tuple)) + suffix))) + ;; We try to find the smallest possible edit for each backend's expansion + ;; (minimum prefix and suffix, beyond which the area is unchanged). + (setq replacements + (mapcar + (lambda (tuple) + (let* ((backend-prefix (company--prefix-str (nth 1 tuple))) + (backend-suffix (company--suffix-str (nth 1 tuple))) + (bplen (length backend-prefix)) + (bslen (length backend-suffix)) + (beg 0) + (end 0) + (rep-suffix-len (length (cdr (nth 2 tuple)))) + (max-beg (min bplen (length (car (nth 2 tuple))))) + (max-end (min bslen rep-suffix-len))) + (while (and (< beg max-beg) + (= (aref backend-prefix beg) + (aref (car (nth 2 tuple)) beg))) + (cl-incf beg)) + (while (and (< end max-end) + (= (aref suffix (- bslen end 1)) + (aref (cdr (nth 2 tuple)) + (- rep-suffix-len end 1)))) + (cl-incf end)) + (list (- bplen beg) + (substring (car (nth 2 tuple)) beg) + (- bslen end) + (substring (cdr (nth 2 tuple)) 0 (- rep-suffix-len end)) + (nth 0 tuple)))) + tuples)) + (setq replacements (sort replacements + (lambda (t1 t2) (< (- (length (nth 1 t1)) (nth 0 t1)) + (- (length (nth 1 t2)) (nth 0 t2)))))) + (or + (let ((choice (car replacements))) + ;; See if every replacement is similar enough to the one we selected: + ;; same suffix and beg/end and a prefix that starts with the proposed. + ;; + ;; More advanced checks seem possible, but with some backends reacting to + ;; buffer contents (not just string arguments) it seems we'd need to + ;; change the buffer contents first, then fetch `candidates' for each, + ;; and revert at the end. Might be error-prone. + (and + choice + (cl-every + (lambda (replacement) + (and + (= (car replacement) (car choice)) + (= (nth 2 replacement) (nth 2 choice)) + (equal (nth 3 replacement) (nth 3 choice)) + (string-prefix-p (nth 1 choice) (nth 1 replacement)))) + (cdr replacements)) + ;; Proposed edit applied to the group's prefix and suffix. + (cons (concat (substring prefix 0 (- (length prefix) (nth 0 choice))) + (nth 1 choice)) + (concat (nth 3 choice) + (substring suffix (nth 2 choice)))))) + (and (null replacements) 'no-match) + ;; Didn't find anything suitable - return entity parts unchanged. + (cons prefix suffix)))) + +(defun company--multi-backend-adapter-candidates (backends min-length separate) + (let* (backend-prefix suffix + (pairs (cl-loop for backend in backends + when (let ((bp (let ((company-backend backend)) + (company-call-backend 'prefix)))) + ;; One might override min-length, another not. + (if (company--good-prefix-p bp min-length) + (setq backend-prefix (company--prefix-str bp) + suffix (company--suffix-str bp)) + (push backend company--multi-uncached-backends) + nil)) + collect (cons (funcall backend 'candidates backend-prefix suffix) + (company--multi-candidates-mapper + backend + separate + ;; Small perf optimization: don't tag the + ;; candidates received from the first + ;; backend in the group. + (not (eq backend (car backends)))))))) (company--merge-async pairs (lambda (values) (apply #'append values))))) (defun company--multi-candidates-mapper (backend separate tag) @@ -1253,19 +1596,40 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." (this-finisher (lambda (res) (setq pending (delq val pending)) (setcar cell (funcall mapper res)) - (funcall finisher)))) + (funcall-interactively finisher)))) (if (not (eq :async (car-safe val))) (funcall this-finisher val) (let ((fetcher (cdr val))) (funcall fetcher this-finisher))))))))))) -(defun company--prefix-str (prefix) - (or (car-safe prefix) prefix)) +(defun company--prefix-str (entity) + (or (car-safe entity) entity)) + +(defun company--prefix-len (entity) + (let ((cdr (cdr-safe entity)) + override) + (cond + ((consp cdr) + (setq override (cadr cdr))) + ((or (numberp cdr) (eq t cdr)) + (setq override cdr))) + (or override + (length + (if (stringp entity) + entity + (car entity)))))) + +(defun company--suffix-str (entity) + (if (stringp (car-safe (cdr-safe entity))) + (car-safe (cdr-safe entity)) + "")) ;;; completion mechanism ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar-local company-prefix nil) +(defvar-local company-suffix nil) + (defvar-local company-candidates nil) (defvar-local company-candidates-length nil) @@ -1283,7 +1647,10 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." (defvar-local company-selection-changed nil) (defvar-local company--manual-action nil - "Non-nil, if manual completion took place.") + "Non-nil if manual completion was performed by the user.") + +(defvar-local company--manual-now nil + "Non-nil if manual completion is being performed now.") (defvar-local company--manual-prefix nil) @@ -1291,20 +1658,22 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons." (defvar-local company-point nil) +(defvar-local company-valid-point nil) + (defvar company-timer nil) (defvar company-tooltip-timer nil) -(defsubst company-strip-prefix (str) - (substring str (length company-prefix))) +(defun company-strip-prefix (str prefix) + (substring str (length prefix))) -(defun company--insert-candidate (candidate) +(defun company--insert-candidate (candidate prefix) (when (> (length candidate) 0) (setq candidate (substring-no-properties candidate)) ;; XXX: Return value we check here is subject to change. (if (eq (company-call-backend 'ignore-case) 'keep-prefix) - (insert (company-strip-prefix candidate)) - (unless (equal company-prefix candidate) - (delete-region (- (point) (length company-prefix)) (point)) + (insert (company-strip-prefix candidate prefix)) + (unless (equal prefix candidate) + (delete-region (- (point) (length prefix)) (point)) (insert candidate))))) (defmacro company-with-candidate-inserted (candidate &rest body) @@ -1315,7 +1684,7 @@ can retrieve meta-data for them." `(let ((inhibit-modification-hooks t) (inhibit-point-motion-hooks t) (modified-p (buffer-modified-p))) - (company--insert-candidate ,candidate) + (company--insert-candidate ,candidate company-prefix) (unwind-protect (progn ,@body) (delete-region company-point (point)) @@ -1331,8 +1700,7 @@ 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) - (let ((prefix (company--clean-string company-prefix))) - (concat prefix (substring candidate (length prefix)))) + (concat company-prefix (substring candidate (length company-prefix))) candidate)) (defun company--should-complete () @@ -1360,9 +1728,6 @@ To toggle the value of this variable, call `company-show-doc-buffer' with a prefix argument.") (defun company-call-frontends (command) - (when (and company-auto-update-doc - (memq command '(update show))) - (company-show-doc-buffer)) (cl-loop for frontend in company-frontends collect (condition-case-unless-debug err (funcall frontend command) @@ -1400,7 +1765,8 @@ update if FORCE-UPDATE." (format "%s-<%s>" base name))))) (defun company-update-candidates (candidates) - (setq company-candidates-length (length candidates)) + (setq company-candidates-length (length candidates) + company-valid-point company-point) (if company-selection-changed ;; Try to restore the selection (let ((selected (and company-selection @@ -1429,12 +1795,11 @@ update if FORCE-UPDATE." (setq company-common (if (cdr company-candidates) (let ((common (try-completion "" company-candidates))) - (when (string-prefix-p company-prefix common - completion-ignore-case) - common)) + (and (stringp common) + common)) (car company-candidates))))) -(defun company-calculate-candidates (prefix ignore-case) +(defun company-calculate-candidates (prefix ignore-case suffix) (let ((candidates (cdr (assoc prefix company-candidates-cache)))) (or candidates (when company-candidates-cache @@ -1448,33 +1813,35 @@ update if FORCE-UPDATE." (cl-return t))))) ;; No cache match, call the backend. (let ((refresh-timer (run-with-timer company-async-redisplay-delay - nil #'company--sneaky-refresh))) - (setq candidates (company--preprocess-candidates - (company--fetch-candidates prefix))) - ;; If the backend is synchronous, no chance for the timer to run. - (cancel-timer refresh-timer) + nil + #'company--sneaky-refresh + prefix suffix))) + (unwind-protect + (setq candidates (company--preprocess-candidates + (company--fetch-candidates prefix suffix))) + ;; If the backend is synchronous, no chance for the timer to run. + (cancel-timer refresh-timer)) ;; Save in cache. (push (cons prefix candidates) company-candidates-cache))) ;; Only now apply the predicate and transformers. (company--postprocess-candidates candidates))) -(defun company--unique-match-p (candidates prefix ignore-case) +(defun company--unique-match-p (candidates prefix suffix ignore-case) (and candidates (not (cdr candidates)) (eq t (compare-strings (car candidates) nil nil - prefix nil nil ignore-case)) + (concat prefix suffix) nil nil ignore-case)) (not (eq (company-call-backend 'kind (car candidates)) 'snippet)))) -(defun company--fetch-candidates (prefix) - (let* ((non-essential (not (company-explicit-action-p))) +(defun company--fetch-candidates (prefix suffix) + (let* ((non-essential (not company--manual-now)) (inhibit-redisplay t) - (c (if (or company-selection-changed - ;; FIXME: This is not ideal, but we have not managed to deal - ;; with these situations in a better way yet. - (company-require-match-p)) - (company-call-backend 'candidates prefix) - (company-call-backend-raw 'candidates prefix)))) + ;; At least we need "fresh" completions if the current command will + ;; rely on the result (e.g. insert common, or finish completion). + (c (if company--manual-now + (company-call-backend 'candidates prefix suffix) + (company-call-backend-raw 'candidates prefix suffix)))) (if (not (eq (car c) :async)) c (let ((res 'none)) @@ -1493,12 +1860,18 @@ update if FORCE-UPDATE." (while (member (car unread-command-events) '(company-foo (t . company-foo))) (pop unread-command-events)) - (prog1 - (and (consp res) res) - (setq res 'exited)))))) + (let ((res-was res)) + (setq res 'exited) + (if (eq 'none res-was) + (throw 'interrupted 'new-input) + res-was)))))) -(defun company--sneaky-refresh () - (when company-candidates (company-call-frontends 'unhide)) +(defun company--sneaky-refresh (prefix suffix) + (when company-candidates + (let* ((company-prefix prefix) + (company-suffix suffix)) + (and prefix + (company-call-frontends 'unhide)))) (let (inhibit-redisplay) (redisplay)) (when company-candidates (company-call-frontends 'pre-command))) @@ -1616,11 +1989,11 @@ end of the match." :type 'integer) (defun company--render-icons-margin (icon-mapping root-dir candidate selected) - (if-let ((ws (window-system)) - (candidate candidate) - (kind (company-call-backend 'kind candidate)) - (icon-file (or (alist-get kind icon-mapping) - (alist-get t icon-mapping)))) + (if-let* ((ws (window-system)) + (candidate candidate) + (kind (company-call-backend 'kind candidate)) + (icon-file (or (alist-get kind icon-mapping) + (alist-get t icon-mapping)))) (let* ((bkg (face-attribute (if selected 'company-tooltip-selection 'company-tooltip) @@ -1646,6 +2019,7 @@ end of the match." :width icon-size :height icon-size :ascent 'center + ;; Transparency requires Emacs 28+. :background (unless (eq bkg 'unspecified) bkg))) (spacer-px-width (- (* company-icon-margin dfw) icon-size))) @@ -1744,10 +2118,10 @@ See `company-text-icons-mapping'." (defun company-text-icons-margin (candidate selected) "Margin function which returns unicode icons." - (when-let ((candidate candidate) - (kind (company-call-backend 'kind candidate)) - (conf (or (alist-get kind company-text-icons-mapping) - (alist-get t company-text-icons-mapping)))) + (when-let* ((candidate candidate) + (kind (company-call-backend 'kind candidate)) + (conf (or (alist-get kind company-text-icons-mapping) + (alist-get t company-text-icons-mapping)))) (cl-destructuring-bind (icon &optional fg bg) conf (propertize (format company-text-icons-format icon) @@ -1809,9 +2183,9 @@ PROPERTY return nil." (defun company-dot-icons-margin (candidate selected) "Margin function that uses a colored dot to display completion kind." - (when-let ((kind (company-call-backend 'kind candidate)) - (conf (or (assoc-default kind company-text-icons-mapping) - (assoc-default t company-text-icons-mapping)))) + (when-let* ((kind (company-call-backend 'kind candidate)) + (conf (or (assoc-default kind company-text-icons-mapping) + (assoc-default t company-text-icons-mapping)))) (cl-destructuring-bind (_icon &optional fg bg) conf (propertize company-dot-icons-format 'face @@ -1867,7 +2241,7 @@ Keywords and function definition names are ignored." (cl-delete-if (lambda (candidate) (goto-char w-start) - (when (and (not (equal candidate "")) + (when (and (not (string-empty-p candidate)) (search-forward candidate w-end t) ;; ^^^ optimize for large lists where most elements ;; won't have a match. @@ -1970,12 +2344,18 @@ prefix match (same case) will be prioritized." ;;;###autoload (defun company-manual-begin () + "Start the completion interface. + +Unlike `company-complete-selection' or `company-complete', this command +doesn't cause any immediate changes to the buffer text." (interactive) (company-assert-enabled) (setq company--manual-action t) (unwind-protect - (let ((company-minimum-prefix-length 0)) - (or company-candidates + (let ((company-minimum-prefix-length 0) + (company--manual-now t)) + (or (and company-candidates + (= company-valid-point (point))) (company-auto-begin))) (unless company-candidates (setq company--manual-action nil)))) @@ -2017,8 +2397,8 @@ For more details see `company-insertion-on-trigger' and (if (consp company-insertion-triggers) (memq (char-syntax (string-to-char input)) company-insertion-triggers) - (string-match (regexp-quote (substring input 0 1)) - company-insertion-triggers))))) + (string-match-p (regexp-quote (substring input 0 1)) + company-insertion-triggers))))) (defun company--incremental-p () (and (> (point) company-point) @@ -2042,44 +2422,62 @@ For more details see `company-insertion-on-trigger' and (company-cancel 'non-unique)) ((company-require-match-p) ;; Wrong incremental input, but required match. - (delete-char (- company-point (point))) + (delete-char (- company-valid-point (point))) (ding) (message "Matching input is required") company-candidates) (t (company-cancel)))) -(defun company--good-prefix-p (prefix) +(defun company--good-prefix-p (prefix min-length) (and (stringp (company--prefix-str prefix)) ;excludes 'stop - (or (eq (cdr-safe prefix) t) - (let ((len (or (cdr-safe prefix) (length prefix)))) - (if company--manual-prefix - (or (not company-abort-manual-when-too-short) - ;; Must not be less than minimum or initial length. - (>= len (min company-minimum-prefix-length - (length company--manual-prefix)))) - (>= len company-minimum-prefix-length)))))) + (or (eq (company--prefix-len prefix) t) + (>= (company--prefix-len prefix) + min-length)))) + +(defun company--prefix-min-length () + (if company--manual-prefix + (if company-abort-manual-when-too-short + ;; Must not be less than minimum or initial length. + (min company-minimum-prefix-length + (if-let* ((mp-len-override (cdr-safe company--manual-prefix))) + (if (numberp mp-len-override) + mp-len-override + (length (car-safe company--manual-prefix))) + (length company--manual-prefix))) + 0) + company-minimum-prefix-length)) (defun company--continue () (when (company-call-backend 'no-cache company-prefix) ;; Don't complete existing candidates, fetch new ones. (setq company-candidates-cache nil)) (let* ((new-prefix (company-call-backend 'prefix)) + (new-suffix (company--suffix-str new-prefix)) (ignore-case (company-call-backend 'ignore-case)) - (c (when (and (company--good-prefix-p new-prefix) - (setq new-prefix (company--prefix-str new-prefix)) - (= (- (point) (length new-prefix)) - (- company-point (length company-prefix)))) - (company-calculate-candidates new-prefix ignore-case)))) + (c (catch 'interrupted + (when (and (company--good-prefix-p new-prefix + (company--prefix-min-length)) + (setq new-prefix (company--prefix-str new-prefix)) + (= (- (point) (length new-prefix)) + (- company-point (length company-prefix)))) + (company-calculate-candidates new-prefix ignore-case new-suffix))))) (cond + ((eq c 'new-input) ; Keep the old completions, but update the rest. + (setq company-prefix new-prefix + company-suffix new-suffix + company-point (point)) + t) ((and company-abort-on-unique-match - (company--unique-match-p c new-prefix ignore-case)) + (company--unique-match-p c new-prefix new-suffix ignore-case)) ;; Handle it like completion was aborted, to differentiate from user ;; calling one of Company's commands to insert the candidate, ;; not to trigger template expansion, etc. (company-cancel 'unique)) ((consp c) ;; incremental match - (setq company-prefix new-prefix) + (setq company-prefix new-prefix + company-suffix new-suffix + company-point (point)) (company-update-candidates c) c) ((and (characterp last-command-event) @@ -2094,27 +2492,40 @@ For more details see `company-insertion-on-trigger' and (t (company--continue-failed new-prefix))))) (defun company--begin-new () - (let (prefix c) + (let ((min-prefix (company--prefix-min-length)) + entity c) (cl-dolist (backend (if company-backend ;; prefer manual override (list company-backend) company-backends)) - (setq prefix + (setq entity (if (or (symbolp backend) (functionp backend)) (when (company--maybe-init-backend backend) (let ((company-backend backend)) (company-call-backend 'prefix))) (company--multi-backend-adapter backend 'prefix))) - (when prefix - (when (company--good-prefix-p prefix) + (when entity + (when (and (company--good-prefix-p entity min-prefix) + (or (not company-inhibit-inside-symbols) + company--manual-action + (zerop (length (company--suffix-str entity))))) (let ((ignore-case (company-call-backend 'ignore-case))) - (setq company-prefix (company--prefix-str prefix) + ;; Keep this undocumented, esp. while only 1 backend needs it. + (company-call-backend 'set-min-prefix min-prefix) + (setq company-prefix (company--prefix-str entity) + company-suffix (company--suffix-str entity) + company-point (point) company-backend backend - c (company-calculate-candidates company-prefix ignore-case)) + c (catch 'interrupted + (company-calculate-candidates company-prefix ignore-case + company-suffix))) (cond + ((or (null c) (eq c 'new-input)) + (when company--manual-action + (message "No completion found"))) ((and company-abort-on-unique-match - (company--unique-match-p c company-prefix ignore-case) + (company--unique-match-p c company-prefix company-suffix ignore-case) (if company--manual-action ;; If `company-manual-begin' was called, the user ;; really wants something to happen. Otherwise... @@ -2122,12 +2533,9 @@ For more details see `company-insertion-on-trigger' and t)) ;; ...abort and run the hooks, e.g. to clear the cache. (company-cancel 'unique)) - ((null c) - (when company--manual-action - (message "No completion found"))) (t ;; We got completions! (when company--manual-action - (setq company--manual-prefix prefix)) + (setq company--manual-prefix entity)) (company-update-candidates c) (run-hook-with-args 'company-completion-started-hook (company-explicit-action-p)) @@ -2139,11 +2547,11 @@ For more details see `company-insertion-on-trigger' and (company-candidates (company--continue)) ((company--should-complete) + (company-cache-expire) (company--begin-new))) (if (not company-candidates) (setq company-backend nil) - (setq company-point (point) - company--point-max (point-max)) + (setq company--point-max (point-max)) (company-ensure-emulation-alist) (company-enable-overriding-keymap company-active-map) (company-call-frontends 'update))) @@ -2163,6 +2571,8 @@ For more details see `company-insertion-on-trigger' and company--manual-action nil company--manual-prefix nil company--point-max nil + company--multi-uncached-backends nil + company--multi-min-prefix nil company-point nil) (when company-timer (cancel-timer company-timer)) @@ -2185,12 +2595,49 @@ For more details see `company-insertion-on-trigger' and (company-cancel 'abort)) (defun company-finish (result) - (company--insert-candidate result) - (company-cancel result)) + (pcase-let ((`(,prefix . ,suffix) (company--boundaries result))) + (company--insert-candidate result (or prefix company-prefix)) + (and (> (length suffix) 0) + (delete-region (point) (+ (point) (length suffix)))) + (let ((tick (buffer-chars-modified-tick)) + (backend company-backend)) + ;; Call backend's `post-completion' and run other hooks, then exit. + (company-cancel result) + ;; Try restarting completion, to see if we moved into a new field. + ;; Most commonly, this would be after entering a dir in file completion. + (when (= (buffer-chars-modified-tick) tick) + (let (company-require-match) + (setq company-backend backend + company--manual-prefix 0) + (company--begin-new)) + (unless (and company-candidates + (equal (company--boundaries) '("" . ""))) + (company-cancel)))))) (defsubst company-keep (command) (and (symbolp command) (get command 'company-keep))) +(defun company--proper-suffix-p (candidate) + (and + (>= (length candidate) + (+ (length company-prefix) + (length company-suffix))) + (string-suffix-p company-suffix candidate + (company-call-backend 'ignore-case)))) + +(defun company--boundaries (&optional candidate) + (unless candidate + (setq candidate (nth (or company-selection 0) company-candidates))) + (or + (company-call-backend 'adjust-boundaries + candidate + company-prefix company-suffix) + (and + ;; Default to replacing the suffix only if the completion ends with it. + (company--proper-suffix-p candidate) + (cons company-prefix company-suffix)) + (cons company-prefix ""))) + (defun company--active-p () company-candidates) @@ -2223,11 +2670,19 @@ For more details see `company-insertion-on-trigger' and (unless (company-keep this-command) (condition-case-unless-debug err (progn - (unless (equal (point) company-point) + (unless (and (equal (point) company-point) + (equal (point-max) company--point-max)) (let (company-idle-delay) ; Against misbehavior while debugging. (company--perform))) (if company-candidates - (company-call-frontends 'post-command) + (progn + (company-call-frontends 'post-command) + (when company-auto-update-doc + (condition-case nil + (unless (company--electric-command-p) + (company-show-doc-buffer)) + (user-error nil) + (quit nil)))) (let ((delay (company--idle-delay))) (and (numberp delay) (not defining-kbd-macro) @@ -2356,11 +2811,12 @@ each one wraps a part of the input string." (defun company--search-update-predicate (ss) (let* ((re (funcall company-search-regexp-function ss)) (company-candidates-predicate - (and (not (string= re "")) + (and (not (string-empty-p re)) company-search-filtering - (lambda (candidate) (string-match re candidate)))) + (lambda (candidate) (string-match-p re candidate)))) (cc (company-calculate-candidates company-prefix - (company-call-backend 'ignore-case)))) + (company-call-backend 'ignore-case) + company-suffix))) (unless cc (user-error "No match")) (company-update-candidates cc))) @@ -2374,7 +2830,7 @@ each one wraps a part of the input string." (defun company--search-assert-input () (company--search-assert-enabled) - (when (string= company-search-string "") + (when (string-empty-p company-search-string) (user-error "Empty search string"))) (defun company-search-repeat-forward () @@ -2427,7 +2883,7 @@ each one wraps a part of the input string." (defun company-search-delete-char () (interactive) (company--search-assert-enabled) - (if (string= company-search-string "") + (if (string-empty-p company-search-string) (ding) (let ((ss (substring company-search-string 0 -1))) (when company-search-filtering @@ -2635,12 +3091,56 @@ For use in the `select-mouse' frontend action. `let'-bound.") (company-complete-selection))) (defun company-complete-selection () - "Insert the selected candidate." + "Insert the selected candidate. + +Restart completion if a new field is entered. A field is indicated by +`adjust-boundaries' as implemented in the backend. If both adjusted prefix +and adjusted suffix are empty strings, that means a new field." (interactive) (when (and (company-manual-begin) company-selection) (let ((result (nth company-selection company-candidates))) (company-finish result)))) +(defun company--expand-common (prefix suffix) + (let ((expansion (company-call-backend 'expand-common prefix suffix))) + (unless expansion + ;; Backend doesn't implement this, try emulating. + (let* (;; XXX: We could also filter/group `company-candidates'. + (candidates (company-call-backend 'candidates prefix suffix)) + ;; Assuming that boundaries don't vary between completions here. + ;; If they do, the backend should have a custom `expand-common'. + (boundaries-prefix (car (company--boundaries))) + (completion-ignore-case (company-call-backend 'ignore-case)) + (trycmp (try-completion boundaries-prefix candidates)) + (common (if (eq trycmp t) (car candidates) trycmp)) + (max-len (when (and common + (cl-every (lambda (s) (string-suffix-p + suffix s + completion-ignore-case)) + candidates)) + (- + (apply #'min + (mapcar #'length candidates)) + (length suffix)))) + (common (if max-len + (substring common 0 + (min max-len (length common))) + common))) + (setq expansion + (cond + ((null candidates) + 'no-match) + ((string-prefix-p boundaries-prefix common t) + (cons (concat + (substring prefix + 0 + (- (length prefix) + (length boundaries-prefix))) + common) + suffix)) + (t (cons prefix suffix)))))) + expansion)) + (defun company-complete-common () "Insert the common part of all candidates." (interactive) @@ -2648,7 +3148,19 @@ For use in the `select-mouse' frontend action. `let'-bound.") (if (and (not (cdr company-candidates)) (equal company-common (car company-candidates))) (company-complete-selection) - (company--insert-candidate company-common)))) + (let ((expansion (company--expand-common company-prefix + company-suffix))) + (when (eq expansion 'no-match) + (user-error "No matches for the current input")) + (unless (equal (car expansion) company-prefix) + (if (eq (company-call-backend 'ignore-case) 'keep-prefix) + (insert (substring (car expansion) (length company-prefix))) + (delete-region (- (point) (length company-prefix)) (point)) + (insert (car expansion)))) + (unless (equal (cdr expansion) company-suffix) + (save-excursion + (delete-region (point) (+ (point) (length company-suffix))) + (insert (cdr expansion)))))))) (defun company-complete-common-or-cycle (&optional arg) "Insert the common part of all candidates, or select the next one. @@ -2663,6 +3175,11 @@ With ARG, move by that many elements." (current-prefix-arg arg)) (call-interactively 'company-select-next)))))) +(defun company-cycle-backward (&optional arg) + (interactive "p") + (let ((company-selection-wrap-around t)) + (company-select-previous arg))) + (defun company-complete-common-or-show-delayed-tooltip () "Insert the common part of all candidates, or show a tooltip." (interactive) @@ -2715,12 +3232,13 @@ inserted." (call-interactively 'company-complete-selection) (call-interactively 'company-complete-common) (when company-candidates - (setq this-command 'company-complete-common))))) + (setq this-command 'company-complete-common))) + this-command)) (define-obsolete-function-alias 'company-complete-number 'company-complete-tooltip-row - "0.9.14") + "0.10.0") (defun company-complete-tooltip-row (number) "Insert a candidate visible on the tooltip's row NUMBER. @@ -2785,23 +3303,155 @@ from the candidates list.") (aref company-space-strings len) (make-string len ?\ ))) +;; XXX: This is really a hack, but one that we could really get rid of only by +;; moving to the one-overlay-per-line scheme. +(defmacro company--with-face-remappings (&rest body) + `(let ((fra-local (and (local-variable-p 'face-remapping-alist) + face-remapping-alist)) + (bdt-local (and (local-variable-p 'buffer-display-table) + buffer-display-table)) + (bufs (list (get-buffer-create " *string-pixel-width*") + (get-buffer-create " *company-sps*")))) + (unwind-protect + (progn + (dolist (buf bufs) + (with-current-buffer buf + (when (bound-and-true-p display-line-numbers) + ;; Workaround for debbugs#67248. + (setq-local display-line-numbers nil)) + (when fra-local + (setq-local face-remapping-alist fra-local)) + (when bdt-local + (setq-local buffer-display-table bdt-local)))) + ,@body) + (dolist (buf bufs) + (and (buffer-live-p buf) + (with-current-buffer buf + (kill-local-variable 'face-remapping-alist) + (kill-local-variable 'buffer-display-table))))))) + +(declare-function buffer-text-pixel-size "xdisp.c") + +(defun company--string-pixel-width (string) + (if (zerop (length string)) + 0 + ;; Keeping a work buffer around is more efficient than creating a + ;; new temporary buffer. + (with-current-buffer (get-buffer-create " *string-pixel-width*") + ;; `display-line-numbers-mode' is enabled in internal buffers + ;; that breaks width calculation, so need to disable (bug#59311) + (when (bound-and-true-p display-line-numbers-mode) + (with-no-warnings ;; Emacs 25 + (display-line-numbers-mode -1))) + (delete-region (point-min) (point-max)) + (insert string) + (if (fboundp #'buffer-text-pixel-size) + ;; Emacs 29.1+ + (car (buffer-text-pixel-size nil nil t)) + (let ((wb (window-buffer)) + (hscroll (window-hscroll)) + (dedicated (window-dedicated-p)) + buffer-list-update-hook) + (unwind-protect + (progn + (when dedicated + (set-window-dedicated-p nil nil)) + (set-window-buffer nil (current-buffer)) + (car + (window-text-pixel-size nil nil nil 55555))) + (set-window-buffer nil wb) + (set-window-hscroll nil hscroll) + (when dedicated + (set-window-dedicated-p nil dedicated)))))))) + +(defun company--string-width (str) + (if (display-graphic-p) + (ceiling (/ (company--string-pixel-width str) + (float (default-font-width)))) + (string-width str))) + +;; TODO: Add more tests! +(defun company-safe-pixel-substring (str from &optional to) + (let ((from-chars 0) + (to-chars 0) + spw-from spw-to + spw-to-prev + front back + (orig-buf (window-buffer)) + (bis buffer-invisibility-spec) + (inhibit-read-only t) + (inhibit-modification-hooks t) + (dedicated (window-dedicated-p)) + (hscroll (window-hscroll)) + window-configuration-change-hook + buffer-list-update-hook) + (with-current-buffer (get-buffer-create " *company-sps*") + (unwind-protect + (progn + (delete-region (point-min) (point-max)) + (insert str) + (setq-local buffer-invisibility-spec bis) + (when dedicated (set-window-dedicated-p nil nil)) + (set-window-buffer nil (current-buffer) t) + + (vertical-motion (cons (/ from (frame-char-width)) 0)) + (setq from-chars (point)) + (setq spw-from + (if (bobp) 0 + (car (window-text-pixel-size nil (point-min) (point) 55555)))) + (while (and (< spw-from from) + (not (eolp))) + (forward-char 1) + (setq spw-from + (car (window-text-pixel-size nil (point-min) (point) 55555))) + (setq from-chars (point))) + + (if (= from-chars (point-max)) + (if (and to (> to from)) + (propertize " " 'display `(space . (:width (,(- to from))))) + "") + (if (not to) + (setq to-chars (point-max)) + (vertical-motion (cons (/ to (frame-char-width)) 0)) + (setq to-chars (point)) + (setq spw-to + (if (bobp) 0 + (car (window-text-pixel-size nil (point-min) (point) 55555)))) + (while (and (< spw-to to) + (not (eolp))) + (setq spw-to-prev spw-to) + (forward-char 1) + (setq spw-to + (car (window-text-pixel-size nil (point-min) (point) 55555))) + (when (<= spw-to to) + (setq to-chars (point))))) + + (unless spw-to-prev (setq spw-to-prev spw-to)) + + (when (> spw-from from) + (setq front (propertize " " 'display + `(space . (:width (,(- spw-from from))))))) + (when (and to (/= spw-to to)) + (setq back (propertize + " " 'display + `(space . (:width (,(- to + (if (< spw-to to) + spw-to + spw-to-prev)))))))) + (concat front (buffer-substring from-chars to-chars) back))) + (set-window-buffer nil orig-buf t) + (set-window-hscroll nil hscroll) + (when dedicated + (set-window-dedicated-p nil dedicated)))))) + (defun company-safe-substring (str from &optional to) - (let ((bis buffer-invisibility-spec)) - (if (> from (string-width str)) + (let ((ll (length str))) + (if (> from ll) "" - (with-temp-buffer - (setq buffer-invisibility-spec bis) - (insert str) - (move-to-column from) - (let ((beg (point))) - (if to - (progn - (move-to-column to) - (concat (buffer-substring beg (point)) - (let ((padding (- to (current-column)))) - (when (> padding 0) - (company-space-string padding))))) - (buffer-substring beg (point-max)))))))) + (if to + (concat (substring str from (min to ll)) + (company-space-string (max 0 (- to ll)))) + (substring str from))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2830,16 +3480,19 @@ from the candidates list.") '(scroll-other-window scroll-other-window-down mwheel-scroll) "List of Commands that won't break out of electric commands.") +(defun company--electric-command-p () + (memq this-command company--electric-commands)) + (defun company--electric-restore-window-configuration () "Restore window configuration (after electric commands)." (when (and company--electric-saved-window-configuration - (not (memq this-command company--electric-commands))) + (not (company--electric-command-p))) (set-window-configuration company--electric-saved-window-configuration) (setq company--electric-saved-window-configuration nil))) (defmacro company--electric-do (&rest body) (declare (indent 0) (debug t)) - `(when (company-manual-begin) + `(when company-candidates (cl-assert (null company--electric-saved-window-configuration)) (setq company--electric-saved-window-configuration (current-window-configuration)) (let ((height (window-height)) @@ -2862,11 +3515,7 @@ from the candidates list.") (selection (or company-selection 0))) (let* ((selected (nth selection company-candidates)) (doc-buffer (or (company-call-backend 'doc-buffer selected) - (if company-auto-update-doc - (company-doc-buffer - (format "%s: No documentation available" - selected)) - (user-error "No documentation available")))) + (user-error "No documentation available"))) start) (when (consp doc-buffer) (setq start (cdr doc-buffer) @@ -2883,10 +3532,8 @@ automatically show the documentation buffer for each selection." (interactive "P") (when toggle-auto-update (setq company-auto-update-doc (not company-auto-update-doc))) - (if company-auto-update-doc - (company--show-doc-buffer) - (company--electric-do - (company--show-doc-buffer)))) + (company--electric-do + (company--show-doc-buffer))) (put 'company-show-doc-buffer 'company-keep t) (defun company-show-location () @@ -2990,7 +3637,9 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (when (or (stringp prefix) (consp prefix)) (let ((company-backend backend)) (condition-case nil - (setq cc (company-call-backend 'candidates (company--prefix-str prefix)) + (setq cc (company-call-backend 'candidates + (company--prefix-str prefix) + (company--suffix-str prefix)) annotations (mapcar (lambda (c) (cons c (company-call-backend 'annotation c))) @@ -3066,7 +3715,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (defun company-plainify (str) (let ((prefix (get-text-property 0 'line-prefix str))) - (when prefix ; Keep the original value unmodified, for no special reason. + (when (stringp prefix) ; Keep the original value unmodified, for no special reason. (setq str (concat prefix str)) (remove-text-properties 0 (length str) '(line-prefix) str))) (let* ((pieces (split-string str "\t")) @@ -3077,27 +3726,29 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (pop copy)) (apply 'concat pieces))) -(defun company--common-or-matches (value) +(defun company--common-or-matches (value &optional suffix) (let ((matches (company-call-backend 'match value))) - (when (and matches - company-common - (listp matches) - (= 1 (length matches)) - (= 0 (caar matches)) - (> (length company-common) (cdar matches))) - (setq matches nil)) (when (integerp matches) (setq matches `((0 . ,matches)))) (or matches - (and company-common `((0 . ,(length company-common)))) + (and company-common `((0 . ,(length company-common)) + ,@(list + (cons + (- (length value) + (length (or suffix + (cdr (company--boundaries value))))) + (length value))))) nil))) (defun company-fill-propertize (value annotation width selected left right) (let* ((margin (length left)) - (company-common (and company-common (company--clean-string company-common))) (common (company--common-or-matches value)) - (_ (setq value (company-reformat (company--pre-render value)) - annotation (and annotation (company--pre-render annotation t)))) + (_ (setq value + (company--clean-string + (company-reformat (company--pre-render value))) + annotation (and annotation + (company--clean-string + (company--pre-render annotation t))))) (ann-ralign company-tooltip-align-annotations) (ann-padding (or company-tooltip-annotation-padding 0)) (ann-truncate (< width @@ -3147,7 +3798,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area." nil line)) (when (let ((re (funcall company-search-regexp-function company-search-string))) - (and (not (string= re "")) + (and (not (string-empty-p re)) (string-match re value))) (pcase-dolist (`(,mbeg . ,mend) (company--search-chunks)) (let ((beg (+ margin mbeg)) @@ -3194,33 +3845,50 @@ If SHOW-VERSION is non-nil, show the version in the echo area." str))) (defun company--clean-string (str) - (replace-regexp-in-string - "\\([^[:graph:] ]\\)\\|\\(\ufeff\\)\\|[[:multibyte:]]" - (lambda (match) - (cond - ((match-beginning 1) - ;; FIXME: Better char for 'non-printable'? - ;; We shouldn't get any of these, but sometimes we might. - ;; The official "replacement character" is not supported by some fonts. - ;;"\ufffd" - "?" - ) - ((match-beginning 2) - ;; Zero-width non-breakable space. - "") - ((> (string-width match) 1) - (concat - (make-string (1- (string-width match)) ?\ufeff) - match)) - (t match))) - str)) + (let* ((add-pixels 0) + (add-length 0) + (new-str + (replace-regexp-in-string + "\\([^[:graph:] ]\\)\\|\\(\ufeff\\)\\|[[:multibyte:]]+" + (lambda (match) + (cond + ((match-beginning 1) + ;; FIXME: Better char for 'non-printable'? + ;; We shouldn't get any of these, but sometimes we might. + ;; The official "replacement character" is not supported by some fonts. + ;;"\ufffd" + (if (equal match "\n") + (propertize "\\\\n" 'face 'font-lock-escape-face) + "?") + ) + ((match-beginning 2) + ;; Zero-width non-breakable space. + "") + (t + ;; FIXME: Maybe move that counting later to a non-replacement loop. + (let ((msw (company--string-width match))) + (cl-incf add-pixels + (- (* (default-font-width) + msw) + (company--string-pixel-width match))) + (cl-incf add-length (- msw (length match))) + match + )) + )) + str))) + (if (>= 0 add-length) + new-str + (concat new-str + (propertize + (make-string add-length ?\ufeff) + 'display `(space . (:width (,add-pixels)))))))) ;;; replace (defun company-buffer-lines (beg end) (goto-char beg) (let (lines lines-moved) - (while (and (not (eobp)) ; http://debbugs.gnu.org/19553 + (while (and (not (eobp)) ; http://debbugs.gnu.org/19553 (> (setq lines-moved (vertical-motion 1)) 0) (<= (point) end)) (let ((bound (min end (point)))) @@ -3242,9 +3910,13 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (nreverse lines))) (defun company-modify-line (old new offset) - (concat (company-safe-substring old 0 offset) - new - (company-safe-substring old (+ offset (length new))))) + (if (not new) + ;; Avoid modifying OLD, e.g. to avoid "blinking" with half-spaces for + ;; double-width (or usually fractional) characters. + old + (concat (company-safe-pixel-substring old 0 offset) + new + (company-safe-pixel-substring old (+ offset (company--string-pixel-width new)))))) (defun company--show-numbers (numbered) (format " %s" (if (<= numbered 10) @@ -3254,24 +3926,30 @@ If SHOW-VERSION is non-nil, show the version in the echo area." 'company--show-numbers "use `company-quick-access-hint-key' instead, but adjust the expected values appropriately." - "0.9.14") + "0.10.0") (defsubst company--window-height () (if (fboundp 'window-screen-lines) (floor (window-screen-lines)) (window-body-height))) -(defun company--window-width () - (let ((ww (window-body-width))) +(defun company--window-width (&optional pixelwise) + (let ((ww (window-body-width nil pixelwise))) ;; Account for the line continuation column. (when (zerop (cadr (window-fringes))) - (cl-decf ww)) + (cl-decf ww (if pixelwise (company--string-pixel-width ">") 1))) (when (bound-and-true-p display-line-numbers) - (cl-decf ww (+ 2 (line-number-display-width)))) + (cl-decf ww + (if pixelwise + (line-number-display-width t) + (+ 2 (line-number-display-width))))) ;; whitespace-mode with newline-mark (when (and buffer-display-table (aref buffer-display-table ?\n)) - (cl-decf ww (1- (length (aref buffer-display-table ?\n))))) + (cl-decf ww + (if pixelwise + (company--string-pixel-width "\n") + (1- (length (aref buffer-display-table ?\n)))))) ww)) (defun company--face-attribute (face attr) @@ -3303,24 +3981,33 @@ but adjust the expected values appropriately." (when (and align-top company-tooltip-flip-when-above) (setq lines (reverse lines))) - (let ((width (length (car lines))) - (remaining-cols (- (+ (company--window-width) (window-hscroll)) - column))) - (when (> width remaining-cols) - (cl-decf column (- width remaining-cols)))) - - (let (new) + (let* ((px-width (company--string-pixel-width (car lines))) + ;; The (display (space :width (..))) spec is only applied to the + ;; visible part of the buffer (past hscroll), so subtracting + ;; window-scroll here is a good idea. But then we also need to slice + ;; the "old" strings so the hidden contents don't get shown. + ;; XXX: `auto-hscroll-mode' set to `current-line' is not supported. + (px-col (* (- column (window-hscroll)) (default-font-width))) + (remaining-px (- (company--window-width t) px-col)) + (hscroll-space (when (> (window-hscroll) 0) + (company-space-string (window-hscroll)))) + new) + (when (> px-width remaining-px) + (cl-decf px-col (- px-width remaining-px))) + (when hscroll-space + (setq old (mapcar (lambda (s) (company-safe-substring s (window-hscroll))) + old))) (when align-top ;; untouched lines first (dotimes (_ (- (length old) (length lines))) (push (pop old) new))) ;; length into old lines. (while old - (push (company-modify-line (pop old) (pop lines) column) + (push (company-modify-line (pop old) (pop lines) px-col) new)) ;; Append whole new lines. (while lines - (push (concat (company-space-string column) (pop lines)) + (push (concat (company-safe-pixel-substring "" 0 px-col) (pop lines)) new)) ;; XXX: Also see branch 'more-precise-extend'. @@ -3333,7 +4020,7 @@ but adjust the expected values appropriately." (when nl " \n") (cl-mapcan ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42552#23 - (lambda (line) (list line (propertize "\n" 'face nl-face))) + (lambda (line) (list hscroll-space line (propertize "\n" 'face nl-face))) (nreverse new))))) ;; https://debbugs.gnu.org/38563 (add-face-text-property 0 (length str) 'default t str) @@ -3348,6 +4035,7 @@ but adjust the expected values appropriately." (if company-tooltip-align-annotations 1 0))) left-margins left-margin-size + right-margin lines width lines-copy @@ -3382,6 +4070,7 @@ but adjust the expected values appropriately." (setq width (max (length previous) (length remainder)) lines (nthcdr company-tooltip-offset company-candidates) + right-margin (company--right-margin limit len) len (min limit len) lines-copy lines) @@ -3410,18 +4099,16 @@ but adjust the expected values appropriately." (annotation (company-call-backend 'annotation value)) (left (or (pop left-margins) (company-space-string left-margin-size)))) - (setq value (company--clean-string value)) (when annotation - (setq annotation (company--clean-string annotation)) (when company-tooltip-align-annotations ;; `lisp-completion-at-point' adds a space. (setq annotation (string-trim-left annotation)))) (push (list value annotation left) items) - (setq width (max (+ (length value) + (setq width (max (+ (company--string-width value) (if annotation - (+ (length annotation) + (+ (company--string-width annotation) company-tooltip-annotation-padding) - (length annotation))) + 0)) width)))) (setq width (min window-width @@ -3446,7 +4133,7 @@ but adjust the expected values appropriately." (str (car item)) (annotation (cadr item)) (left (nth 2 item)) - (right (company-space-string company-tooltip-margin)) + (right right-margin) (width width) (selected (equal selection i))) (when company-show-quick-access @@ -3454,7 +4141,7 @@ but adjust the expected values appropriately." left right))) (qa-hint (company-tooltip--format-quick-access-hint row selected))) - (cl-decf width (string-width qa-hint)) + (cl-decf width (company--string-width qa-hint)) (setf (gv-deref quick-access) (concat qa-hint (gv-deref quick-access)))) (cl-incf row)) @@ -3482,10 +4169,28 @@ but adjust the expected values appropriately." (cons lower upper)))) (defun company--scrollbar (i bounds) - (propertize " " 'face - (if (and (>= i (car bounds)) (<= i (cdr bounds))) - 'company-tooltip-scrollbar-thumb - 'company-tooltip-scrollbar-track))) + (let* ((scroll-width (ceiling (* (default-font-width) + company-tooltip-scrollbar-width)))) + (propertize " " + 'display `(space . (:width (,scroll-width))) + 'face + (if (and (>= i (car bounds)) (<= i (cdr bounds))) + 'company-tooltip-scrollbar-thumb + 'company-tooltip-scrollbar-track)))) + +(defun company--right-margin (limit length) + (if (or (not (eq company-tooltip-offset-display 'scrollbar)) + (not (display-graphic-p)) + (= company-tooltip-scrollbar-width 1) + (<= length limit)) + (company-space-string company-tooltip-margin) + (let* ((scroll-width (ceiling (* (default-font-width) + company-tooltip-scrollbar-width))) + (rest-width (- (* (default-font-width) company-tooltip-margin) + scroll-width))) + (propertize + (company-space-string company-tooltip-margin) + 'display `(space . (:width (,rest-width))))))) (defun company--scrollpos-line (text width fancy-margin-width) (propertize (concat (company-space-string company-tooltip-margin) @@ -3547,10 +4252,17 @@ Returns a negative number if the tooltip should be displayed above point." (let (nl beg end ov args) (save-excursion - (setq nl (< (move-to-window-line row) row) - beg (point) + (setq nl (< (move-to-window-line row) row)) + ;; HACK: Very specific to the log-edit buffer. Could alternatively + ;; look up the `display-line-numbers-disable' property, but with + ;; larger consequences. + (when (and (not nl) (> height 0)) + (while (eq (get-char-property (point) 'face) + 'log-edit-headers-separator) + (vertical-motion 1))) + (setq beg (point) end (save-excursion - (move-to-window-line (+ row (abs height))) + (vertical-motion (abs height)) (point)) ov (make-overlay beg end nil t) args (list (mapcar 'company-plainify @@ -3566,7 +4278,7 @@ Returns a negative number if the tooltip should be displayed above point." (overlay-put ov 'company-display (apply 'company--replacement-string lines column-offset args)) - (overlay-put ov 'company-width (string-width (car lines)))) + (overlay-put ov 'company-width (company--string-width (car lines)))) (overlay-put ov 'company-column column) (overlay-put ov 'company-height height)))) @@ -3575,7 +4287,8 @@ Returns a negative number if the tooltip should be displayed above point." (let* ((col-row (company--col-row pos)) (col (- (car col-row) column-offset))) (when (< col 0) (setq col 0)) - (company-pseudo-tooltip-show (1+ (cdr col-row)) col company-selection))) + (company--with-face-remappings + (company-pseudo-tooltip-show (1+ (cdr col-row)) col company-selection)))) (defun company-pseudo-tooltip-edit (selection) (let* ((height (overlay-get company-pseudo-tooltip-overlay 'company-height)) @@ -3583,7 +4296,7 @@ Returns a negative number if the tooltip should be displayed above point." (lines (cdr lines-and-offset)) (column-offset (car lines-and-offset))) (overlay-put company-pseudo-tooltip-overlay 'company-width - (string-width (car lines))) + (company--string-width (car lines))) (overlay-put company-pseudo-tooltip-overlay 'company-display (apply 'company--replacement-string lines column-offset @@ -3625,8 +4338,9 @@ Returns a negative number if the tooltip should be displayed above point." (overlay-put ov 'display "") (overlay-put ov 'window (selected-window))))) -(defun company-pseudo-tooltip-guard () +(defun company-pseudo-tooltip-guard (prefix) (list + (- (point) (length prefix)) (save-excursion (beginning-of-visual-line)) (window-width) (let ((ov company-pseudo-tooltip-overlay) @@ -3643,7 +4357,7 @@ Returns a negative number if the tooltip should be displayed above point." (pre-command (company-pseudo-tooltip-hide-temporarily)) (unhide (let ((ov company-pseudo-tooltip-overlay)) - (when (> (overlay-get ov 'company-height) 0) + (when (and ov (> (overlay-get ov 'company-height) 0)) ;; Sleight of hand: if the current line wraps, we adjust the ;; start of the overlay so that the popup does not zig-zag, ;; but don't update the popup's background. This seems just @@ -3654,25 +4368,30 @@ Returns a negative number if the tooltip should be displayed above point." (move-overlay ov (point) (overlay-end ov)))))) (company-pseudo-tooltip-unhide)) (post-command - (unless (when (overlayp company-pseudo-tooltip-overlay) - (let* ((ov company-pseudo-tooltip-overlay) - (old-height (overlay-get ov 'company-height)) - (new-height (company--pseudo-tooltip-height))) - (and - (>= (* old-height new-height) 0) - (>= (abs old-height) (abs new-height)) - (equal (company-pseudo-tooltip-guard) - (overlay-get ov 'company-guard))))) - ;; Redraw needed. - (company-pseudo-tooltip-show-at-point (point) (length company-prefix)) - (overlay-put company-pseudo-tooltip-overlay - 'company-guard (company-pseudo-tooltip-guard))) + (let ((prefix (car (company--boundaries))) + guard) + (unless (when (overlayp company-pseudo-tooltip-overlay) + (let* ((ov company-pseudo-tooltip-overlay) + (old-height (overlay-get ov 'company-height)) + (new-height (company--pseudo-tooltip-height))) + (and + (>= (* old-height new-height) 0) + (>= (abs old-height) (abs new-height)) + (equal (setq guard (company-pseudo-tooltip-guard prefix)) + (overlay-get ov 'company-guard))))) + ;; Redraw needed. + (company-pseudo-tooltip-show-at-point (point) + (length prefix)) + (overlay-put company-pseudo-tooltip-overlay + 'company-guard (or guard + (company-pseudo-tooltip-guard prefix))))) (company-pseudo-tooltip-unhide)) (show (setq company--tooltip-current-width 0)) (hide (company-pseudo-tooltip-hide) (setq company-tooltip-offset 0)) (update (when (overlayp company-pseudo-tooltip-overlay) - (company-pseudo-tooltip-edit company-selection))) + (company--with-face-remappings + (company-pseudo-tooltip-edit company-selection)))) (select-mouse (let ((event-col-row (company--event-col-row company-mouse-event)) (ovl-row (company--row)) @@ -3734,13 +4453,16 @@ Delay is determined by `company-tooltip-idle-delay'." (defvar-local company-preview-overlay nil) -(defun company-preview-show-at-point (pos completion) +(defun company-preview-show-at-point (pos completion &optional boundaries) (company-preview-hide) - (let* ((company-common (and company-common - (string-prefix-p company-prefix company-common) + (let* ((boundaries (or boundaries (company--boundaries completion))) + (prefix (car boundaries)) + (suffix (cdr boundaries)) + (company-common (and company-common + (string-prefix-p prefix company-common) company-common)) - (common (company--common-or-matches completion))) + (common (company--common-or-matches completion suffix))) (setq completion (copy-sequence (company--pre-render completion))) (add-face-text-property 0 (length completion) 'company-preview nil completion) @@ -3757,10 +4479,10 @@ Delay is determined by `company-tooltip-idle-delay'." (add-face-text-property mbeg mend 'company-preview-search nil completion))) - (setq completion (if (string-prefix-p company-prefix completion + (setq completion (if (string-prefix-p prefix completion (eq (company-call-backend 'ignore-case) 'keep-prefix)) - (company-strip-prefix completion) + (company-strip-prefix completion prefix) completion)) (when (string-prefix-p "\n" completion) @@ -3768,7 +4490,7 @@ Delay is determined by `company-tooltip-idle-delay'." (substring completion 1)))) (and (equal pos (point)) - (not (equal completion "")) + (not (string-empty-p completion)) (add-text-properties 0 1 '(cursor 1) completion)) (let* ((beg pos) @@ -3776,17 +4498,21 @@ Delay is determined by `company-tooltip-idle-delay'." (ptf-workaround (and pto (char-before pos) - (eq pos (overlay-start pto))))) + (eq pos (overlay-start pto)))) + (end pos)) ;; Try to accommodate for the pseudo-tooltip overlay, ;; which may start at the same position if it's at eol. (when ptf-workaround (cl-decf beg) (setq completion (concat (buffer-substring beg pos) completion))) - (setq company-preview-overlay (make-overlay beg pos)) + (when (string-suffix-p suffix completion) + (cl-incf end (length suffix))) + + (setq company-preview-overlay (make-overlay beg end)) (let ((ov company-preview-overlay)) - (overlay-put ov (if ptf-workaround 'display 'after-string) + (overlay-put ov (if (> end beg) 'display 'after-string) completion) (overlay-put ov 'window (selected-window)))))) @@ -3801,14 +4527,7 @@ Delay is determined by `company-tooltip-idle-delay'." (`pre-command (company-preview-hide)) (`unhide (when company-selection - (let* ((current (nth company-selection company-candidates)) - (company-prefix (if (equal current company-prefix) - ;; Would be more accurate to compare lengths, - ;; but this is shorter. - current - (buffer-substring - (- company-point (length company-prefix)) - (point))))) + (let* ((current (nth company-selection company-candidates))) (company-preview-show-at-point (point) current)))) (`post-command (when company-selection @@ -3823,13 +4542,19 @@ Delay is determined by `company-tooltip-idle-delay'." (company-preview-frontend command))) (defun company--show-inline-p () - (and (not (cdr company-candidates)) - company-common - (not (eq t (compare-strings company-prefix nil nil - (car company-candidates) nil nil - t))) - (or (eq (company-call-backend 'ignore-case) 'keep-prefix) - (string-prefix-p company-prefix company-common)))) + (let* ((boundaries (and company-candidates (company--boundaries))) + (prefix (car boundaries)) + (suffix (cdr boundaries)) + (ignore-case (company-call-backend 'ignore-case)) + (candidate (car company-candidates))) + (and (not (cdr company-candidates)) + company-common + (not (eq t (compare-strings prefix nil nil + candidate nil nil + t))) + (string-suffix-p suffix candidate ignore-case) + (or (eq ignore-case 'keep-prefix) + (string-prefix-p prefix company-common))))) (defun company-tooltip-visible-p () "Returns whether the tooltip is visible." @@ -3907,13 +4632,13 @@ Delay is determined by `company-tooltip-idle-delay'." 'company-echo) len (+ len 1 (length comp))) (let ((beg 0) - (end (string-width (or company-common "")))) + (end (company--string-width (or company-common "")))) (when (< numbered qa-keys-len) (let ((qa-hint (format "%s: " (funcall company-quick-access-hint-function numbered)))) - (setq beg (string-width qa-hint) + (setq beg (company--string-width qa-hint) end (+ beg end)) (cl-incf len beg) (setq comp (propertize (concat qa-hint comp) 'face 'company-echo))) @@ -3937,14 +4662,14 @@ Delay is determined by `company-tooltip-idle-delay'." comp msg) (while candidates - (setq comp (company-strip-prefix (pop candidates)) + (setq comp (company-strip-prefix (pop candidates) company-prefix) len (+ len 2 (length comp))) (when (< numbered qa-keys-len) (let ((qa-hint (format " (%s)" (funcall company-quick-access-hint-function numbered)))) (setq comp (concat comp qa-hint)) - (cl-incf len (string-width qa-hint))) + (cl-incf len (company--string-width qa-hint))) (cl-incf numbered)) (if (>= len limit) (setq candidates nil) @@ -3955,7 +4680,7 @@ Delay is determined by `company-tooltip-idle-delay'." "}")))) (defun company-echo-hide () - (unless (equal company-echo-last-msg "") + (unless (string-empty-p company-echo-last-msg) (setq company-echo-last-msg "") (company-echo-show))) diff --git a/elpa/company-20230703.2021/company.info b/elpa/company-20241210.2019/company.info similarity index 83% rename from elpa/company-20230703.2021/company.info rename to elpa/company-20241210.2019/company.info index b64a87ca..1cae4936 100644 --- a/elpa/company-20230703.2021/company.info +++ b/elpa/company-20241210.2019/company.info @@ -1,9 +1,10 @@ -This is company.info, produced by makeinfo version 6.7 from +This is company.info, produced by makeinfo version 6.8 from company.texi. -This user manual is for Company version 0.9.14snapshot (16 April 2023). +This user manual is for Company version 1.0.3-snapshot +(7 December 2024). -Copyright © 2021-2023 Free Software Foundation, Inc. +Copyright © 2021-2024 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -26,9 +27,10 @@ The goal of this document is to lay out the foundational knowledge of the package, so that the readers of the manual could competently start adapting Company to their needs and preferences. -This user manual is for Company version 0.9.14snapshot (16 April 2023). +This user manual is for Company version 1.0.3-snapshot +(7 December 2024). -Copyright © 2021-2023 Free Software Foundation, Inc. +Copyright © 2021-2024 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -104,7 +106,7 @@ File: company.info, Node: Terminology, Next: Structure, Up: Overview 1.1 Terminology =============== -“Completion” is an act of intelligibly guessing possible variants of +“Completion” is an act of intelligently guessing possible variants of words based on already typed characters. To “complete” a word means to insert a correctly guessed variant into the buffer. @@ -112,20 +114,19 @@ Consequently, the “candidates” are the aforementioned guessed variants of words. Each of the candidates has the potential to be chosen for successful completion. And each of the candidates contains the initially typed characters: either only at the beginning (so-called -“prefix matches”), or also inside (“non-prefix matches”) of a candidate -(1). - -The package’s name “Company” is based on the combination of the two +“prefix matches”), or also inside of a candidate (“non-prefix matches”). +Which matching method is used, depends on the current _backend_ (*note +Structure::). ‘company-capf’ is an example of a backend that supports a +number of particular non-prefix matching algorithms which are +configurable through the user option ‘completion-styles’, which see. +For illustrations on how Company visualizes the matches, *note +Frontends::. + +The package’s name ‘Company’ is based on the combination of the two words: ‘Complete’ and ‘Anything’. These words reflect the package’s commitment to handling completion candidates and its extensible nature allowing it to cover a wide range of usage scenarios. - ---------- Footnotes ---------- - - (1) A good starting point to learn about types of matches is to play -with the Emacs’s user option ‘completion-styles’. For illustrations on -how Company visualizes the matches, *note Frontends::. -  File: company.info, Node: Structure, Prev: Terminology, Up: Overview @@ -137,11 +138,11 @@ are pluggable modules: backends (*note Backends::) and frontends (*note Frontends::). The “backends” are responsible for retrieving completion candidates; -which are then outputted by the “frontends”. For an easy and quick +which are then displayed by the “frontends”. For an easy and quick initial setup, Company is supplied with the preconfigured sets of the backends and frontends. The default behavior of the modules can be -adjusted per particular needs, goals, and preferences. It is also -typical to utilize backends from a variety of third-party libraries +adjusted for particular needs, and preferences. It is also typical to +utilize backends from a variety of third-party libraries (https://github.com/company-mode/company-mode/wiki/Third-Party-Packages), developed to be pluggable with Company. @@ -149,7 +150,7 @@ But Company consists not only of the backends and frontends. A core of the package plays the role of a controller, connecting the modules, making them work together; and exposing configurations and -commands for a user to operate with. For more details, *note +commands for the user to operate with. For more details, *note Customization:: and *note Commands::. Also, Company is bundled with an alternative workflow configuration @@ -202,7 +203,7 @@ indicator ‘company’. After _company-mode_ had been enabled, the package auto-starts suggesting completion candidates. The candidates are retrieved and -shown according to the typed characters and the default (until a user +shown according to the typed characters and the default (until the user specifies otherwise) configurations. To have Company always enabled for the following sessions, add the line @@ -216,7 +217,7 @@ File: company.info, Node: Usage Basics, Next: Commands, Prev: Initial Setup, ================ By default — having _company-mode_ enabled (*note Initial Setup::) — a -tooltip with completion candidates is shown when a user types in a few +tooltip with completion candidates is shown when the user types a few characters. To initiate completion manually, use the command ‘M-x company-complete’. @@ -226,8 +227,11 @@ respectively key bindings ‘C-n’ and ‘C-p’, then do one of the following: • Hit to choose a selected candidate for completion. - • Hit to complete with the “common part”: characters present at - the beginning of all the candidates. + • Hit to expand the “common part” of all completions. Exactly + what that means, can vary by backend. In the simplest case it’s + the longest string that all completion start with, but when a + backend returns _non-prefix matches_, it can implement the same + kind of expansion logic for the input string. • Hit ‘C-g’ to stop activity of Company. @@ -253,11 +257,15 @@ commands of the out-of-the-box Company. ‘RET’ ‘’ Insert the selected candidate (‘company-complete-selection’). + Restart completion if a new field is entered. ‘TAB’ ‘’ - Insert the common part of all the candidates - (‘company-complete-common’). + Insert the _common part_ of all completion candidates or — if no + _common part_ is present — select the next candidate + (‘company-complete-common-or-cycle’). In the latter case, + wraparound is implicitly enabled (*note + company-selection-wrap-around::). ‘C-g’ ‘’ @@ -285,17 +293,8 @@ illustrate how to assign key bindings to such commands. (global-set-key (kbd "") #'company-indent-or-complete-common) (with-eval-after-load 'company - (define-key company-active-map (kbd "M-/") #'company-complete)) - - (with-eval-after-load 'company - (define-key company-active-map - (kbd "TAB") - #'company-complete-common-or-cycle) - (define-key company-active-map - (kbd "") - (lambda () - (interactive) - (company-complete-common-or-cycle -1)))) + (define-key company-active-map (kbd "M-/") #'company-complete) + (define-key company-active-map (kbd "C-M-/") #'company-complete-common)) In the same manner, an additional key can be assigned to a command or a command can be unbound from a key. For instance: @@ -350,7 +349,7 @@ File: company.info, Node: Configuration File, Prev: Customization Interface, ====================== Company is a customization-rich package. This section lists some of the -core settings that influence the overall behavior of the _company-mode_. +core settings that influence its overall behavior. -- User Option: company-minimum-prefix-length This is one of the values (together with ‘company-idle-delay’), @@ -374,6 +373,10 @@ core settings that influence the overall behavior of the _company-mode_. (setq company-idle-delay (lambda () (if (company-in-string-or-comment) nil 0.3))) + -- User Option: company-inhibit-inside-symbols + You can set this option to ‘t’ to disable the auto-start behavior + when in the middle of a symbol. + -- User Option: company-global-modes This option allows to specify in which major modes _company-mode_ can be enabled by ‘(global-company-mode)’. *Note Initial Setup::. @@ -398,8 +401,8 @@ core settings that influence the overall behavior of the _company-mode_. To allow typing in characters that don’t match the candidates, set the value of this option to ‘nil’. For an opposite behavior (that is, to disallow non-matching input), set it to ‘t’. By default, - Company is configured to require a matching input only if a user - manually enables completion or selects a candidate; by having the + Company is configured to require a matching input only if the user + invokes completion manually or selects a candidate; by having the option configured to call the function ‘company-explicit-action-p’. -- User Option: company-lighter-base @@ -575,12 +578,11 @@ user options. [image src="./images/small/tooltip-minimum-above.png"] -- User Option: company-tooltip-flip-when-above - This is one of the fancy features Company has to suggest. When - this setting is enabled, no matter if a tooltip is shown above or - below point, the candidates are always listed starting near point. - (Putting it differently, the candidates are mirrored horizontally - if a tooltip changes its position, instead of being commonly listed - top-to-bottom.) + When this setting is enabled, no matter if a tooltip is shown above + or below point, the candidates are always listed starting near + point. (Putting it differently, the candidates are mirrored + vertically if a tooltip changes its position, instead of being + commonly listed top-to-bottom.) (setq company-tooltip-flip-when-above t) @@ -588,7 +590,7 @@ user options. -- User Option: company-tooltip-minimum-width Sets the minimum width of a tooltip, excluding the margins and the - scroll bar. Changing this value especially makes sense if a user + scroll bar. Changing this value especially makes sense if the user navigates between tooltip pages. Keeping this value at the default ‘0’ allows Company to always adapt the width of the tooltip to the longest shown candidate. Enlarging ‘company-tooltip-minimum-width’ @@ -630,7 +632,7 @@ the variable ‘company-vscode-icons-mapping’.) -- User Option: company-format-margin-function Allows setting a function to format the left margin of a tooltip inner area; namely, to output candidate’s _icons_. The predefined - formatting functions are listed below. A user may also set this + formatting functions are listed below. The user may also set this option to a custom function. To disable left margin formatting, set the value of the option to ‘nil’ (this way control over the size of the left margin returns to the user option @@ -694,14 +696,14 @@ Faces Out-of-the-box Company defines and configures distinguished faces (*note (emacs)Faces::) for light and dark themes. Moreover, some of the built-in and third-party themes fine-tune Company to fit their palettes. -That is why there’s often no real need to make such adjustments on a -user side. However, this chapter presents some hints on where to start -customizing Company interface. +That is why there’s often no real need to make such adjustments on the +user’s side. However, this chapter presents some hints on where to +start customizing Company interface. Namely, the look of a tooltip is controlled by the ‘company-tooltip*’ named faces. -The following example hints how a user may approach tooltip faces +The following example suggests how users may approach tooltip faces customization: (custom-set-faces @@ -730,7 +732,7 @@ File: company.info, Node: Preview Frontends, Next: Echo Frontends, Prev: Tool ===================== Frontends in this group output a completion candidate or a common part -of the candidates temporarily inline, as if a word had already been +of the candidates temporarily inline, as if the word had already been completed (1). -- Function: company-preview-if-just-one-frontend @@ -910,19 +912,18 @@ File: company.info, Node: Backends, Next: Troubleshooting, Prev: Frontends, ********** We can metaphorically say that each backend is like an engine. (The -reality is even better since backends are just functions.) Fueling such +reality is even better since backends are just functions.) Firing such an engine with a command causes the production of material for Company -to move further on. Typically, moving on means outputting that material -to a user via one or several configured frontends, *note Frontends::. +to work on. Typically, that means showing that output to the user via +one or several configured frontends, *note Frontends::. Just like Company provides a preconfigured list of the enabled frontends, it also defines a list of the backends to rely on by default. This list is stored in the user option ‘company-backends’. The -docstring of this variable has been a source of valuable information for -years. That’s why we’re going to stick to a tradition and suggest -reading the output of ‘C-h v company-backends’ for insightful details -about backends. Nevertheless, the fundamental concepts are described in -this user manual too. +docstring of this variable has the full description of what a backend is +and how to implement one. So we suggest reading the output of ‘C-h v +company-backends’ for more details. Nevertheless, the fundamental +concepts are described in this user manual too. * Menu: @@ -940,16 +941,18 @@ File: company.info, Node: Backends Usage Basics, Next: Grouped Backends, Up: One of the significant concepts to understand about Company is that the package relies on one backend at a time (1). The backends are invoked one by one, in the sequential order of the items on the -‘company-backends’ list. +‘company-backends’ list. The first one that reports itself applicable +in the current context (usually based on the value of ‘major-mode’ and +the text around point), is used for completion. The name of the currently active backend is shown in the mode line and in the output of the command ‘M-x company-diag’. -In most cases (mainly to exclude false-positive results), the next -backend is not invoked automatically. For the purpose of invoking the -next backend, use the command ‘company-other-backend’: either by calling -it with ‘M-x’ or by binding the command to the keys of your choice, such -as: +In most cases (mainly to exclude false-positive results), if the current +applicable backend returned no completions, the ones after it in the +list are not invoked. If you do want to query the next one, use the +command ‘company-other-backend’: either by calling it with ‘M-x’ or by +binding the command to the keys of your choice, like: (global-set-key (kbd "C-c C-/") #'company-other-backend) @@ -977,9 +980,7 @@ backends”: a sub-list of backends in the ‘company-backends’ list, that is handled specifically by Company. The most important part of this handling is the merge of the completion -candidates from the grouped backends. (But only from the backends that -return the same _prefix_ value, see ‘C-h v company-backends’ for more -details.) +candidates from the grouped backends. To keep the candidates organized in accordance with the grouped backends order, add the keyword ‘:separate’ to the list of the grouped backends. @@ -1040,13 +1041,14 @@ File: company.info, Node: Code Completion, Next: Text Completion, Up: Package --------------------- -- Function: company-capf - In the Emacs’s world, the current tendency is to have the - completion logic provided by ‘completion-at-point-functions’ (CAPF) - implementations. [Among the other things, this is what the popular - packages that support language server protocol (LSP) also rely on.] - - Since _company-capf_ works as a bridge to the standard CAPF - facility, it is probably the most often used and recommended + The current trend in the Emacs’s world is to delegate completion + logic to the hook ‘completion-at-point-functions’ (CAPF) assigned + to by the major or minor modes. It supports a common subset of + features which is well-supported across different completion UIs. + [Among other things, this is what the most popular Emacs clients + for the language server protocol (LSP) also rely on.] + + For that reason, it is probably the most used and recommended backend nowadays, including for Emacs Lisp coding. Just to illustrate, the following minimal backends setup @@ -1058,11 +1060,46 @@ File: company.info, Node: Code Completion, Next: Text Completion, Up: Package For more details on CAPF, *note (elisp)Completion in Buffers::. + -- User Option: company-capf-disabled-functions + List of completion functions which should be ignored by this + backend. By default it contains the functions that duplicate the + built-in backends but don’t support the corresponding configuration + options and/or alter the intended priority of the default backends’ + configuration. + -- Function: company-dabbrev-code This backend works similarly to the built-in Emacs package _dabbrev_, searching for completion candidates inside the contents - of the open buffer(s). Internally, its based on the backend - _company-dabbrev_ (*note Text Completion::). + of the open buffer(s). Internally, it reuses code from the other + backend, ‘company-dabbrev’ (*note Text Completion::). + + -- User Option: company-dabbrev-code-modes + This variable lists the modes that use ‘company-dabbrev-code’. The + backend will only perform completion in these major modes and their + derivatives. Otherwise it passes control to other backends. Value + t means complete in all modes. + + -- User Option: company-dabbrev-code-other-buffers + This variable determined whether ‘company-dabbrev-code’ will search + other buffers for completions. If ‘all’, it will search all other + buffers except the ignored ones (names starting with a space). If + ‘t’, it will search buffers with the same major mode. If ‘code’, + it will search buffers with major modes in + ‘company-dabbrev-code-modes’ or derived from one of them. This can + also be a function that takes the current buffer as parameter and + returns a list of major modes to search. + + -- User Option: company-dabbrev-code-everywhere + This is a boolean option which determines whether this backend will + perform completion in strings and comments as well. The default + value ‘nil’ means it will pass on control to other backends in such + contexts. + + -- User Option: company-dabbrev-code-completion-styles + Non-nil to use ‘completion-styles’ for matching completions in this + backend. It can be set to ‘t’ to use the global value of + ‘completion-styles’, or to a list of symbols to use specific + completion styles with this backend. The default value is nil. -- Function: company-keywords This backend provides completions for many of the widely spread @@ -1072,21 +1109,45 @@ File: company.info, Node: Code Completion, Next: Text Completion, Up: Package -- Function: company-clang As the name suggests, use this backend to get completions from _Clang_ compiler; that is, for the languages in the _C_ language - family: _C_, _C++_, _Objective-C_. + family: _C_, _C++_, _Objective-C_. It uses the command-line + interface of the program ‘clang’, but without any advanced caching + across calls, or automatic detection of the project structure. + Which makes it more suitable for small to medium projects, + especially if you’re willing to customize + ‘company-clang-arguments’. Otherwise we recommend using one of the + LSP clients available for Emacs, together with the backend + ‘company-capf’. + + -- User Option: company-clang-arguments + This option can be set to a list of strings which will be passed to + _clang_ during completion. These can include elements like ‘"-I" + "path/to/includes/dir"’ to indicate the header directories and + other compiler options. -- Function: company-semantic This backend relies on a built-in Emacs package that provides language-aware editing commands based on source code parsers, *note (emacs)Semantic::. Having enabled _semantic-mode_ makes it to be used by the CAPF mechanism (*note (emacs)Symbol Completion::), - hence a user may consider enabling _company-capf_ backend instead. + hence the user may consider enabling _company-capf_ backend + instead. -- Function: company-etags - This backend works on top of a built-in Emacs package _etags_, - *note (emacs)Tags Tables::. Similarly to aforementioned _Semantic_ - usage, tags-based completions now are a part of the Emacs’ CAPF - facility, therefore a user may consider switching to _company-capf_ - backend. + This backend uses tags tables as produced by the built-in Emacs + program _etags_, *note (emacs)Tags Tables::. + + -- User Option: company-etags-ignore-case + Non-nil to ignore case in this backend’s completions. + + -- User Option: company-etags-everywhere + Non-nil to offer completions in comments and strings. It can also + be set to ‘t’ or a list of major modes in which this would happen. + + -- User Option: company-etags-completion-styles + Non-nil to use ‘completion-styles’ for matching completions in this + backend. It can be set to ‘t’ to use the global value of + ‘completion-styles’, or to a list of symbols to use specific + completion styles with this backend. The default value is nil.  File: company.info, Node: Text Completion, Next: File Name Completion, Prev: Code Completion, Up: Package Backends @@ -1235,16 +1296,42 @@ File: company.info, Node: Candidates Post-Processing, Prev: Package Backends, 5.4 Candidates Post-Processing ============================== -A list of completion candidates, supplied by a backend, can be -additionally manipulated (reorganized, reduced, sorted, etc) before its -output. This is done by adding a processing function name to the user -option ‘company-transformers’ list, for example: +A list of completion candidates supplied by backends can be manipulated +before output: reorganized, reduced, sorted, etc. To apply adjustments, +add a processing function name to the user option ‘company-transformers’ +list. + +The transformer functions are called in a sequence, each with the return +value of the previous one. The first function receives a sorted list of +distinct completion candidates. Note that the default sorting behavior +may be overridden by backends and influenced by the use of the keyword +‘:separate’ in the grouped backends list (*note Grouped Backends::). + +Since Company does not treat candidates with differing annotations as +duplicates, it may sometimes be desirable to condense completion lists +containing such entries. In the example below, post-processing begins +with their removal. Then, the weighted ordering of the candidates is +performed. + ;; Set grouped backends. + (setq company-backends '((company-capf company-dabbrev-code))) + + ;; Apply post-processing. (setq company-transformers '(delete-consecutive-dups company-sort-by-occurrence)) -Company is bundled with several such transformer functions. They are -listed below. +If a grouped backend contains the keyword ‘:separate’, you can use the +‘delete-dups’ function instead. + + ;; Set grouped backends. + (setq company-backends + '((:separate company-capf company-dabbrev-code))) + + ;; Apply post-processing. + (setq company-transformers '(delete-dups + company-sort-by-occurrence)) + +Company is bundled with several transformer functions. -- Function: company-sort-by-occurrence Sorts candidates using ‘company-occurrence-weight-function’ @@ -1329,11 +1416,11 @@ Key Index [index] * Menu: -* C-g: Usage Basics. (line 20) -* C-g <1>: Commands. (line 30) +* C-g: Usage Basics. (line 23) +* C-g <1>: Commands. (line 34) * C-g <2>: Candidates Search. (line 11) * C-g <3>: Filter Candidates. (line 14) -* C-h: Commands. (line 34) +* C-h: Commands. (line 38) * C-M-s: Filter Candidates. (line 6) * C-n: Usage Basics. (line 12) * C-n <1>: Commands. (line 11) @@ -1341,13 +1428,13 @@ Key Index * C-p: Usage Basics. (line 12) * C-p <1>: Commands. (line 16) * C-s: Candidates Search. (line 6) -* C-w: Commands. (line 42) +* C-w: Commands. (line 45) * M-: Quick Access a Candidate. (line 6) * RET: Usage Basics. (line 15) * RET <1>: Commands. (line 21) * TAB: Usage Basics. (line 17) -* TAB <1>: Commands. (line 25) +* TAB <1>: Commands. (line 26)  File: company.info, Node: Variable Index, Next: Function Index, Prev: Key Index, Up: Index @@ -1358,59 +1445,69 @@ Variable Index [index] * Menu: -* company-after-completion-hook: Configuration File. (line 94) +* company-after-completion-hook: Configuration File. (line 98) * company-backends: Backends. (line 12) * company-backends <1>: Backends Usage Basics. (line 6) * company-backends <2>: Grouped Backends. (line 6) -* company-completion-cancelled-hook: Configuration File. (line 90) -* company-completion-finished-hook: Configuration File. (line 92) -* company-completion-started-hook: Configuration File. (line 88) +* company-capf-disabled-functions: Code Completion. (line 26) +* company-clang-arguments: Code Completion. (line 84) +* company-completion-cancelled-hook: Configuration File. (line 94) +* company-completion-finished-hook: Configuration File. (line 96) +* company-completion-started-hook: Configuration File. (line 92) +* company-dabbrev-code-completion-styles: Code Completion. (line 61) +* company-dabbrev-code-everywhere: Code Completion. (line 55) +* company-dabbrev-code-modes: Code Completion. (line 39) +* company-dabbrev-code-other-buffers: Code Completion. (line 45) * company-dabbrev-downcase: Text Completion. (line 64) * company-dabbrev-ignore-buffers: Text Completion. (line 32) * company-dabbrev-ignore-case: Text Completion. (line 47) * company-dabbrev-minimum-length: Text Completion. (line 13) * company-dabbrev-other-buffers: Text Completion. (line 23) -* company-dot-icons-format: Tooltip Frontends. (line 187) +* company-dot-icons-format: Tooltip Frontends. (line 183) * company-echo-truncate-lines: Echo Frontends. (line 33) +* company-etags-completion-styles: Code Completion. (line 109) +* company-etags-everywhere: Code Completion. (line 105) +* company-etags-ignore-case: Code Completion. (line 102) * company-files-chop-trailing-slash: File Name Completion. (line 19) * company-files-exclusions: File Name Completion. (line 12) -* company-format-margin-function: Tooltip Frontends. (line 161) +* company-format-margin-function: Tooltip Frontends. (line 158) * company-frontends: Frontends. (line 6) -* company-global-modes: Configuration File. (line 31) -* company-icon-margin: Tooltip Frontends. (line 172) -* company-icon-size: Tooltip Frontends. (line 172) +* company-global-modes: Configuration File. (line 35) +* company-icon-margin: Tooltip Frontends. (line 169) +* company-icon-size: Tooltip Frontends. (line 169) * company-idle-delay: Configuration File. (line 17) -* company-insertion-on-trigger: Configuration File. (line 64) -* company-insertion-triggers: Configuration File. (line 72) +* company-inhibit-inside-symbols: Configuration File. (line 31) +* company-insertion-on-trigger: Configuration File. (line 68) +* company-insertion-triggers: Configuration File. (line 76) * company-ispell-dictionary: Text Completion. (line 84) -* company-lighter-base: Configuration File. (line 59) +* company-lighter-base: Configuration File. (line 63) * company-minimum-prefix-length: Configuration File. (line 9) * company-mode: Initial Setup. (line 6) * company-occurrence-weight-function: Candidates Post-Processing. - (line 21) -* company-require-match: Configuration File. (line 51) + (line 47) +* company-require-match: Configuration File. (line 55) * company-search-regexp-function: Candidates Search. (line 13) -* company-selection-wrap-around: Configuration File. (line 43) +* company-selection-wrap-around: Configuration File. (line 47) * company-show-quick-access: Quick Access a Candidate. - (line 14) -* company-text-face-extra-attributes: Tooltip Frontends. (line 200) -* company-text-icons-add-background: Tooltip Frontends. (line 208) -* company-text-icons-format: Tooltip Frontends. (line 179) -* company-text-icons-mapping: Tooltip Frontends. (line 196) -* company-tooltip-align-annotations: Tooltip Frontends. (line 52) -* company-tooltip-annotation-padding: Tooltip Frontends. (line 64) -* company-tooltip-flip-when-above: Tooltip Frontends. (line 107) -* company-tooltip-idle-delay: Tooltip Frontends. (line 22) -* company-tooltip-limit: Tooltip Frontends. (line 72) -* company-tooltip-margin: Tooltip Frontends. (line 141) -* company-tooltip-maximum-width: Tooltip Frontends. (line 134) -* company-tooltip-minimum: Tooltip Frontends. (line 92) -* company-tooltip-minimum-width: Tooltip Frontends. (line 119) -* company-tooltip-offset-display: Tooltip Frontends. (line 82) -* company-tooltip-width-grow-only: Tooltip Frontends. (line 129) + (line 12) +* company-text-face-extra-attributes: Tooltip Frontends. (line 196) +* company-text-icons-add-background: Tooltip Frontends. (line 204) +* company-text-icons-format: Tooltip Frontends. (line 176) +* company-text-icons-mapping: Tooltip Frontends. (line 192) +* company-tooltip-align-annotations: Tooltip Frontends. (line 51) +* company-tooltip-annotation-padding: Tooltip Frontends. (line 63) +* company-tooltip-flip-when-above: Tooltip Frontends. (line 106) +* company-tooltip-idle-delay: Tooltip Frontends. (line 21) +* company-tooltip-limit: Tooltip Frontends. (line 71) +* company-tooltip-margin: Tooltip Frontends. (line 139) +* company-tooltip-maximum-width: Tooltip Frontends. (line 132) +* company-tooltip-minimum: Tooltip Frontends. (line 91) +* company-tooltip-minimum-width: Tooltip Frontends. (line 117) +* company-tooltip-offset-display: Tooltip Frontends. (line 81) +* company-tooltip-width-grow-only: Tooltip Frontends. (line 127) * company-transformers: Candidates Post-Processing. (line 6) @@ -1424,40 +1521,43 @@ Function Index * Menu: * company-abbrev: Template Expansion. (line 6) -* company-abort: Commands. (line 30) +* company-abort: Commands. (line 34) * company-begin-backend: Backends Usage Basics. - (line 23) + (line 24) * company-capf: Code Completion. (line 6) -* company-clang: Code Completion. (line 36) +* company-clang: Code Completion. (line 72) * company-complete: Usage Basics. (line 10) -* company-complete-common: Commands. (line 25) +* company-complete <1>: Commands. (line 51) +* company-complete-common: Commands. (line 51) +* company-complete-common-or-cycle: Commands. (line 26) * company-complete-selection: Commands. (line 21) * company-dabbrev: Text Completion. (line 6) -* company-dabbrev-code: Code Completion. (line 25) -* company-detect-icons-margin: Tooltip Frontends. (line 217) +* company-dabbrev-code: Code Completion. (line 33) +* company-detect-icons-margin: Tooltip Frontends. (line 213) * company-diag: Backends Usage Basics. - (line 11) + (line 13) * company-diag <1>: Troubleshooting. (line 6) -* company-dot-icons-margin: Tooltip Frontends. (line 186) +* company-dot-icons-margin: Tooltip Frontends. (line 182) * company-echo-frontend: Echo Frontends. (line 21) * company-echo-metadata-frontend: Echo Frontends. (line 9) * company-echo-strip-common-frontend: Echo Frontends. (line 27) -* company-etags: Code Completion. (line 48) +* company-etags: Code Completion. (line 98) * company-files: File Name Completion. (line 6) +* company-indent-or-complete-common: Commands. (line 51) * company-ispell: Text Completion. (line 75) -* company-keywords: Code Completion. (line 31) +* company-keywords: Code Completion. (line 67) * company-mode: Initial Setup. (line 6) * company-other-backend: Backends Usage Basics. - (line 14) + (line 16) * company-preview-common-frontend: Preview Frontends. (line 21) * company-preview-frontend: Preview Frontends. (line 17) * company-preview-if-just-one-frontend: Preview Frontends. (line 10) -* company-pseudo-tooltip-frontend: Tooltip Frontends. (line 17) +* company-pseudo-tooltip-frontend: Tooltip Frontends. (line 16) * company-pseudo-tooltip-unless-just-one-frontend: Tooltip Frontends. - (line 11) + (line 10) * company-pseudo-tooltip-unless-just-one-frontend-with-delay: Tooltip Frontends. - (line 21) + (line 20) * company-search-flex-regexp: Candidates Search. (line 26) * company-search-words-in-any-order-regexp: Candidates Search. (line 23) @@ -1466,21 +1566,21 @@ Function Index * company-select-next-or-abort: Commands. (line 11) * company-select-previous: Commands. (line 16) * company-select-previous-or-abort: Commands. (line 16) -* company-semantic: Code Completion. (line 41) -* company-show-doc-buffer: Commands. (line 34) -* company-show-location: Commands. (line 42) +* company-semantic: Code Completion. (line 90) +* company-show-doc-buffer: Commands. (line 38) +* company-show-location: Commands. (line 45) * company-sort-by-backend-importance: Candidates Post-Processing. - (line 28) + (line 53) * company-sort-by-occurrence: Candidates Post-Processing. - (line 17) + (line 43) * company-sort-prefer-same-case-prefix: Candidates Post-Processing. - (line 34) + (line 59) * company-tempo: Template Expansion. (line 11) -* company-text-icons-margin: Tooltip Frontends. (line 178) +* company-text-icons-margin: Tooltip Frontends. (line 175) * company-tng-frontend: Structure. (line 26) * company-tng-mode: Structure. (line 26) -* company-vscode-dark-icons-margin: Tooltip Frontends. (line 170) -* company-vscode-light-icons-margin: Tooltip Frontends. (line 171) +* company-vscode-dark-icons-margin: Tooltip Frontends. (line 167) +* company-vscode-light-icons-margin: Tooltip Frontends. (line 168) * company-yasnippet: Template Expansion. (line 16) * global-company-mode: Initial Setup. (line 18) @@ -1493,47 +1593,57 @@ Concept Index [index] * Menu: +* :separate: Grouped Backends. (line 14) +* :separate <1>: Candidates Post-Processing. + (line 11) +* :separate <2>: Candidates Post-Processing. + (line 30) +* :with: Grouped Backends. (line 25) * abbrev: Template Expansion. (line 6) -* abort: Usage Basics. (line 20) -* abort <1>: Commands. (line 30) +* abort: Usage Basics. (line 23) +* abort <1>: Commands. (line 34) * activate: Initial Setup. (line 8) * active backend: Backends Usage Basics. - (line 11) -* active backend <1>: Troubleshooting. (line 15) -* annotation: Tooltip Frontends. (line 53) + (line 13) +* active backend <1>: Troubleshooting. (line 14) +* annotation: Tooltip Frontends. (line 52) +* annotation <1>: Candidates Post-Processing. + (line 17) * auto-start: Initial Setup. (line 13) * backend: Structure. (line 6) * backend <1>: Structure. (line 10) * backend <2>: Backends Usage Basics. - (line 11) + (line 13) * backend <3>: Backends Usage Basics. - (line 14) -* backend <4>: Troubleshooting. (line 15) + (line 16) +* backend <4>: Troubleshooting. (line 14) * backends: Backends. (line 6) * backends <1>: Backends Usage Basics. (line 6) * backends <2>: Grouped Backends. (line 6) * backends <3>: Package Backends. (line 6) +* backends <4>: Candidates Post-Processing. + (line 11) * basics: Usage Basics. (line 6) * bug: Troubleshooting. (line 6) -* bug <1>: Troubleshooting. (line 27) +* bug <1>: Troubleshooting. (line 25) * bundled backends: Package Backends. (line 6) -* cancel: Usage Basics. (line 20) -* cancel <1>: Commands. (line 30) +* cancel: Usage Basics. (line 23) +* cancel <1>: Commands. (line 34) * candidate: Terminology. (line 10) * candidate <1>: Usage Basics. (line 12) * candidate <2>: Usage Basics. (line 15) * candidate <3>: Preview Frontends. (line 6) -* color: Tooltip Frontends. (line 227) +* color: Tooltip Frontends. (line 222) * color <1>: Quick Access a Candidate. - (line 37) + (line 34) * common part: Usage Basics. (line 17) -* common part <1>: Commands. (line 25) +* common part <1>: Commands. (line 26) * common part <2>: Preview Frontends. (line 6) * company-echo: Echo Frontends. (line 6) * company-preview: Preview Frontends. (line 6) * company-tng: Structure. (line 26) -* company-tooltip: Tooltip Frontends. (line 227) +* company-tooltip: Tooltip Frontends. (line 222) * company-tooltip-search: Candidates Search. (line 6) * complete: Terminology. (line 6) * complete <1>: Usage Basics. (line 12) @@ -1549,40 +1659,42 @@ Concept Index * configure <1>: Customization Interface. (line 6) * configure <2>: Configuration File. (line 6) -* configure <3>: Tooltip Frontends. (line 49) -* configure <4>: Tooltip Frontends. (line 227) +* configure <3>: Tooltip Frontends. (line 48) +* configure <4>: Tooltip Frontends. (line 222) * configure <5>: Preview Frontends. (line 25) * configure <6>: Echo Frontends. (line 38) * configure <7>: Candidates Search. (line 30) * configure <8>: Quick Access a Candidate. - (line 28) + (line 25) * configure <9>: Quick Access a Candidate. - (line 37) + (line 34) * custom: Customization. (line 6) * custom <1>: Customization Interface. (line 6) * custom <2>: Configuration File. (line 6) -* custom <3>: Tooltip Frontends. (line 49) -* custom <4>: Tooltip Frontends. (line 227) +* custom <3>: Tooltip Frontends. (line 48) +* custom <4>: Tooltip Frontends. (line 222) * custom <5>: Preview Frontends. (line 25) * custom <6>: Echo Frontends. (line 38) * custom <7>: Candidates Search. (line 30) * custom <8>: Quick Access a Candidate. - (line 28) + (line 25) * custom <9>: Quick Access a Candidate. - (line 37) -* definition: Commands. (line 42) + (line 34) +* definition: Commands. (line 45) * distribution: Installation. (line 6) -* doc: Commands. (line 34) -* duplicate: Candidates Post-Processing. - (line 6) +* doc: Commands. (line 38) +* duplicates: Candidates Post-Processing. + (line 17) +* duplicates <1>: Candidates Post-Processing. + (line 30) * echo: Echo Frontends. (line 6) * enable: Initial Setup. (line 8) * error: Troubleshooting. (line 6) -* error <1>: Troubleshooting. (line 27) +* error <1>: Troubleshooting. (line 25) * expansion: Template Expansion. (line 6) * extensible: Structure. (line 6) -* face: Tooltip Frontends. (line 227) +* face: Tooltip Frontends. (line 222) * face <1>: Preview Frontends. (line 6) * face <2>: Preview Frontends. (line 25) * face <3>: Echo Frontends. (line 6) @@ -1591,53 +1703,57 @@ Concept Index * face <6>: Candidates Search. (line 30) * face <7>: Filter Candidates. (line 6) * face <8>: Quick Access a Candidate. - (line 37) + (line 34) * filter: Filter Candidates. (line 6) -* finish: Usage Basics. (line 20) -* finish <1>: Commands. (line 30) -* font: Tooltip Frontends. (line 227) +* finish: Usage Basics. (line 23) +* finish <1>: Commands. (line 34) +* font: Tooltip Frontends. (line 222) * font <1>: Quick Access a Candidate. - (line 37) + (line 34) * frontend: Structure. (line 6) * frontend <1>: Structure. (line 10) * frontends: Frontends. (line 6) * grouped backends: Grouped Backends. (line 6) -* icon: Tooltip Frontends. (line 153) +* grouped backends <1>: Candidates Post-Processing. + (line 11) +* icon: Tooltip Frontends. (line 151) * install: Installation. (line 6) -* interface: Tooltip Frontends. (line 49) -* interface <1>: Tooltip Frontends. (line 227) +* interface: Tooltip Frontends. (line 48) +* interface <1>: Tooltip Frontends. (line 222) * interface <2>: Preview Frontends. (line 25) * interface <3>: Echo Frontends. (line 38) * interface <4>: Candidates Search. (line 30) * interface <5>: Quick Access a Candidate. - (line 37) + (line 34) * intro: Initial Setup. (line 6) * issue: Troubleshooting. (line 6) -* issue tracker: Troubleshooting. (line 27) -* kind: Tooltip Frontends. (line 153) -* location: Commands. (line 42) +* issue tracker: Troubleshooting. (line 25) +* kind: Tooltip Frontends. (line 151) +* location: Commands. (line 45) * manual: Initial Setup. (line 8) * manual <1>: Usage Basics. (line 10) -* margin: Tooltip Frontends. (line 142) -* margin <1>: Tooltip Frontends. (line 162) +* margin: Tooltip Frontends. (line 140) +* margin <1>: Tooltip Frontends. (line 159) * minor-mode: Initial Setup. (line 6) * module: Structure. (line 6) * module <1>: Structure. (line 10) * navigate: Usage Basics. (line 12) * next backend: Backends Usage Basics. - (line 14) + (line 16) * non-prefix matches: Terminology. (line 10) * package: Installation. (line 6) * package backends: Package Backends. (line 6) * pluggable: Structure. (line 6) * pop-up: Tooltip Frontends. (line 6) +* post-processing: Candidates Post-Processing. + (line 6) * prefix matches: Terminology. (line 10) * preview: Preview Frontends. (line 6) * quick start: Initial Setup. (line 6) * quick-access: Quick Access a Candidate. (line 6) -* quit: Usage Basics. (line 20) -* quit <1>: Commands. (line 30) +* quit: Usage Basics. (line 23) +* quit <1>: Commands. (line 34) * search: Candidates Search. (line 6) * select: Usage Basics. (line 12) * select <1>: Commands. (line 11) @@ -1645,13 +1761,13 @@ Concept Index * snippet: Template Expansion. (line 6) * sort: Candidates Post-Processing. (line 6) -* stop: Usage Basics. (line 20) -* stop <1>: Commands. (line 30) +* stop: Usage Basics. (line 23) +* stop <1>: Commands. (line 34) * TAB: Structure. (line 26) * Tab and Go: Structure. (line 26) * template: Template Expansion. (line 6) * third-party: Structure. (line 10) -* third-party <1>: Troubleshooting. (line 18) +* third-party <1>: Troubleshooting. (line 17) * tooltip: Tooltip Frontends. (line 6) * troubleshoot: Troubleshooting. (line 6) * usage: Usage Basics. (line 6) @@ -1659,45 +1775,45 @@ Concept Index  Tag Table: -Node: Top571 -Node: Overview1998 -Node: Terminology2406 -Ref: Terminology-Footnote-13393 -Node: Structure3599 -Node: Getting Started5095 -Node: Installation5373 -Node: Initial Setup5756 -Node: Usage Basics6602 -Node: Commands7365 -Ref: Commands-Footnote-19800 -Node: Customization9967 -Node: Customization Interface10439 -Node: Configuration File10972 -Node: Frontends15638 -Node: Tooltip Frontends16607 -Ref: Tooltip Frontends-Footnote-127374 -Node: Preview Frontends27611 -Ref: Preview Frontends-Footnote-128867 -Node: Echo Frontends28994 -Node: Candidates Search30527 -Node: Filter Candidates31861 -Node: Quick Access a Candidate32641 -Node: Backends34259 -Node: Backends Usage Basics35357 -Ref: Backends Usage Basics-Footnote-136572 -Node: Grouped Backends36656 -Node: Package Backends38285 -Node: Code Completion39214 -Node: Text Completion41583 -Node: File Name Completion46017 -Node: Template Expansion47565 -Node: Candidates Post-Processing48284 -Node: Troubleshooting49761 -Node: Index51434 -Node: Key Index51597 -Node: Variable Index53096 -Node: Function Index57219 -Node: Concept Index61700 +Node: Top573 +Node: Overview2002 +Node: Terminology2410 +Node: Structure3717 +Node: Getting Started5208 +Node: Installation5486 +Node: Initial Setup5869 +Node: Usage Basics6717 +Node: Commands7695 +Ref: Commands-Footnote-110093 +Node: Customization10260 +Node: Customization Interface10732 +Node: Configuration File11265 +Ref: company-selection-wrap-around13579 +Node: Frontends16072 +Node: Tooltip Frontends17041 +Ref: Tooltip Frontends-Footnote-127755 +Node: Preview Frontends27992 +Ref: Preview Frontends-Footnote-129250 +Node: Echo Frontends29377 +Node: Candidates Search30910 +Node: Filter Candidates32244 +Node: Quick Access a Candidate33024 +Node: Backends34642 +Node: Backends Usage Basics35672 +Ref: Backends Usage Basics-Footnote-137104 +Node: Grouped Backends37188 +Node: Package Backends38699 +Node: Code Completion39628 +Node: Text Completion45155 +Node: File Name Completion49589 +Node: Template Expansion51137 +Node: Candidates Post-Processing51856 +Node: Troubleshooting54433 +Node: Index56106 +Node: Key Index56269 +Node: Variable Index57768 +Node: Function Index62621 +Node: Concept Index67321  End Tag Table diff --git a/elpa/company-20230703.2021/dir b/elpa/company-20241210.2019/dir similarity index 100% rename from elpa/company-20230703.2021/dir rename to elpa/company-20241210.2019/dir diff --git a/elpa/company-20230703.2021/images/small/echo-meta.png b/elpa/company-20241210.2019/images/small/echo-meta.png similarity index 100% rename from elpa/company-20230703.2021/images/small/echo-meta.png rename to elpa/company-20241210.2019/images/small/echo-meta.png diff --git a/elpa/company-20230703.2021/images/small/echo-qa.png b/elpa/company-20241210.2019/images/small/echo-qa.png similarity index 100% rename from elpa/company-20230703.2021/images/small/echo-qa.png rename to elpa/company-20241210.2019/images/small/echo-qa.png diff --git a/elpa/company-20230703.2021/images/small/echo-strip-qa.png b/elpa/company-20241210.2019/images/small/echo-strip-qa.png similarity index 100% rename from elpa/company-20230703.2021/images/small/echo-strip-qa.png rename to elpa/company-20241210.2019/images/small/echo-strip-qa.png diff --git a/elpa/company-20230703.2021/images/small/echo-strip.png b/elpa/company-20241210.2019/images/small/echo-strip.png similarity index 100% rename from elpa/company-20230703.2021/images/small/echo-strip.png rename to elpa/company-20241210.2019/images/small/echo-strip.png diff --git a/elpa/company-20230703.2021/images/small/echo.png b/elpa/company-20241210.2019/images/small/echo.png similarity index 100% rename from elpa/company-20230703.2021/images/small/echo.png rename to elpa/company-20241210.2019/images/small/echo.png diff --git a/elpa/company-20230703.2021/images/small/preview-dark.png b/elpa/company-20241210.2019/images/small/preview-dark.png similarity index 100% rename from elpa/company-20230703.2021/images/small/preview-dark.png rename to elpa/company-20241210.2019/images/small/preview-dark.png diff --git a/elpa/company-20230703.2021/images/small/preview-light.png b/elpa/company-20241210.2019/images/small/preview-light.png similarity index 100% rename from elpa/company-20230703.2021/images/small/preview-light.png rename to elpa/company-20241210.2019/images/small/preview-light.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-annotations.png b/elpa/company-20241210.2019/images/small/tooltip-annotations.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-annotations.png rename to elpa/company-20241210.2019/images/small/tooltip-annotations.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-faces-light.png b/elpa/company-20241210.2019/images/small/tooltip-faces-light.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-faces-light.png rename to elpa/company-20241210.2019/images/small/tooltip-faces-light.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-filter.png b/elpa/company-20241210.2019/images/small/tooltip-filter.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-filter.png rename to elpa/company-20241210.2019/images/small/tooltip-filter.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-flip.png b/elpa/company-20241210.2019/images/small/tooltip-flip.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-flip.png rename to elpa/company-20241210.2019/images/small/tooltip-flip.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-icon-bg.png b/elpa/company-20241210.2019/images/small/tooltip-icon-bg.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-icon-bg.png rename to elpa/company-20241210.2019/images/small/tooltip-icon-bg.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-icon-face.png b/elpa/company-20241210.2019/images/small/tooltip-icon-face.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-icon-face.png rename to elpa/company-20241210.2019/images/small/tooltip-icon-face.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-icons-dot.png b/elpa/company-20241210.2019/images/small/tooltip-icons-dot.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-icons-dot.png rename to elpa/company-20241210.2019/images/small/tooltip-icons-dot.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-icons-text.png b/elpa/company-20241210.2019/images/small/tooltip-icons-text.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-icons-text.png rename to elpa/company-20241210.2019/images/small/tooltip-icons-text.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-icons-vscode.png b/elpa/company-20241210.2019/images/small/tooltip-icons-vscode.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-icons-vscode.png rename to elpa/company-20241210.2019/images/small/tooltip-icons-vscode.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-limit.png b/elpa/company-20241210.2019/images/small/tooltip-limit.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-limit.png rename to elpa/company-20241210.2019/images/small/tooltip-limit.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-margin.png b/elpa/company-20241210.2019/images/small/tooltip-margin.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-margin.png rename to elpa/company-20241210.2019/images/small/tooltip-margin.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-minimum-above.png b/elpa/company-20241210.2019/images/small/tooltip-minimum-above.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-minimum-above.png rename to elpa/company-20241210.2019/images/small/tooltip-minimum-above.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-minimum-below.png b/elpa/company-20241210.2019/images/small/tooltip-minimum-below.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-minimum-below.png rename to elpa/company-20241210.2019/images/small/tooltip-minimum-below.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-offset-display.png b/elpa/company-20241210.2019/images/small/tooltip-offset-display.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-offset-display.png rename to elpa/company-20241210.2019/images/small/tooltip-offset-display.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-qa-faces-light.png b/elpa/company-20241210.2019/images/small/tooltip-qa-faces-light.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-qa-faces-light.png rename to elpa/company-20241210.2019/images/small/tooltip-qa-faces-light.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-quick-access.png b/elpa/company-20241210.2019/images/small/tooltip-quick-access.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-quick-access.png rename to elpa/company-20241210.2019/images/small/tooltip-quick-access.png diff --git a/elpa/company-20230703.2021/images/small/tooltip-search.png b/elpa/company-20241210.2019/images/small/tooltip-search.png similarity index 100% rename from elpa/company-20230703.2021/images/small/tooltip-search.png rename to elpa/company-20241210.2019/images/small/tooltip-search.png -- 2.47.3