Skip to content

Commit 173f269

Browse files
author
Nikhil Prabhakar
committed
Adding company-mode.
1 parent f72ea98 commit 173f269

29 files changed

+5531
-0
lines changed

company-mode/.dir-locals.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
((nil . ((indent-tabs-mode . nil)
2+
(fill-column . 80)
3+
(sentence-end-double-space . t)
4+
(emacs-lisp-docstring-fill-column . 75))))

company-mode/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.elc
2+
ert.el

company-mode/.travis.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://github.com/rolandwalker/emacs-travis
2+
3+
language: emacs-lisp
4+
5+
env:
6+
matrix:
7+
- EMACS=emacs23
8+
- EMACS=emacs24
9+
- EMACS=emacs-snapshot
10+
11+
install:
12+
- if [ "$EMACS" = "emacs23" ]; then
13+
sudo apt-get update -qq &&
14+
sudo apt-get install -qq emacs23-gtk emacs23-el;
15+
fi
16+
- if [ "$EMACS" = "emacs24" ]; then
17+
sudo add-apt-repository -y ppa:cassou/emacs &&
18+
sudo apt-get update -qq &&
19+
sudo apt-get install -qq emacs24 emacs24-el;
20+
fi
21+
- if [ "$EMACS" = "emacs-snapshot" ]; then
22+
sudo add-apt-repository -y ppa:cassou/emacs &&
23+
sudo apt-get update -qq &&
24+
sudo apt-get install -qq emacs-snapshot &&
25+
sudo apt-get install -qq emacs-snapshot-el emacs-snapshot-gtk;
26+
fi
27+
28+
before_script:
29+
make downloads
30+
31+
script:
32+
make test-batch EMACS=${EMACS}

company-mode/Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
EMACS=emacs
2+
CURL=curl --silent
3+
ERT_URL=http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/ert.el?h=emacs-24
4+
5+
.PHONY: ert test test-batch
6+
7+
package: *.el
8+
@ver=`grep -o "Version: .*" company.el | cut -c 10-`; \
9+
tar cjvf company-$$ver.tar.bz2 --mode 644 `git ls-files '*.el' | xargs`
10+
11+
elpa: *.el
12+
@version=`grep -o "Version: .*" company.el | cut -c 10-`; \
13+
dir=company-$$version; \
14+
mkdir -p "$$dir"; \
15+
cp `git ls-files '*.el' | xargs` company-$$version; \
16+
echo "(define-package \"company\" \"$$version\" \
17+
\"Modular in-buffer completion framework\")" \
18+
> "$$dir"/company-pkg.el; \
19+
tar cvf company-$$version.tar --mode 644 "$$dir"
20+
21+
clean:
22+
@rm -rf company-*/ company-*.tar company-*.tar.bz2 *.elc ert.el
23+
24+
test:
25+
${EMACS} -Q -nw -L . -l company-tests.el \
26+
--eval "(let (pop-up-windows) (ert t))"
27+
28+
test-batch:
29+
${EMACS} -Q --batch -L . -l company-tests.el \
30+
--eval "(ert-run-tests-batch-and-exit '(not (tag interactive)))"
31+
32+
downloads:
33+
${EMACS} -Q --batch -l ert || \
34+
${CURL} ${ERT_URL} > ert.el
35+
36+
compile:
37+
${EMACS} -Q --batch -L . -f batch-byte-compile company.el company-*.el

company-mode/NEWS.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# History of user-visible changes
2+
3+
## 2013-05-26 (0.6.10)
4+
5+
* Plays nicer with `org-indent-mode`.
6+
* Works in horizontally scrolled windows.
7+
8+
## 2013-05-10 (0.6.9)
9+
10+
* `company-capf` respects `:exit-function` completion property.
11+
* `company-backends`: `prefix` command can return `t` in the cdr.
12+
* `company-clang-begin-after-member-access`: New option.
13+
* Mouse click outside the tooltip aborts completion.
14+
* `company-clang` uses standard input to pass the contents of current buffer to
15+
Clang 2.9+, otherwise saves the buffer and passes the path to the file.
16+
* `company-clang-auto-save` option has been removed.
17+
* Better interaction with `outline-minor-mode`.
18+
* `company-dabbrev-code` supports all `prog-mode` derivatives.
19+
20+
## 2013-04-16 (0.6.8)
21+
22+
* `company-auto-complete` is disabled by default.
23+
* `company-auto-complete-chars` default value includes fewer syntax classes.
24+
* In expanded function calls, arguments skipped by the user default to "argN".
25+
* `company-eclim` and `company-clang` do not strip argument types from fields.
26+
* `company-clang` expands function calls for all three modes now.
27+
* `company-clang` supports `c++-mode` by default.
28+
29+
## 2013-04-05 (0.6.7)
30+
31+
* Two `company-elisp` tweaks.
32+
33+
## 2013-04-01 (0.6.6)
34+
35+
* `company-elisp` doesn't offer completions when typing the name and the
36+
arguments of a new function or macro definition, allowing to fall back to
37+
other back-ends like `company-dabbrev-code`.
38+
39+
## 2013-03-30 (0.6.5)
40+
41+
* Fixed keybindings when running in a terminal.
42+
* `company-elisp-show-locals-first`: new customizable variable.
43+
* `company-elisp` shows more accurate and comprehensive candidates list.
44+
45+
## 2013-03-26 (0.6.4)
46+
47+
* `company-eclim` shows valid completions after an opening paren.
48+
* Expanded template does not get removed until the point leaves it. After your
49+
input the last argument in a method call expanded by `company-eclim`, you can
50+
press `<tab>` once more, to jump after the closing paren. No other bundled
51+
back-ends are affected.
52+
53+
## 2013-03-25 (0.6.3)
54+
55+
* New tooltip face colors used on themes with light background.
56+
* Pseudo-tooltip stays up-to-date when text is inserted after the point.
57+
* Fixed `company-require-match` mechanics.
58+
59+
## 2013-03-24 (0.6.2)
60+
61+
* `global-company-mode` is now autoloaded.
62+
63+
## 2013-03-23 (0.6.1)
64+
65+
* Documented `init` and `post-completion` back-end commands.
66+
* `company-eclim` and `company-clang` only expand the template on explicit user
67+
action (such as `company-complete-{selection,number,mouse}`).
68+
* `company-template` has some breaking changes. When point is at one of the
69+
fields, it's displayed at the beginning, not right after it; `<tab>` jumps to
70+
the next field, `forward-word` and `subword-forward` remappings are removed;
71+
when you jump to the next field, if the current one hasn't been edited, the
72+
overlay gets removed but the text remains.
73+
* `company-eclim` shows method overloads and expands templates for calls.
74+
* `company-clang-objc-templatify` does not insert spaces after colons anymore.
75+
* `company-clang` is now only initialized in supported buffers.
76+
So, no error messages if you don't have Clang until you open a C file.
77+
* `company-clang` recognizes Clang included in recent Xcode.
78+
* New commands `company-select-previous-or-abort` and
79+
`company-select-next-or-abort`, bound to `<up>` and `<down>`.
80+
81+
## 2013-03-19 (0.6)
82+
83+
* Across-the-board bugfixing.
84+
* `company-pysmell` is not used by default anymore.
85+
* Loading of `nxml`, `semantic`, `pymacs` and `ropemacs` is now deferred.
86+
* Candidates from grouped back-ends are merged more conservatively: only
87+
back-ends that return the same prefix at point are used.
88+
* `company-clang` now shows meta information, too.
89+
* Some performance improvements.
90+
* Fixed two old tooltip annoyances.
91+
* Instead of `overrriding-terminal-local-map`, we're now using
92+
`emulation-mode-map-alists` (experimental). This largely means that when the
93+
completion keymap is active, other minor modes' keymaps are still used, so,
94+
for example, it's not as easy to accidentally circumvent `paredit-mode`
95+
when it's enabled.
96+
* `company-elisp` has seen some improvements.
97+
* Added `company-capf`: completion adapter using
98+
`completion-at-point-functions`. (Stefan Monnier)
99+
* Clang completions now include macros and are case-sensitive.
100+
* Switching between tag files now works correctly with `company-etags`.
101+
102+
## 2010-02-24 (0.5)
103+
104+
* `company-ropemacs` now provides location and docs. (Fernando H. Silva)
105+
* Added `company-with-candidate-inserted` macro.
106+
* Added `company-clang` back-end.
107+
* Added new mechanism for non-consecutive insertion.
108+
(So far only used by clang for ObjC.)
109+
* The semantic back-end now shows meta information for local symbols.
110+
* Added compatibility for CEDET in Emacs 23.2 and from CVS. (Oleg Andreev)
111+
112+
## 2009-05-07 (0.4.3)
113+
114+
* Added `company-other-backend`.
115+
* Idle completion no longer interrupts multi-key command input.
116+
* Added `company-ropemacs` and `company-pysmell` back-ends.
117+
118+
## 2009-04-25 (0.4.2)
119+
120+
* In C modes . and -> now count towards `company-minimum-prefix-length`.
121+
* Reverted default front-end back to `company-preview-if-just-one-frontend`.
122+
* The pseudo tooltip will no longer be clipped at the right window edge.
123+
* Added `company-tooltip-minimum`.
124+
* Windows compatibility fixes.
125+
126+
## 2009-04-19 (0.4.1)
127+
128+
* Added `global-company-mode`.
129+
* Performance enhancements.
130+
* Added `company-eclim` back-end.
131+
* Added safer workaround for Emacs `posn-col-row` bug.
132+
133+
## 2009-04-18 (0.4)
134+
135+
* Automatic completion is now aborted if the prefix gets too short.
136+
* Added option `company-dabbrev-time-limit`.
137+
* `company-backends` now supports merging back-ends.
138+
* Added back-end `company-dabbrev-code` for generic code.
139+
* Fixed `company-begin-with`.
140+
141+
## 2009-04-15 (0.3.1)
142+
143+
* Added 'stop prefix to prevent dabbrev from completing inside of symbols.
144+
* Fixed issues with tabbar-mode and line-spacing.
145+
* Performance enhancements.
146+
147+
## 2009-04-12 (0.3)
148+
149+
* Added `company-begin-commands` option.
150+
* Added abbrev, tempo and Xcode back-ends.
151+
* Back-ends are now interactive. You can start them with M-x backend-name.
152+
* Added `company-begin-with` for starting company from elisp-code.
153+
* Added hooks.
154+
* Added `company-require-match` and `company-auto-complete` options.
155+
156+
## 2009-04-05 (0.2.1)
157+
158+
* Improved Emacs Lisp back-end behavior for local variables.
159+
* Added `company-elisp-detect-function-context` option.
160+
* The mouse can now be used for selection.
161+
162+
## 2009-03-22 (0.2)
163+
164+
* Added `company-show-location`.
165+
* Added etags back-end.
166+
* Added work-around for end-of-buffer bug.
167+
* Added `company-filter-candidates`.
168+
* More local Lisp variables are now included in the candidates.
169+
170+
## 2009-03-21 (0.1.5)
171+
172+
* Fixed elisp documentation buffer always showing the same doc.
173+
* Added `company-echo-strip-common-frontend`.
174+
* Added `company-show-numbers` option and M-0 ... M-9 default bindings.
175+
* Don't hide the echo message if it isn't shown.
176+
177+
## 2009-03-20 (0.1)
178+
179+
* Initial release.

company-mode/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
See the [homepage](http://company-mode.github.com/).
2+
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/336ef4be2595a7859d52e2c17b7da2b2 "githalytics.com")](http://githalytics.com/company-mode/company-mode)
3+
4+
[![Build Status](https://travis-ci.org/company-mode/company-mode.png?branch=master)](https://travis-ci.org/company-mode/company-mode)

company-mode/company-abbrev.el

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
;;; company-abbrev.el --- company-mode completion back-end for abbrev
2+
3+
;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
4+
5+
;; Author: Nikolaj Schumacher
6+
7+
;; This file is part of GNU Emacs.
8+
9+
;; GNU Emacs is free software: you can redistribute it and/or modify
10+
;; it under the terms of the GNU General Public License as published by
11+
;; the Free Software Foundation, either version 3 of the License, or
12+
;; (at your option) any later version.
13+
14+
;; GNU Emacs is distributed in the hope that it will be useful,
15+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
;; GNU General Public License for more details.
18+
19+
;; You should have received a copy of the GNU General Public License
20+
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21+
22+
23+
;;; Commentary:
24+
;;
25+
26+
;;; Code:
27+
28+
(require 'company)
29+
(eval-when-compile (require 'cl))
30+
(require 'abbrev)
31+
32+
(defun company-abbrev-insert (match)
33+
"Replace MATCH with the expanded abbrev."
34+
(expand-abbrev))
35+
36+
;;;###autoload
37+
(defun company-abbrev (command &optional arg &rest ignored)
38+
"`company-mode' completion back-end for abbrev."
39+
(interactive (list 'interactive))
40+
(case command
41+
(interactive (company-begin-backend 'company-abbrev
42+
'company-abbrev-insert))
43+
(prefix (company-grab-symbol))
44+
(candidates (nconc
45+
(delete "" (all-completions arg global-abbrev-table))
46+
(delete "" (all-completions arg local-abbrev-table))))
47+
(meta (abbrev-expansion arg))
48+
(require-match t)))
49+
50+
(provide 'company-abbrev)
51+
;;; company-abbrev.el ends here

company-mode/company-capf.el

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
;;; company-capf.el --- company-mode completion-at-point-functions back-end -*- lexical-binding: t -*-
2+
3+
;; Copyright (C) 2013 Free Software Foundation, Inc.
4+
5+
;; Author: Stefan Monnier <[email protected]>
6+
7+
;; This file is part of GNU Emacs.
8+
9+
;; GNU Emacs is free software: you can redistribute it and/or modify
10+
;; it under the terms of the GNU General Public License as published by
11+
;; the Free Software Foundation, either version 3 of the License, or
12+
;; (at your option) any later version.
13+
14+
;; GNU Emacs is distributed in the hope that it will be useful,
15+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
;; GNU General Public License for more details.
18+
19+
;; You should have received a copy of the GNU General Public License
20+
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21+
22+
23+
;;; Commentary:
24+
;;
25+
26+
;;; Code:
27+
28+
(defun company--capf-data ()
29+
(let ((data (run-hook-wrapped 'completion-at-point-functions
30+
;; Ignore misbehaving functions.
31+
#'completion--capf-wrapper 'optimist)))
32+
(when (consp data) data)))
33+
34+
(defun company-capf (command &optional arg &rest _args)
35+
"`company-mode' back-end using `completion-at-point-functions'.
36+
Requires Emacs 24.1 or newer."
37+
(interactive (list 'interactive))
38+
(case command
39+
(interactive (company-begin-backend 'company-capf))
40+
(prefix
41+
(let ((res (company--capf-data)))
42+
(when res
43+
(if (> (nth 2 res) (point))
44+
'stop
45+
(buffer-substring-no-properties (nth 1 res) (point))))))
46+
(candidates
47+
(let ((res (company--capf-data)))
48+
(when res
49+
(let* ((table (nth 3 res))
50+
(pred (plist-get (nthcdr 4 res) :predicate))
51+
(meta (completion-metadata
52+
(buffer-substring (nth 1 res) (nth 2 res))
53+
table pred))
54+
(sortfun (cdr (assq 'display-sort-function meta)))
55+
(candidates (all-completions arg table pred)))
56+
(if sortfun (funcall sortfun candidates) candidates)))))
57+
(sorted
58+
(let ((res (company--capf-data)))
59+
(when res
60+
(let ((meta (completion-metadata
61+
(buffer-substring (nth 1 res) (nth 2 res))
62+
(nth 3 res) (plist-get (nthcdr 4 res) :predicate))))
63+
(cdr (assq 'display-sort-function meta))))))
64+
(duplicates nil) ;Don't bother.
65+
(no-cache t) ;FIXME: Improve!
66+
(meta nil) ;FIXME: Return one-line docstring for `arg'.
67+
(doc-buffer nil) ;FIXME: Return help buffer for `arg'.
68+
(location nil) ;FIXME: Return (BUF . POS) or (FILE . LINENB) of `arg'.
69+
(require-match nil) ;Front-ends should also have a say in this.
70+
(init nil) ;Don't bother: plenty of other ways to initialize the code.
71+
(post-completion
72+
(let* ((res (company--capf-data))
73+
(exit-function (plist-get (nthcdr 4 res) :exit-function)))
74+
(if exit-function
75+
(funcall exit-function arg 'finished))))
76+
))
77+
78+
(provide 'company-capf)
79+
80+
;;; company-capf.el ends here

0 commit comments

Comments
 (0)