-;;; company-abbrev.el --- a company-mode completion back-end for abbrev
+;;; company-abbrev.el --- A company-mode completion back-end for abbrev
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
"A `company-mode' completion back-end for abbrev."
(interactive (list 'interactive))
(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))))
- ('meta (abbrev-expansion arg))
- ('require-match t)))
+ (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))))
+ (meta (abbrev-expansion arg))
+ (require-match t)))
(provide 'company-abbrev)
;;; company-abbrev.el ends here
-;;; company-clang.el --- a company-mode completion back-end for clang
+;;; company-clang.el --- A company-mode completion back-end for clang
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(defcustom company-clang-executable
(executable-find "clang")
- "*Location of clang executable"
+ "*Location of clang executable."
:group 'company-clang
:type 'file)
`company-clang-auto-save' determines whether to do this automatically."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-clang))
- ('init (unless company-clang-executable
- (error "Company found no clang executable"))
- (when (version< (company-clang-version)
- company-clang-required-version)
- (error "Company requires clang version 1.1")))
- ('prefix (and (memq major-mode company-clang-modes)
- buffer-file-name
- company-clang-executable
- (not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
- ('candidates (company-clang--candidates arg))
- ('post-completion (and (derived-mode-p 'objc-mode)
- (string-match ":" arg)
- (company-clang-objc-templatify arg)))))
+ (interactive (company-begin-backend 'company-clang))
+ (init (unless company-clang-executable
+ (error "Company found no clang executable"))
+ (when (version< (company-clang-version)
+ company-clang-required-version)
+ (error "Company requires clang version 1.1")))
+ (prefix (and (memq major-mode company-clang-modes)
+ buffer-file-name
+ company-clang-executable
+ (not (company-in-string-or-comment))
+ (or (company-grab-symbol) 'stop)))
+ (candidates (company-clang--candidates arg))
+ (post-completion (and (derived-mode-p 'objc-mode)
+ (string-match ":" arg)
+ (company-clang-objc-templatify arg)))))
(provide 'company-clang)
;;; company-clang.el ends here
-;;; company-css.el --- a company-mode completion back-end for css-mode
+;;; company-css.el --- A company-mode completion back-end for css-mode
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+;;; Commentary:
+
;;; Code:
(require 'company)
"\\)*"
"\\(\\(?:#\\|\\_<[[:alpha:]]\\)\\(?:[[:alnum:]-#]*\\_>\\)?\\_>\\|\\)"
"\\=")
- "A regular expression matching CSS tags")
+ "A regular expression matching CSS tags.")
;;; pseudo id
(defconst company-css-pseudo-regexp
"\\)*"
"\\(?:\\(?:\\#\\|\\_<[[:alpha:]]\\)[[:alnum:]-#]*\\):"
"\\([[:alpha:]-]+\\_>\\|\\)\\_>\\=")
- "A regular expression matching CSS pseudo classes")
+ "A regular expression matching CSS pseudo classes.")
;;; properties
;;; values
(defconst company-css-property-value-regexp
"\\_<\\([[:alpha:]-]+\\):\\(?:[^};]*[[:space:]]+\\)?\\([^};]*\\_>\\|\\)\\="
- "A regular expression matching CSS tags")
+ "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 (derived-mode-p 'css-mode)
+ (interactive (company-begin-backend 'company-css))
+ (prefix (and (derived-mode-p 'css-mode)
(or (company-grab company-css-tag-regexp 1)
(company-grab company-css-pseudo-regexp 1)
(company-grab company-css-property-value-regexp 2)
(company-css-grab-property))))
- ('candidates
+ (candidates
(cond
((company-grab company-css-tag-regexp 1)
(all-completions arg company-css-html-tags))
(company-grab company-css-property-value-regexp 1))))
((company-css-grab-property)
(all-completions arg company-css-property-alist))))
- ('sorted t)))
+ (sorted t)))
(provide 'company-css)
;;; company-css.el ends here
-;;; company-dabbrev-code.el --- a dabbrev-like company-mode back-end for code
+;;; company-dabbrev-code.el --- A dabbrev-like company-mode back-end for code
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
"*Modes that use `company-dabbrev-code'.
In all these modes `company-dabbrev-code' will complete only symbols, not text
in comments or strings. In other modes `company-dabbrev-code' will pass control
-to other back-ends \(e.g. `company-dabbrev'\).
+to other back-ends \(e.g. `company-dabbrev'\).
Value t means complete in all modes."
:group 'company
:type '(choice (repeat (symbol :tag "Major mode"))
(defcustom company-dabbrev-code-other-buffers t
"*Determines whether `company-dabbrev-code' should search other buffers.
-If 'all, search all other buffers. If t, search buffers with the same
-major-mode.
+If `all', search all other buffers. If t, search buffers with the same
+major mode.
See also `company-dabbrev-code-time-limit'."
:group 'company
:type '(choice (const :tag "Off" nil)
comments or strings."
(interactive (list 'interactive))
(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))
- (not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
- ('candidates (let ((completion-ignore-case nil))
- (company-dabbrev--search
- (company-dabbrev-code--make-regexp arg)
- company-dabbrev-code-time-limit
- company-dabbrev-code-other-buffers t)))
- ('duplicates t)))
+ (interactive (company-begin-backend 'company-dabbrev-code))
+ (prefix (and (or (eq t company-dabbrev-code-modes)
+ (apply 'derived-mode-p company-dabbrev-code-modes))
+ (not (company-in-string-or-comment))
+ (or (company-grab-symbol) 'stop)))
+ (candidates (let ((completion-ignore-case nil))
+ (company-dabbrev--search
+ (company-dabbrev-code--make-regexp arg)
+ company-dabbrev-code-time-limit
+ company-dabbrev-code-other-buffers t)))
+ (duplicates t)))
(provide 'company-dabbrev-code)
;;; company-dabbrev-code.el ends here
-;;; company-dabbrev.el --- a dabbrev-like company-mode completion back-end
+;;; company-dabbrev.el --- A dabbrev-like company-mode completion back-end
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(defcustom company-dabbrev-other-buffers 'all
"*Determines whether `company-dabbrev' should search other buffers.
-If 'all, search all other buffers. If t, search buffers with the same
-major-mode.
+If `all', search all other buffers. If t, search buffers with the same
+major mode.
See also `company-dabbrev-time-limit'."
:group 'company
:type '(choice (const :tag "Off" nil)
"A dabbrev-like `company-mode' completion back-end."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-dabbrev))
- ('prefix (company-grab-word))
- ('candidates
+ (interactive (company-begin-backend 'company-dabbrev))
+ (prefix (company-grab-word))
+ (candidates
(mapcar 'downcase
(company-dabbrev--search (company-dabbrev--make-regexp arg)
company-dabbrev-time-limit
company-dabbrev-other-buffers)))
- ('ignore-case t)
- ('duplicates t)))
+ (ignore-case t)
+ (duplicates t)))
(provide 'company-dabbrev)
;;; company-dabbrev.el ends here
-;;; company-eclim.el --- a company-mode completion back-end for eclim.
+;;; company-eclim.el --- A company-mode completion back-end for eclim.
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(defcustom company-eclim-executable
(or (executable-find "eclim") (company-eclim-executable-find))
- "*Location of eclim executable"
+ "*Location of eclim executable."
:group 'company
:type 'file)
`company-eclim-auto-save' determines whether to do this automatically."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-eclim))
- ('prefix (and (derived-mode-p 'java-mode 'jde-mode)
- buffer-file-name
- company-eclim-executable
- (company-eclim--project-name)
- (not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
- ('candidates (company-eclim--candidates arg))
- ('meta (cadr (assoc arg company-eclim--doc)))
+ (interactive (company-begin-backend 'company-eclim))
+ (prefix (and (derived-mode-p 'java-mode 'jde-mode)
+ buffer-file-name
+ company-eclim-executable
+ (company-eclim--project-name)
+ (not (company-in-string-or-comment))
+ (or (company-grab-symbol) 'stop)))
+ (candidates (company-eclim--candidates arg))
+ (meta (cadr (assoc arg company-eclim--doc)))
;; because "" doesn't return everything
- ('no-cache (equal arg ""))))
+ (no-cache (equal arg ""))))
(provide 'company-eclim)
;;; company-eclim.el ends here
-;;; company-elisp.el --- a company-mode completion back-end for emacs-lisp-mode
+;;; company-elisp.el --- A company-mode completion back-end for emacs-lisp-mode
-;; Copyright (C) 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(require 'help-mode)
(defcustom company-elisp-detect-function-context t
- "*If enabled, offer lisp functions only in appropriate contexts.
+ "*If enabled, offer Lisp functions only in appropriate contexts.
Functions are offered for completion only after ' and \(."
:group 'company
:type '(choice (const :tag "Off" nil)
"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))
- ('meta (company-elisp-doc arg))
- ('doc-buffer (let ((symbol (intern arg)))
- (save-window-excursion
- (when (or (ignore-errors (describe-function symbol))
- (ignore-errors (describe-variable symbol)))
- (help-buffer)))))
- ('location (let ((sym (intern arg)))
- (or (ignore-errors (find-definition-noselect sym nil))
- (ignore-errors (find-definition-noselect sym 'defvar))
- (ignore-errors (find-definition-noselect sym t)))))))
+ (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))
+ (meta (company-elisp-doc arg))
+ (doc-buffer (let ((symbol (intern arg)))
+ (save-window-excursion
+ (when (or (ignore-errors (describe-function symbol))
+ (ignore-errors (describe-variable symbol)))
+ (help-buffer)))))
+ (location (let ((sym (intern arg)))
+ (or (ignore-errors (find-definition-noselect sym nil))
+ (ignore-errors (find-definition-noselect sym 'defvar))
+ (ignore-errors (find-definition-noselect sym t)))))))
(provide 'company-elisp)
;;; company-elisp.el ends here
-;;; company-etags.el --- a company-mode completion back-end for etags
+;;; company-etags.el --- A company-mode completion back-end for etags
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
"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)
- (company-etags-buffer-table)
- (or (company-grab-symbol) 'stop)))
- ('candidates (let ((tags-table-list (company-etags-buffer-table))
- (completion-ignore-case nil))
- (and (or tags-file-name tags-table-list)
- (fboundp 'tags-completion-table)
- tags-table-list
- (all-completions arg (tags-completion-table)))))
- ('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))))))))
- ('sorted t)))
+ (interactive (company-begin-backend 'company-etags))
+ (prefix (and (memq major-mode company-etags-modes)
+ (not (company-in-string-or-comment))
+ (require 'etags nil t)
+ (company-etags-buffer-table)
+ (or (company-grab-symbol) 'stop)))
+ (candidates (let ((tags-table-list (company-etags-buffer-table))
+ (completion-ignore-case nil))
+ (and (or tags-file-name tags-table-list)
+ (fboundp 'tags-completion-table)
+ tags-table-list
+ (all-completions arg (tags-completion-table)))))
+ (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))))))))
+ (sorted t)))
(provide 'company-etags)
;;; company-etags.el ends here
-;;; company-files.el --- a company-mode completion back-end for file names
+;;; company-files.el --- A company-mode completion back-end for file names
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
;;;###autoload
(defun company-files (command &optional arg &rest ignored)
- "a `company-mode' completion back-end existing file names."
+ "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
- (file-name-directory (directory-file-name arg))) 1))
- ('sorted t)
- ('no-cache t)))
+ (interactive (company-begin-backend 'company-files))
+ (prefix (company-files-grab-existing-name))
+ (candidates (company-files-complete arg))
+ (location (cons (dired-noselect
+ (file-name-directory (directory-file-name arg))) 1))
+ (sorted t)
+ (no-cache t)))
(provide 'company-files)
;;; company-files.el ends here
-;;; company-gtags.el --- a company-mode completion back-end for GNU Global
+;;; company-gtags.el --- A company-mode completion back-end for GNU Global
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(defcustom company-gtags-executable
(executable-find "global")
- "*Location of GNU global executable"
+ "*Location of GNU global executable."
:type 'string
:group 'company)
"A `company-mode' completion back-end for GNU Global."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-gtags))
- ('prefix (and company-gtags-executable
- (memq major-mode company-gtags-modes)
- (not (company-in-string-or-comment))
- (company-gtags--tags-available-p)
- (or (company-grab-symbol) 'stop)))
- ('candidates (company-gtags-fetch-tags arg))
- ('sorted t)
- ('location (company-gtags-location arg))))
+ (interactive (company-begin-backend 'company-gtags))
+ (prefix (and company-gtags-executable
+ (memq major-mode company-gtags-modes)
+ (not (company-in-string-or-comment))
+ (company-gtags--tags-available-p)
+ (or (company-grab-symbol) 'stop)))
+ (candidates (company-gtags-fetch-tags arg))
+ (sorted t)
+ (location (company-gtags-location arg))))
(provide 'company-gtags)
;;; company-gtags.el ends here
-;;; company-ispell.el --- a company-mode completion back-end using ispell
+;;; company-ispell.el --- A company-mode completion back-end using ispell
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
"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-word)))
- ('candidates (lookup-words arg (or company-ispell-dictionary
- ispell-complete-word-dict)))
- ('sorted t)
- ('ignore-case t)))
+ (interactive (company-begin-backend 'company-ispell))
+ (prefix (when (company-ispell-available)
+ (company-grab-word)))
+ (candidates (lookup-words arg (or company-ispell-dictionary
+ ispell-complete-word-dict)))
+ (sorted t)
+ (ignore-case t)))
(provide 'company-ispell)
;;; company-ispell.el ends here
-;;; company-keywords.el --- a company back-end for programming language keywords
+;;; company-keywords.el --- A company back-end for programming language keywords
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
"A `company-mode' back-end for programming language keywords."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-))
- ('prefix (and (assq major-mode company-keywords-alist)
- (not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
- ('candidates
+ (interactive (company-begin-backend 'company-))
+ (prefix (and (assq major-mode company-keywords-alist)
+ (not (company-in-string-or-comment))
+ (or (company-grab-symbol) 'stop)))
+ (candidates
(let ((completion-ignore-case nil)
(symbols (cdr (assq major-mode company-keywords-alist))))
(all-completions arg (if (consp symbols)
symbols
(cdr (assq symbols company-keywords-alist))))))
- ('sorted t)))
+ (sorted t)))
(provide 'company-keywords)
;;; company-keywords.el ends here
-;;; company-nxml.el --- a company-mode completion back-end for nxml-mode
+;;; company-nxml.el --- A company-mode completion back-end for nxml-mode
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(replace-regexp-in-string "w" company-nxml-token-regexp
"<w\\(?::w\\)?\
\\(?:[ \t\r\n]+w\\(?::w\\)?[ \t\r\n]*=\
-[ \t\r\n]*\\(?:\"[^\"]*\"\\|'[^']*'\\)\\)*\
-[ \t\r\n]+\\(w\\(:w\\)?\\)[ \t\r\n]*=[ \t\r\n]*\
+\[ \t\r\n]*\\(?:\"[^\"]*\"\\|'[^']*'\\)\\)*\
+\[ \t\r\n]+\\(w\\(:w\\)?\\)[ \t\r\n]*=[ \t\r\n]*\
\\(\"\\([^\"]*\\>\\)\\|'\\([^']*\\>\\)\\)\\="
t t))
(defun company-nxml-tag (command &optional arg &rest ignored)
(case command
- ('prefix (and (derived-mode-p 'nxml-mode)
- rng-validate-mode
- (company-grab company-nxml-in-tag-name-regexp 1)))
- ('candidates (company-nxml-prepared
- (company-nxml-all-completions arg
- (rng-match-possible-start-tag-names))))
- ('sorted t)))
+ (prefix (and (derived-mode-p 'nxml-mode)
+ rng-validate-mode
+ (company-grab company-nxml-in-tag-name-regexp 1)))
+ (candidates (company-nxml-prepared
+ (company-nxml-all-completions arg
+ (rng-match-possible-start-tag-names))))
+ (sorted t)))
(defun company-nxml-attribute (command &optional arg &rest ignored)
(case command
- ('prefix (and (derived-mode-p 'nxml-mode)
+ (prefix (and (derived-mode-p 'nxml-mode)
rng-validate-mode
(memq (char-after) '(?\ ?\t ?\n)) ;; outside word
(company-grab rng-in-attribute-regex 1)))
- ('candidates (company-nxml-prepared
- (and (rng-adjust-state-for-attribute
- lt-pos (- (point) (length arg)))
- (company-nxml-all-completions arg
- (rng-match-possible-attribute-names)))))
- ('sorted t)))
+ (candidates (company-nxml-prepared
+ (and (rng-adjust-state-for-attribute
+ lt-pos (- (point) (length arg)))
+ (company-nxml-all-completions arg
+ (rng-match-possible-attribute-names)))))
+ (sorted t)))
(defun company-nxml-attribute-value (command &optional arg &rest ignored)
(case command
- ('prefix (and (derived-mode-p 'nxml-mode)
- rng-validate-mode
- (and (memq (char-after) '(?' ?\" ?\ ?\t ?\n)) ;; outside word
- (looking-back company-nxml-in-attribute-value-regexp)
- (or (match-string-no-properties 4)
- (match-string-no-properties 5)
- ""))))
- ('candidates (company-nxml-prepared
- (let (attr-start attr-end colon)
- (and (looking-back rng-in-attribute-value-regex lt-pos)
- (setq colon (match-beginning 2)
- attr-start (match-beginning 1)
- attr-end (match-end 1))
- (rng-adjust-state-for-attribute lt-pos attr-start)
- (rng-adjust-state-for-attribute-value
- attr-start colon attr-end)
- (all-completions arg
- (rng-match-possible-value-strings))))))))
+ (prefix (and (derived-mode-p 'nxml-mode)
+ rng-validate-mode
+ (and (memq (char-after) '(?' ?\" ?\ ?\t ?\n)) ;; outside word
+ (looking-back company-nxml-in-attribute-value-regexp)
+ (or (match-string-no-properties 4)
+ (match-string-no-properties 5)
+ ""))))
+ (candidates (company-nxml-prepared
+ (let (attr-start attr-end colon)
+ (and (looking-back rng-in-attribute-value-regex lt-pos)
+ (setq colon (match-beginning 2)
+ attr-start (match-beginning 1)
+ attr-end (match-end 1))
+ (rng-adjust-state-for-attribute lt-pos attr-start)
+ (rng-adjust-state-for-attribute-value
+ attr-start colon attr-end)
+ (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)))
- ('candidates (cond
- ((company-nxml-tag 'prefix)
- (company-nxml-tag 'candidates arg))
- ((company-nxml-attribute 'prefix)
- (company-nxml-attribute 'candidates arg))
- ((company-nxml-attribute-value 'prefix)
- (sort (company-nxml-attribute-value 'candidates arg)
- 'string<))))
- ('sorted t)))
+ (interactive (company-begin-backend 'company-nxml))
+ (prefix (or (company-nxml-tag 'prefix)
+ (company-nxml-attribute 'prefix)
+ (company-nxml-attribute-value 'prefix)))
+ (candidates (cond
+ ((company-nxml-tag 'prefix)
+ (company-nxml-tag 'candidates arg))
+ ((company-nxml-attribute 'prefix)
+ (company-nxml-attribute 'candidates arg))
+ ((company-nxml-attribute-value 'prefix)
+ (sort (company-nxml-attribute-value 'candidates arg)
+ 'string<))))
+ (sorted t)))
(provide 'company-nxml)
;;; company-nxml.el ends here
-;;; company-oddmuse.el --- a company-mode completion back-end for oddmuse-mode
+;;; company-oddmuse.el --- A company-mode completion back-end for oddmuse-mode
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(defun company-oddmuse-get-page-table ()
(case major-mode
- ('yaoddmuse-mode (with-no-warnings
- (yaoddmuse-get-pagename-table yaoddmuse-wikiname)))
- ('oddmuse-mode (with-no-warnings
- (oddmuse-make-completion-table oddmuse-wiki)))))
+ (yaoddmuse-mode (with-no-warnings
+ (yaoddmuse-get-pagename-table yaoddmuse-wikiname)))
+ (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))
- (or (match-string 1)
- (match-string 2)))))
- ('candidates (all-completions arg (company-oddmuse-get-page-table)))))
+ (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))
+ (or (match-string 1)
+ (match-string 2)))))
+ (candidates (all-completions arg (company-oddmuse-get-page-table)))))
(provide 'company-oddmuse)
;;; company-oddmuse.el ends here
-;;; company-pysmell.el --- a company-mode completion back-end for pysmell.el
+;;; company-pysmell.el --- A company-mode completion back-end for pysmell.el
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(eval-when-compile (require 'cl))
This requires pysmell.el and pymacs.el."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-pysmell))
- ('prefix (and (derived-mode-p 'python-mode)
- buffer-file-name
- (not (company-in-string-or-comment))
- (company-pysmell--available-p)
- (company-pysmell--grab-symbol)))
- ('candidates (delete "" (pysmell-get-all-completions)))))
+ (interactive (company-begin-backend 'company-pysmell))
+ (prefix (and (derived-mode-p 'python-mode)
+ buffer-file-name
+ (not (company-in-string-or-comment))
+ (company-pysmell--available-p)
+ (company-pysmell--grab-symbol)))
+ (candidates (delete "" (pysmell-get-all-completions)))))
(provide 'company-pysmell)
;;; company-pysmell.el ends here
-;;; company-ropemacs.el --- a company-mode completion back-end for pysmell.el
+;;; company-ropemacs.el --- A company-mode completion back-end for pysmell.el
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(eval-when-compile (require 'cl))
"A `company-mode' completion back-end for ropemacs."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-ropemacs))
- ('prefix (and (derived-mode-p 'python-mode)
- (not (company-in-string-or-comment))
- (company-ropemacs--grab-symbol)))
- ('candidates (mapcar (lambda (element) (concat arg element))
- (rope-completions)))
- ('doc-buffer (company-ropemacs-doc-buffer arg))
- ('location (company-ropemacs-location arg))))
+ (interactive (company-begin-backend 'company-ropemacs))
+ (prefix (and (derived-mode-p 'python-mode)
+ (not (company-in-string-or-comment))
+ (company-ropemacs--grab-symbol)))
+ (candidates (mapcar (lambda (element) (concat arg element))
+ (rope-completions)))
+ (doc-buffer (company-ropemacs-doc-buffer arg))
+ (location (company-ropemacs-location arg))))
(provide 'company-ropemacs)
;;; company-ropemacs.el ends here
-;;; company-semantic.el --- a company-mode back-end using CEDET Semantic
+;;; company-semantic.el --- A company-mode back-end using CEDET Semantic
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode))
(defvar company-semantic--current-tags nil
- "Tags for the current context")
+ "Tags for the current context.")
(defun company-semantic-doc-or-summary (tag)
(or (semantic-documentation-for-tag tag)
"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 company-semantic-modes)
- (semantic-active-p)
- (not (company-in-string-or-comment))
- (or (company-semantic--grab) 'stop)))
- ('candidates (if (and (equal arg "")
- (not (looking-back "->\\|\\.")))
- (company-semantic-completions-raw arg)
- (company-semantic-completions arg)))
- ('meta (funcall company-semantic-metadata-function
- (assoc arg company-semantic--current-tags)))
- ('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 ""))
- ('location (let ((tag (assoc arg company-semantic--current-tags)))
- (when (buffer-live-p (semantic-tag-buffer tag))
- (cons (semantic-tag-buffer tag)
- (semantic-tag-start tag)))))))
+ (interactive (company-begin-backend 'company-semantic))
+ (prefix (and (memq major-mode company-semantic-modes)
+ (semantic-active-p)
+ (not (company-in-string-or-comment))
+ (or (company-semantic--grab) 'stop)))
+ (candidates (if (and (equal arg "")
+ (not (looking-back "->\\|\\.")))
+ (company-semantic-completions-raw arg)
+ (company-semantic-completions arg)))
+ (meta (funcall company-semantic-metadata-function
+ (assoc arg company-semantic--current-tags)))
+ (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 ""))
+ (location (let ((tag (assoc arg company-semantic--current-tags)))
+ (when (buffer-live-p (semantic-tag-buffer tag))
+ (cons (semantic-tag-buffer tag)
+ (semantic-tag-start tag)))))))
(provide 'company-semantic)
;;; company-semantic.el ends here
-;;; company-tempo.el --- a company-mode completion back-end for tempo
+;;; company-tempo.el --- A company-mode completion back-end for tempo
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
"A `company-mode' completion back-end for tempo."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-tempo
- 'company-tempo-insert))
- ('prefix (or (car (tempo-find-match-string tempo-match-finder)) ""))
- ('candidates (all-completions arg (tempo-build-collection)))
- ('meta (company-tempo-meta arg))
- ('require-match t)
- ('sorted t)))
+ (interactive (company-begin-backend 'company-tempo
+ 'company-tempo-insert))
+ (prefix (or (car (tempo-find-match-string tempo-match-finder)) ""))
+ (candidates (all-completions arg (tempo-build-collection)))
+ (meta (company-tempo-meta arg))
+ (require-match t)
+ (sorted t)))
(provide 'company-tempo)
;;; company-tempo.el ends here
-;;; company-xcode.el --- a company-mode completion back-end for Xcode projects
+;;; company-xcode.el --- A company-mode completion back-end for Xcode projects
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
;;; Code:
(require 'company)
(eval-when-compile (require 'cl))
(defcustom company-xcode-xcodeindex-executable (executable-find "xcodeindex")
- "*Location of xcodeindex executable"
+ "*Location of xcodeindex executable."
:group 'company-xcode
:type 'file)
(defcustom company-xcode-types
'("Class" "Constant" "Enum" "Macro" "Modeled Class" "Structure"
"Type" "Union" "Function")
- "*The types of symbols offered by `company-xcode'
+ "*The types of symbols offered by `company-xcode'.
No context-enabled completion is available. Types like methods will be
offered regardless of whether the class supports them. The defaults should be
valid in most contexts."
"A `company-mode' completion back-end for Xcode projects."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-xcode))
- ('prefix (and company-xcode-xcodeindex-executable
+ (interactive (company-begin-backend 'company-xcode))
+ (prefix (and company-xcode-xcodeindex-executable
+ (company-xcode-tags)
+ (not (company-in-string-or-comment))
+ (or (company-grab-symbol) 'stop)))
+ (candidates (let ((completion-ignore-case nil))
(company-xcode-tags)
- (not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
- ('candidates (let ((completion-ignore-case nil))
- (company-xcode-tags)
- (all-completions arg (company-xcode-tags))))))
+ (all-completions arg (company-xcode-tags))))))
(provide 'company-xcode)
-;;; company.el --- extensible inline text completion mechanism
+;;; company.el --- Extensible inline text completion mechanism
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
;; Version: 0.5
;; Keywords: abbrev, convenience, matching
-;; URL: http://nschum.de/src/emacs/company/
+;; URL: http://nschum.de/src/emacs/company-mode/
;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x
;; This file is part of GNU Emacs.
;;
;; (defun company-my-backend (command &optional arg &rest ignored)
;; (case command
-;; ('prefix (when (looking-back "foo\\>")
+;; (prefix (when (looking-back "foo\\>")
;; (match-string 0)))
-;; ('candidates (list "foobar" "foobaz" "foobarbaz"))
-;; ('meta (format "This value is named %s" arg))))
+;; (candidates (list "foobar" "foobaz" "foobarbaz"))
+;; (meta (format "This value is named %s" arg))))
;;
;; Sometimes it is a good idea to mix two back-ends together, for example to
;; enrich gtags with dabbrev-code results (to emulate local variables):
(assq backend company-safe-backends))
(return t))))))
-(defcustom company-backends '(company-elisp company-nxml company-css
+(defun company-capf (command &optional arg &rest args)
+ "Adapter for Company completion to use `completion-at-point-functions'."
+ (interactive (list 'interactive))
+ (case command
+ (interactive (company-begin-backend 'company-capf))
+ (prefix
+ (let ((res (run-hook-wrapped 'completion-at-point-functions
+ ;; Ignore misbehaving functions.
+ #'completion--capf-wrapper 'optimist)))
+ (when (consp res)
+ (if (> (nth 1 res) (point))
+ 'stop
+ (buffer-substring-no-properties (nth 0 res) (point))))))
+ (candidates
+ (let ((res (run-hook-wrapped 'completion-at-point-functions
+ ;; Ignore misbehaving functions.
+ #'completion--capf-wrapper 'optimist)))
+ (when (consp res)
+ (all-completions arg (nth 2 res)
+ (plist-get (nthcdr 3 res) :predicate)))))))
+
+(defcustom company-backends '(;; company-capf ;FIXME: Untested!
+ company-elisp company-nxml company-css
company-eclim company-semantic company-clang
company-xcode company-ropemacs
(company-gtags company-etags company-dabbrev-code
The first argument is the command requested from the back-end. It is one
of the following:
-'prefix: The back-end should return the text to be completed. It must be
+`prefix': The back-end should return the text to be completed. It must be
text immediately before `point'. Returning nil passes control to the next
back-end. The function should return 'stop if it should complete but cannot
\(e.g. if it is in the middle of a string\). If the returned value is only
cons of prefix and prefix length, which is then used in the
`company-minimum-prefix-length' test.
-'candidates: The second argument is the prefix to be completed. The
+`candidates': The second argument is the prefix to be completed. The
return value should be a list of candidates that start with the prefix.
Optional commands:
-'sorted: The back-end may return t here to indicate that the candidates
+`sorted': The back-end may return t here to indicate that the candidates
are sorted and will not need to be sorted again.
-'duplicates: If non-nil, company will take care of removing duplicates
+`duplicates': If non-nil, company will take care of removing duplicates
from the list.
-'no-cache: Usually company doesn't ask for candidates again as completion
+`no-cache': Usually company doesn't ask for candidates again as completion
progresses, unless the back-end returns t for this command. The second
argument is the latest prefix.
-'meta: The second argument is a completion candidate. The back-end should
+`meta': The second argument is a completion candidate. The back-end should
return a (short) documentation string for it.
-'doc-buffer: The second argument is a completion candidate. The back-end should
-create a buffer (preferably with `company-doc-buffer'), fill it with
-documentation and return it.
+`doc-buffer': The second argument is a completion candidate.
+The back-end should create a buffer (preferably with `company-doc-buffer'),
+fill it with documentation and return it.
-'location: The second argument is a completion candidate. The back-end can
+`location': The second argument is a completion candidate. The back-end can
return the cons of buffer and buffer location, or of file and line
number where the completion candidate was defined.
-'require-match: If this value is t, the user is not allowed to enter anything
+`require-match': If this value is t, the user is not allowed to enter anything
not offering as a candidate. Use with care! The default value nil gives the
user that choice with `company-require-match'. Return value 'never overrides
that option the other way around.
(defun company--multi-backend-adapter (backends command &rest args)
(case command
- ('candidates
+ (candidates
(apply 'append (mapcar (lambda (backend) (apply backend command args))
backends)))
- ('sorted nil)
- ('duplicates t)
+ (sorted nil)
+ (duplicates t)
(otherwise
(let (value)
(dolist (backend backends)
(defun company-pseudo-tooltip-frontend (command)
"A `company-mode' front-end similar to a tool-tip but based on overlays."
(case command
- ('pre-command (company-pseudo-tooltip-hide-temporarily))
- ('post-command
+ (pre-command (company-pseudo-tooltip-hide-temporarily))
+ (post-command
(let ((old-height (if (overlayp company-pseudo-tooltip-overlay)
(overlay-get company-pseudo-tooltip-overlay
'company-height)
(company-pseudo-tooltip-show-at-point (- (point)
(length company-prefix)))))
(company-pseudo-tooltip-unhide))
- ('hide (company-pseudo-tooltip-hide)
+ (hide (company-pseudo-tooltip-hide)
(setq company-tooltip-offset 0))
- ('update (when (overlayp company-pseudo-tooltip-overlay)
+ (update (when (overlayp company-pseudo-tooltip-overlay)
(company-pseudo-tooltip-edit company-candidates
company-selection)))))
(defun company-preview-frontend (command)
"A `company-mode' front-end showing the selection as if it had been inserted."
(case command
- ('pre-command (company-preview-hide))
- ('post-command (company-preview-show-at-point (point)))
- ('hide (company-preview-hide))))
+ (pre-command (company-preview-hide))
+ (post-command (company-preview-show-at-point (point)))
+ (hide (company-preview-hide))))
(defun company-preview-if-just-one-frontend (command)
"`company-preview-frontend', but only shown for single candidates."
(defun company-echo-frontend (command)
"A `company-mode' front-end showing the candidates in the echo area."
(case command
- ('pre-command (company-echo-show-soon))
- ('post-command (company-echo-show-soon 'company-echo-format))
- ('hide (company-echo-hide))))
+ (pre-command (company-echo-show-soon))
+ (post-command (company-echo-show-soon 'company-echo-format))
+ (hide (company-echo-hide))))
(defun company-echo-strip-common-frontend (command)
"A `company-mode' front-end showing the candidates in the echo area."
(case command
- ('pre-command (company-echo-show-soon))
- ('post-command (company-echo-show-soon 'company-echo-strip-common-format))
- ('hide (company-echo-hide))))
+ (pre-command (company-echo-show-soon))
+ (post-command (company-echo-show-soon 'company-echo-strip-common-format))
+ (hide (company-echo-hide))))
(defun company-echo-metadata-frontend (command)
"A `company-mode' front-end showing the documentation in the echo area."
(case command
- ('pre-command (company-echo-show-soon))
- ('post-command (company-echo-show-soon 'company-fetch-metadata))
- ('hide (company-echo-hide))))
+ (pre-command (company-echo-show-soon))
+ (post-command (company-echo-show-soon 'company-fetch-metadata))
+ (hide (company-echo-hide))))
;; templates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;