]> code.delx.au - gnu-emacs-elpa/blob - company-keywords.el
Bumped version to 0.4.
[gnu-emacs-elpa] / company-keywords.el
1 ;;; company-keywords.el --- a company back-end for programming language keywords
2 ;;
3 ;; Copyright (C) 2009 Nikolaj Schumacher
4 ;;
5 ;; This file is part of company 0.4.
6 ;;
7 ;; This program is free software; you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License
9 ;; as published by the Free Software Foundation; either version 2
10 ;; of the License, or (at your option) any later version.
11 ;;
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 (require 'company)
21 (eval-when-compile (require 'cl))
22
23 (defvar company-keywords-alist
24 ;; Please contribute corrections or additions.
25 '((c++-mode
26 "asm" "auto" "bool" "break" "case" "catch" "char" "class" "const"
27 "const_cast" "continue" "default" "delete" "do" "double" "dynamic_cast"
28 "else" "enum" "explicit" "export" "extern" "false" "float" "for" "friend"
29 "goto" "if" "inline" "int" "long" "mutable" "namespace" "new"
30 "operator" "private" "protected" "public" "register" "reinterpret_cast"
31 "return" "short" "signed" "sizeof" "static" "static_cast" "struct" "switch"
32 "template" "this" "throw" "true" "try" "typedef" "typeid" "typename"
33 "union" "unsigned" "using" "virtual" "void" "volatile" "wchar_t" "while")
34 (c-mode
35 "auto" "break" "case" "char" "const" "continue" "default" "do"
36 "double" "else" "enum" "extern" "float" "for" "goto" "if" "int" "long"
37 "register" "return" "short" "signed" "sizeof" "static" "struct"
38 "switch" "typedef" "union" "unsigned" "void" "volatile" "while")
39 (csharp-mode
40 "abstract" "add" "alias" "as" "base" "bool" "break" "byte" "case"
41 "catch" "char" "checked" "class" "const" "continue" "decimal" "default"
42 "delegate" "do" "double" "else" "enum" "event" "explicit" "extern"
43 "false" "finally" "fixed" "float" "for" "foreach" "get" "global" "goto"
44 "if" "implicit" "in" "int" "interface" "internal" "is" "lock" "long"
45 "namespace" "new" "null" "object" "operator" "out" "override" "params"
46 "partial" "private" "protected" "public" "readonly" "ref" "remove"
47 "return" "sbyte" "sealed" "set" "short" "sizeof" "stackalloc" "static"
48 "string" "struct" "switch" "this" "throw" "true" "try" "typeof" "uint"
49 "ulong" "unchecked" "unsafe" "ushort" "using" "value" "var" "virtual"
50 "void" "volatile" "where" "while" "yield")
51 (d-mode
52 ;; from http://www.digitalmars.com/d/2.0/lex.html
53 "abstract" "alias" "align" "asm"
54 "assert" "auto" "body" "bool" "break" "byte" "case" "cast" "catch"
55 "cdouble" "cent" "cfloat" "char" "class" "const" "continue" "creal"
56 "dchar" "debug" "default" "delegate" "delete" "deprecated" "do"
57 "double" "else" "enum" "export" "extern" "false" "final" "finally"
58 "float" "for" "foreach" "foreach_reverse" "function" "goto" "idouble"
59 "if" "ifloat" "import" "in" "inout" "int" "interface" "invariant"
60 "ireal" "is" "lazy" "long" "macro" "mixin" "module" "new" "nothrow"
61 "null" "out" "override" "package" "pragma" "private" "protected"
62 "public" "pure" "real" "ref" "return" "scope" "short" "static" "struct"
63 "super" "switch" "synchronized" "template" "this" "throw" "true" "try"
64 "typedef" "typeid" "typeof" "ubyte" "ucent" "uint" "ulong" "union"
65 "unittest" "ushort" "version" "void" "volatile" "wchar" "while" "with")
66 (java-mode
67 "abstract" "assert" "boolean" "break" "byte" "case" "catch" "char" "class"
68 "continue" "default" "do" "double" "else" "enum" "extends" "final"
69 "finally" "float" "for" "if" "implements" "import" "instanceof" "int"
70 "interface" "long" "native" "new" "package" "private" "protected" "public"
71 "return" "short" "static" "strictfp" "super" "switch" "synchronized"
72 "this" "throw" "throws" "transient" "try" "void" "volatile" "while")
73 (javascript-mode
74 "break" "catch" "const" "continue" "delete" "do" "else" "export" "for"
75 "function" "if" "import" "in" "instanceOf" "label" "let" "new" "return"
76 "switch" "this" "throw" "try" "typeof" "var" "void" "while" "with" "yield")
77 (objc-mode
78 "@catch" "@class" "@encode" "@end" "@finally" "@implementation"
79 "@interface" "@private" "@protected" "@protocol" "@public"
80 "@selector" "@synchronized" "@throw" "@try" "alloc" "autorelease"
81 "bycopy" "byref" "in" "inout" "oneway" "out" "release" "retain")
82 (perl-mode
83 ;; from cperl.el
84 "AUTOLOAD" "BEGIN" "CHECK" "CORE" "DESTROY" "END" "INIT" "__END__"
85 "__FILE__" "__LINE__" "abs" "accept" "alarm" "and" "atan2" "bind"
86 "binmode" "bless" "caller" "chdir" "chmod" "chomp" "chop" "chown" "chr"
87 "chroot" "close" "closedir" "cmp" "connect" "continue" "cos"
88 "crypt" "dbmclose" "dbmopen" "defined" "delete" "die" "do" "dump" "each"
89 "else" "elsif" "endgrent" "endhostent" "endnetent" "endprotoent"
90 "endpwent" "endservent" "eof" "eq" "eval" "exec" "exists" "exit" "exp"
91 "fcntl" "fileno" "flock" "for" "foreach" "fork" "format" "formline"
92 "ge" "getc" "getgrent" "getgrgid" "getgrnam" "gethostbyaddr"
93 "gethostbyname" "gethostent" "getlogin" "getnetbyaddr" "getnetbyname"
94 "getnetent" "getpeername" "getpgrp" "getppid" "getpriority"
95 "getprotobyname" "getprotobynumber" "getprotoent" "getpwent" "getpwnam"
96 "getpwuid" "getservbyname" "getservbyport" "getservent" "getsockname"
97 "getsockopt" "glob" "gmtime" "goto" "grep" "gt" "hex" "if" "index" "int"
98 "ioctl" "join" "keys" "kill" "last" "lc" "lcfirst" "le" "length"
99 "link" "listen" "local" "localtime" "lock" "log" "lstat" "lt" "map"
100 "mkdir" "msgctl" "msgget" "msgrcv" "msgsnd" "my" "ne" "next" "no"
101 "not" "oct" "open" "opendir" "or" "ord" "our" "pack" "package" "pipe"
102 "pop" "pos" "print" "printf" "push" "q" "qq" "quotemeta" "qw" "qx"
103 "rand" "read" "readdir" "readline" "readlink" "readpipe" "recv" "redo"
104 "ref" "rename" "require" "reset" "return" "reverse" "rewinddir" "rindex"
105 "rmdir" "scalar" "seek" "seekdir" "select" "semctl" "semget" "semop"
106 "send" "setgrent" "sethostent" "setnetent" "setpgrp" "setpriority"
107 "setprotoent" "setpwent" "setservent" "setsockopt" "shift" "shmctl"
108 "shmget" "shmread" "shmwrite" "shutdown" "sin" "sleep" "socket"
109 "socketpair" "sort" "splice" "split" "sprintf" "sqrt" "srand" "stat"
110 "study" "sub" "substr" "symlink" "syscall" "sysopen" "sysread" "system"
111 "syswrite" "tell" "telldir" "tie" "time" "times" "tr" "truncate" "uc"
112 "ucfirst" "umask" "undef" "unless" "unlink" "unpack" "unshift" "untie"
113 "until" "use" "utime" "values" "vec" "wait" "waitpid"
114 "wantarray" "warn" "while" "write" "x" "xor" "y")
115 (php-mode
116 "__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" "__METHOD__"
117 "__NAMESPACE__" "_once" "abstract" "and" "array" "as" "break" "case"
118 "catch" "cfunction" "class" "clone" "const" "continue" "declare"
119 "default" "die" "do" "echo" "else" "elseif" "empty" "enddeclare"
120 "endfor" "endforeach" "endif" "endswitch" "endwhile" "eval" "exception"
121 "exit" "extends" "final" "for" "foreach" "function" "global"
122 "goto" "if" "implements" "include" "instanceof" "interface"
123 "isset" "list" "namespace" "new" "old_function" "or" "php_user_filter"
124 "print" "private" "protected" "public" "require" "require_once" "return"
125 "static" "switch" "this" "throw" "try" "unset" "use" "var" "while" "xor")
126 (python-mode
127 "and" "assert" "break" "class" "continue" "def" "del" "elif" "else"
128 "except" "exec" "finally" "for" "from" "global" "if" "import" "in" "is"
129 "lambda" "not" "or" "pass" "print" "raise" "return" "try" "while" "yield")
130 (ruby-mode
131 "BEGIN" "END" "alias" "and" "begin" "break" "case" "class" "def" "defined"
132 "do" "else" "elsif" "end" "ensure" "false" "for" "if" "in" "module"
133 "next" "nil" "not" "or" "redo" "rescue" "retry" "return" "self" "super"
134 "then" "true" "undef" "unless" "until" "when" "while" "yield")
135 ;; aliases
136 (js2-mode . javascript-mode)
137 (espresso-mode . javascript-mode)
138 (cperl-mode . perl-mode)
139 (jde-mode . java-mode))
140 "*Alist mapping major-modes to sorted keywords for `company-keywords'.")
141
142 ;;;###autoload
143 (defun company-keywords (command &optional arg &rest ignored)
144 "A `company-mode' back-end for programming language keywords."
145 (interactive (list 'interactive))
146 (case command
147 ('interactive (company-begin-backend 'company-))
148 ('prefix (and (assq major-mode company-keywords-alist)
149 (not (company-in-string-or-comment))
150 (or (company-grab-symbol) 'stop)))
151 ('candidates
152 (let ((case-fold-search nil)
153 (symbols (cdr (assq major-mode company-keywords-alist))))
154 (all-completions arg (if (consp symbols)
155 symbols
156 (cdr (assq symbols company-keywords-alist))))))
157 ('sorted t)))
158
159 (provide 'company-keywords)
160 ;;; company-keywords.el ends here
161
162