update packages

This commit is contained in:
2025-02-26 20:16:44 +01:00
parent 59db017445
commit 45d49daef0
291 changed files with 16240 additions and 522600 deletions

View File

@@ -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))))

View File

@@ -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 <jan.tatarik@gmail.com>
@@ -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

View File

@@ -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 <monnier@iro.umontreal.ca>
@@ -19,7 +19,6 @@
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; 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,79 +73,51 @@ 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
@@ -168,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 " <f>") ; elisp-completion-at-point, pre-icons
@@ -190,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)))))
candidates))))
(defun company--capf-post-completion (arg)
(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
@@ -232,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)

View File

@@ -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)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@@ -1,6 +1,6 @@
;;; 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 <chenbin DOT sh AT gmail>
;; Version: 0.2
@@ -49,7 +49,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 +94,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 +183,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))

View File

@@ -1,6 +1,6 @@
;;; company-dabbrev-code.el --- dabbrev-like company-mode backend for code -*- lexical-binding: t -*-
;; Copyright (C) 2009-2011, 2013-2016, 2021-2023 Free Software Foundation, Inc.
;; Copyright (C) 2009-2011, 2013-2016, 2021-2024 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
@@ -48,13 +48,16 @@ complete only symbols, not text in comments or strings. In other modes
(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'."
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)))
(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."
@@ -73,12 +76,16 @@ also `company-dabbrev-code-time-limit'."
"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)))
(list :tag "Custom list of styles" symbol))
:package-version '(company . "1.0.0"))
(defvar-local company-dabbrev--boundaries nil)
(defvar-local company-dabbrev-code--sorted nil)
(defun company-dabbrev-code--make-regexp (prefix)
(let ((prefix-re
(cond
((equal prefix "")
((string-empty-p prefix)
"\\([a-zA-Z]\\|\\s_\\)")
((not company-dabbrev-code-completion-styles)
(regexp-quote prefix))
@@ -88,13 +95,15 @@ also `company-dabbrev-code-time-limit'."
(let ((prefix (if (>= (length prefix) 2)
(substring prefix 0 2)
prefix)))
(mapconcat #'regexp-quote
(mapcar #'string prefix)
"\\(\\sw\\|\\s_\\)*"))))))
(concat
"\\(\\sw\\|\\s_\\)*"
(mapconcat #'regexp-quote
(mapcar #'string prefix)
"\\(\\sw\\|\\s_\\)*")))))))
(concat "\\_<" prefix-re "\\(\\sw\\|\\s_\\)*\\_>")))
;;;###autoload
(defun company-dabbrev-code (command &optional arg &rest _ignored)
(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."
@@ -102,50 +111,77 @@ comments or strings."
(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))
(cl-some #'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)
(regexp (company-dabbrev-code--make-regexp arg)))
(company-dabbrev-code--filter
arg
(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)
(`all `all))
(not company-dabbrev-code-everywhere)))
:expire t
:check-tag regexp))))
(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)
(sorted company-dabbrev-code--sorted)
(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--filter (prefix table)
(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))
(metadata (completion-metadata prefix table nil))
res)
(if (not company-dabbrev-code-completion-styles)
(all-completions prefix table)
(setq res (completion-all-completions
prefix
table
nil (length prefix)))
(if (numberp (cdr (last res)))
(setcdr (last res) nil))
res)))
(setq res (company--capf-completions
prefix suffix
table nil
metadata))
(when-let* ((sort-fn (completion-metadata-get metadata 'display-sort-function)))
(setq company-dabbrev-code--sorted t)
(setf (alist-get :completions res)
(funcall sort-fn (alist-get :completions res))))
(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

View File

@@ -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.
@@ -156,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)))))
@@ -166,12 +169,13 @@ 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)
@@ -195,6 +199,7 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'."
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
@@ -207,6 +212,7 @@ This variable affects both `company-dabbrev' and `company-dabbrev-code'."
(candidates
(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)

View File

@@ -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 <https://www.gnu.org/licenses/>.
;;; 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

View File

@@ -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)

View File

@@ -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)))

View File

@@ -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)))

View File

@@ -1,4 +1,4 @@
;;; 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, 2023 Free Software Foundation, Inc.
@@ -39,7 +39,8 @@
(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))
:set #'company--set-dictionary)
@@ -58,18 +59,23 @@ If nil, use `ispell-complete-word-dict'."
company-ispell-available)
(defun company--ispell-dict ()
(or company-ispell-dictionary
ispell-complete-word-dict
ispell-alternate-dictionary))
"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* ((dict (company--ispell-dict))
(all-words
@@ -77,7 +83,7 @@ If nil, use `ispell-complete-word-dict'."
(lambda () (ispell-lookup-words "" dict))
:check-tag dict))
(completion-ignore-case t))
(if (string= arg "")
(if (string-empty-p arg)
;; Small optimization.
all-words
(company-substitute-prefix

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,6 +1,6 @@
(define-package "company" "20231023.1033" "Modular text completion framework"
'((emacs "25.1"))
:commit "66201465a962ac003f320a1df612641b2b276ab5" :maintainers
(define-package "company" "20250223.352" "Modular text completion framework"
'((emacs "26.1"))
:commit "5bb6f6d3d44ed919378e6968a06feed442165545" :maintainers
'(("Dmitry Gutov" . "dmitry@gutov.dev"))
:maintainer
'("Dmitry Gutov" . "dmitry@gutov.dev")

View File

@@ -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))

View File

@@ -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 ?< "(")

View File

@@ -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

View File

@@ -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)

View File

@@ -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)))

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,10 @@
This is company.info, produced by makeinfo version 6.8 from
company.texi.
This user manual is for Company version 0.10.0 (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.10.0 (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).
“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 packages name Company is based on the combination of the two
The packages name Company is based on the combination of the two
words: Complete and Anything. These words reflect the packages
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 Emacss 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 <RET> to choose a selected candidate for completion.
• Hit <TAB> to complete with the “common part”: characters present at
the beginning of all the candidates.
• Hit <TAB> to expand the “common part” of all completions. Exactly
what that means, can vary by backend. In the simplest case its
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
<return>
Insert the selected candidate (company-complete-selection).
Restart completion if a new field is entered.
TAB
<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
<ESC ESC ESC>
@@ -285,17 +293,8 @@ illustrate how to assign key bindings to such commands.
(global-set-key (kbd "<tab>") #'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 "<backtab>")
(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 dont 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 candidates _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 theres 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 theres often no real need to make such adjustments on the
users 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. Thats why were 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 Emacss 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.]
The current trend in the Emacss 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.]
Since _company-capf_ works as a bridge to the standard CAPF
facility, it is probably the most often used and recommended
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 dont 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 youre 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 backends 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 41)
* C-w: Commands. (line 45)
* M-<digit>: 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 184)
* 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 159)
* 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 170)
* company-icon-size: Tooltip Frontends. (line 170)
* 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 12)
* company-text-face-extra-attributes: Tooltip Frontends. (line 197)
* company-text-icons-add-background: Tooltip Frontends. (line 205)
* company-text-icons-format: Tooltip Frontends. (line 177)
* company-text-icons-mapping: Tooltip Frontends. (line 193)
* 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 140)
* company-tooltip-maximum-width: Tooltip Frontends. (line 133)
* 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 118)
* company-tooltip-minimum-width: Tooltip Frontends. (line 117)
* company-tooltip-offset-display: Tooltip Frontends. (line 81)
* company-tooltip-width-grow-only: Tooltip Frontends. (line 128)
* company-tooltip-width-grow-only: Tooltip Frontends. (line 127)
* company-transformers: Candidates Post-Processing.
(line 6)
@@ -1424,32 +1521,35 @@ 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 22)
(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 214)
* 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 183)
* 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)
@@ -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 41)
* 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 27)
(line 53)
* company-sort-by-occurrence: Candidates Post-Processing.
(line 17)
(line 43)
* company-sort-prefer-same-case-prefix: Candidates Post-Processing.
(line 33)
(line 59)
* company-tempo: Template Expansion. (line 11)
* company-text-icons-margin: Tooltip Frontends. (line 176)
* 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 168)
* company-vscode-light-icons-margin: Tooltip Frontends. (line 169)
* 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)
(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)
(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 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 223)
* color: Tooltip Frontends. (line 222)
* color <1>: Quick Access a Candidate.
(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 223)
* company-tooltip: Tooltip Frontends. (line 222)
* company-tooltip-search: Candidates Search. (line 6)
* complete: Terminology. (line 6)
* complete <1>: Usage Basics. (line 12)
@@ -1550,7 +1660,7 @@ Concept Index
(line 6)
* configure <2>: Configuration File. (line 6)
* configure <3>: Tooltip Frontends. (line 48)
* configure <4>: Tooltip Frontends. (line 223)
* configure <4>: Tooltip Frontends. (line 222)
* configure <5>: Preview Frontends. (line 25)
* configure <6>: Echo Frontends. (line 38)
* configure <7>: Candidates Search. (line 30)
@@ -1563,7 +1673,7 @@ Concept Index
(line 6)
* custom <2>: Configuration File. (line 6)
* custom <3>: Tooltip Frontends. (line 48)
* custom <4>: Tooltip Frontends. (line 223)
* custom <4>: Tooltip Frontends. (line 222)
* custom <5>: Preview Frontends. (line 25)
* custom <6>: Echo Frontends. (line 38)
* custom <7>: Candidates Search. (line 30)
@@ -1571,18 +1681,20 @@ Concept Index
(line 25)
* custom <9>: Quick Access a Candidate.
(line 34)
* definition: Commands. (line 41)
* 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 25)
* expansion: Template Expansion. (line 6)
* extensible: Structure. (line 6)
* face: Tooltip Frontends. (line 223)
* face: Tooltip Frontends. (line 222)
* face <1>: Preview Frontends. (line 6)
* face <2>: Preview Frontends. (line 25)
* face <3>: Echo Frontends. (line 6)
@@ -1593,19 +1705,21 @@ Concept Index
* face <8>: Quick Access a Candidate.
(line 34)
* filter: Filter Candidates. (line 6)
* finish: Usage Basics. (line 20)
* finish <1>: Commands. (line 30)
* font: Tooltip Frontends. (line 223)
* finish: Usage Basics. (line 23)
* finish <1>: Commands. (line 34)
* font: Tooltip Frontends. (line 222)
* font <1>: Quick Access a Candidate.
(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 152)
* grouped backends <1>: Candidates Post-Processing.
(line 11)
* icon: Tooltip Frontends. (line 151)
* install: Installation. (line 6)
* interface: Tooltip Frontends. (line 48)
* interface <1>: Tooltip Frontends. (line 223)
* interface <1>: Tooltip Frontends. (line 222)
* interface <2>: Preview Frontends. (line 25)
* interface <3>: Echo Frontends. (line 38)
* interface <4>: Candidates Search. (line 30)
@@ -1614,30 +1728,32 @@ Concept Index
* intro: Initial Setup. (line 6)
* issue: Troubleshooting. (line 6)
* issue tracker: Troubleshooting. (line 25)
* kind: Tooltip Frontends. (line 152)
* location: Commands. (line 41)
* kind: Tooltip Frontends. (line 151)
* location: Commands. (line 45)
* manual: Initial Setup. (line 8)
* manual <1>: Usage Basics. (line 10)
* margin: Tooltip Frontends. (line 141)
* margin <1>: Tooltip Frontends. (line 160)
* 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,8 +1761,8 @@ 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)
@@ -1659,45 +1775,45 @@ Concept Index

Tag Table:
Node: Top563
Node: Overview1982
Node: Terminology2390
Ref: Terminology-Footnote-13377
Node: Structure3583
Node: Getting Started5079
Node: Installation5357
Node: Initial Setup5740
Node: Usage Basics6586
Node: Commands7349
Ref: Commands-Footnote-19784
Node: Customization9951
Node: Customization Interface10423
Node: Configuration File10956
Node: Frontends15622
Node: Tooltip Frontends16591
Ref: Tooltip Frontends-Footnote-127358
Node: Preview Frontends27595
Ref: Preview Frontends-Footnote-128851
Node: Echo Frontends28978
Node: Candidates Search30511
Node: Filter Candidates31845
Node: Quick Access a Candidate32625
Node: Backends34243
Node: Backends Usage Basics35341
Ref: Backends Usage Basics-Footnote-136556
Node: Grouped Backends36640
Node: Package Backends38269
Node: Code Completion39198
Node: Text Completion41567
Node: File Name Completion46001
Node: Template Expansion47549
Node: Candidates Post-Processing48268
Node: Troubleshooting49745
Node: Index51418
Node: Key Index51581
Node: Variable Index53080
Node: Function Index57203
Node: Concept Index61684
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