"\\_<\\([[:alpha:]-]+\\):\\(?:[^};]*[[:space:]]+\\)?\\([^};]*\\_>\\|\\)\\="
"A regular expression matching CSS tags")
+;;;###autoload
(defun company-css (command &optional arg &rest ignored)
"A `company-mode' completion back-end for `css-mode'."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-css))
('prefix (and (eq major-mode 'css-mode)
(or (company-grab company-css-tag-regexp 1)
(company-grab company-css-pseudo-regexp 1)
(dabbrev--goto-start-of-abbrev)
(buffer-substring-no-properties (point) end)))))
+;;;###autoload
(defun company-dabbrev (command &optional arg &rest ignored)
"A `company-mode' completion back-end for `dabbrev-completion'."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-dabbrev))
('prefix (company-grab-dabbrev-prefix))
('candidates (let ((dabbrev-check-other-buffers))
(dabbrev--reset-global-variables)
(string-match ".*$" doc)
(match-string 0 doc))))
+;;;###autoload
(defun company-elisp (command &optional arg &rest ignored)
"A `company-mode' completion back-end for `emacs-lisp-mode'."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-elisp))
('prefix (and (eq (derived-mode-p 'emacs-lisp-mode) 'emacs-lisp-mode)
(company-grab-lisp-symbol)))
('candidates (company-elisp-candidates arg))
(setq company-etags-buffer-table (company-etags-find-table))
company-etags-buffer-table)))
+;;;###autoload
(defun company-etags (command &optional arg &rest ignored)
"A `company-mode' completion back-end for etags."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-etags))
('prefix (and (memq major-mode company-etags-modes)
(not (company-in-string-or-comment))
(require 'etags nil t)
(setq company-files-completion-cache (cons dir (nreverse candidates))))
(cdr company-files-completion-cache)))
+;;;###autoload
(defun company-files (command &optional arg &rest ignored)
"a `company-mode' completion back-end existing file names."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-files))
('prefix (company-files-grab-existing-name))
('candidates (company-files-complete arg))
('location (cons (dired-noselect
(cons (expand-file-name (match-string 2))
(string-to-number (match-string 1)))))))
+;;;###autoload
(defun company-gtags (command &optional arg &rest ignored)
"A `company-mode' completion back-end for GNU Global."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-gtags))
('prefix (and (memq major-mode company-gtags-modes)
(not (company-in-string-or-comment))
(company-gtags-available)
(setq company-ispell-available nil))))
company-ispell-available)
+;;;###autoload
(defun company-ispell (command &optional arg &rest ignored)
"A `company-mode' completion back-end using ispell."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-ispell))
('prefix (when (company-ispell-available)
(company-grab "\\<\\w+\\>")))
('candidates (lookup-words arg (or company-ispell-dictionary
(all-completions arg
(rng-match-possible-value-strings))))))))
+;;;###autoload
(defun company-nxml (command &optional arg &rest ignored)
"A `company-mode' completion back-end for `nxml-mode'."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-nxml))
('prefix (or (company-nxml-tag 'prefix)
(company-nxml-attribute 'prefix)
(company-nxml-attribute-value 'prefix)))
('oddmuse-mode (with-no-warnings
(oddmuse-make-completion-table oddmuse-wiki)))))
+;;;###autoload
(defun company-oddmuse (command &optional arg &rest ignored)
"A `company-mode' completion back-end for `oddmuse-mode'."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-oddmuse))
('prefix (let ((case-fold-search nil))
(and (memq major-mode '(oddmuse-mode yaoddmuse-mode))
(looking-back company-oddmuse-link-regexp (point-at-bol))
(context (semantic-analyze-current-context)))
(all-completions prefix (semantic-ia-get-completions context (point))))))
+;;;###autoload
(defun company-semantic (command &optional arg &rest ignored)
"A `company-mode' completion back-end using CEDET Semantic."
+ (interactive (list 'interactive))
(case command
+ ('interactive (company-begin-backend 'company-semantic))
('prefix (and (memq major-mode '(c-mode c++-mode jde-mode java-mode))
(not (company-in-string-or-comment))
(or (company-grab company-semantic-context-regexp 2) "")))
;;
;;; Change Log:
;;
+;; Back-ends are now interactive. You can start them with M-x backend-name.
;; Added `company-begin-with' for starting company from elisp-code.
;; Added hooks.
;; Added `company-require-match' and `company-auto-complete' options.
(add-to-list 'debug-ignored-errors "^No \\(document\\|loc\\)ation available$")
(add-to-list 'debug-ignored-errors "^Company not ")
(add-to-list 'debug-ignored-errors "^No candidate number ")
+(add-to-list 'debug-ignored-errors "^Cannot complete at point$")
(defgroup company nil
"Extensible inline text completion mechanism"
that option the other way around.
The back-end should return nil for all commands it does not support or
-does not know about."
+does not know about. It should also be callable interactively and use
+`company-begin-backend' to start itself in that case."
:group 'company
:type '(repeat (function :tag "function" nil)))
inactive, as well.
The completion data is retrieved using `company-backends' and displayed using
-`company-frontends'.
+`company-frontends'. If you want to start a specific back-end, call it
+interactively or use `company-begin-backend'.
regular keymap (`company-mode-map'):
(defun company-begin-backend (backend &optional callback)
"Start a completion at point using BACKEND."
+ (interactive (let ((val (completing-read "Company back-end: "
+ obarray
+ 'functionp nil "company-")))
+ (when val
+ (list (intern val)))))
(when callback
(setq company-callback
`(lambda (completion)
(add-hook 'company-completion-cancelled-hook 'company-remove-callback nil t)
(add-hook 'company-completion-finished-hook company-callback nil t))
(setq company-backend backend)
- (company-manual-begin))
+ ;; Return non-nil if active.
+ (or (company-manual-begin)
+ (error "Cannot complete at point")))
(defun company-begin-with (candidates
&optional prefix-length require-match callback)