;;; company-keywords.el --- a company back-end for programming language keywords ;; ;; Copyright (C) 2009 Nikolaj Schumacher ;; ;; This file is part of company 0.4. ;; ;; This program 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 2 ;; of the License, or (at your option) any later version. ;; ;; This program 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 this program. If not, see . (require 'company) (eval-when-compile (require 'cl)) (defvar company-keywords-alist ;; Please contribute corrections or additions. '((c++-mode "asm" "auto" "bool" "break" "case" "catch" "char" "class" "const" "const_cast" "continue" "default" "delete" "do" "double" "dynamic_cast" "else" "enum" "explicit" "export" "extern" "false" "float" "for" "friend" "goto" "if" "inline" "int" "long" "mutable" "namespace" "new" "operator" "private" "protected" "public" "register" "reinterpret_cast" "return" "short" "signed" "sizeof" "static" "static_cast" "struct" "switch" "template" "this" "throw" "true" "try" "typedef" "typeid" "typename" "union" "unsigned" "using" "virtual" "void" "volatile" "wchar_t" "while") (c-mode "auto" "break" "case" "char" "const" "continue" "default" "do" "double" "else" "enum" "extern" "float" "for" "goto" "if" "int" "long" "register" "return" "short" "signed" "sizeof" "static" "struct" "switch" "typedef" "union" "unsigned" "void" "volatile" "while") (csharp-mode "abstract" "add" "alias" "as" "base" "bool" "break" "byte" "case" "catch" "char" "checked" "class" "const" "continue" "decimal" "default" "delegate" "do" "double" "else" "enum" "event" "explicit" "extern" "false" "finally" "fixed" "float" "for" "foreach" "get" "global" "goto" "if" "implicit" "in" "int" "interface" "internal" "is" "lock" "long" "namespace" "new" "null" "object" "operator" "out" "override" "params" "partial" "private" "protected" "public" "readonly" "ref" "remove" "return" "sbyte" "sealed" "set" "short" "sizeof" "stackalloc" "static" "string" "struct" "switch" "this" "throw" "true" "try" "typeof" "uint" "ulong" "unchecked" "unsafe" "ushort" "using" "value" "var" "virtual" "void" "volatile" "where" "while" "yield") (d-mode ;; from http://www.digitalmars.com/d/2.0/lex.html "abstract" "alias" "align" "asm" "assert" "auto" "body" "bool" "break" "byte" "case" "cast" "catch" "cdouble" "cent" "cfloat" "char" "class" "const" "continue" "creal" "dchar" "debug" "default" "delegate" "delete" "deprecated" "do" "double" "else" "enum" "export" "extern" "false" "final" "finally" "float" "for" "foreach" "foreach_reverse" "function" "goto" "idouble" "if" "ifloat" "import" "in" "inout" "int" "interface" "invariant" "ireal" "is" "lazy" "long" "macro" "mixin" "module" "new" "nothrow" "null" "out" "override" "package" "pragma" "private" "protected" "public" "pure" "real" "ref" "return" "scope" "short" "static" "struct" "super" "switch" "synchronized" "template" "this" "throw" "true" "try" "typedef" "typeid" "typeof" "ubyte" "ucent" "uint" "ulong" "union" "unittest" "ushort" "version" "void" "volatile" "wchar" "while" "with") (java-mode "abstract" "assert" "boolean" "break" "byte" "case" "catch" "char" "class" "continue" "default" "do" "double" "else" "enum" "extends" "final" "finally" "float" "for" "if" "implements" "import" "instanceof" "int" "interface" "long" "native" "new" "package" "private" "protected" "public" "return" "short" "static" "strictfp" "super" "switch" "synchronized" "this" "throw" "throws" "transient" "try" "void" "volatile" "while") (javascript-mode "break" "catch" "const" "continue" "delete" "do" "else" "export" "for" "function" "if" "import" "in" "instanceOf" "label" "let" "new" "return" "switch" "this" "throw" "try" "typeof" "var" "void" "while" "with" "yield") (objc-mode "@catch" "@class" "@encode" "@end" "@finally" "@implementation" "@interface" "@private" "@protected" "@protocol" "@public" "@selector" "@synchronized" "@throw" "@try" "alloc" "autorelease" "bycopy" "byref" "in" "inout" "oneway" "out" "release" "retain") (perl-mode ;; from cperl.el "AUTOLOAD" "BEGIN" "CHECK" "CORE" "DESTROY" "END" "INIT" "__END__" "__FILE__" "__LINE__" "abs" "accept" "alarm" "and" "atan2" "bind" "binmode" "bless" "caller" "chdir" "chmod" "chomp" "chop" "chown" "chr" "chroot" "close" "closedir" "cmp" "connect" "continue" "cos" "crypt" "dbmclose" "dbmopen" "defined" "delete" "die" "do" "dump" "each" "else" "elsif" "endgrent" "endhostent" "endnetent" "endprotoent" "endpwent" "endservent" "eof" "eq" "eval" "exec" "exists" "exit" "exp" "fcntl" "fileno" "flock" "for" "foreach" "fork" "format" "formline" "ge" "getc" "getgrent" "getgrgid" "getgrnam" "gethostbyaddr" "gethostbyname" "gethostent" "getlogin" "getnetbyaddr" "getnetbyname" "getnetent" "getpeername" "getpgrp" "getppid" "getpriority" "getprotobyname" "getprotobynumber" "getprotoent" "getpwent" "getpwnam" "getpwuid" "getservbyname" "getservbyport" "getservent" "getsockname" "getsockopt" "glob" "gmtime" "goto" "grep" "gt" "hex" "if" "index" "int" "ioctl" "join" "keys" "kill" "last" "lc" "lcfirst" "le" "length" "link" "listen" "local" "localtime" "lock" "log" "lstat" "lt" "map" "mkdir" "msgctl" "msgget" "msgrcv" "msgsnd" "my" "ne" "next" "no" "not" "oct" "open" "opendir" "or" "ord" "our" "pack" "package" "pipe" "pop" "pos" "print" "printf" "push" "q" "qq" "quotemeta" "qw" "qx" "rand" "read" "readdir" "readline" "readlink" "readpipe" "recv" "redo" "ref" "rename" "require" "reset" "return" "reverse" "rewinddir" "rindex" "rmdir" "scalar" "seek" "seekdir" "select" "semctl" "semget" "semop" "send" "setgrent" "sethostent" "setnetent" "setpgrp" "setpriority" "setprotoent" "setpwent" "setservent" "setsockopt" "shift" "shmctl" "shmget" "shmread" "shmwrite" "shutdown" "sin" "sleep" "socket" "socketpair" "sort" "splice" "split" "sprintf" "sqrt" "srand" "stat" "study" "sub" "substr" "symlink" "syscall" "sysopen" "sysread" "system" "syswrite" "tell" "telldir" "tie" "time" "times" "tr" "truncate" "uc" "ucfirst" "umask" "undef" "unless" "unlink" "unpack" "unshift" "untie" "until" "use" "utime" "values" "vec" "wait" "waitpid" "wantarray" "warn" "while" "write" "x" "xor" "y") (php-mode "__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" "__METHOD__" "__NAMESPACE__" "_once" "abstract" "and" "array" "as" "break" "case" "catch" "cfunction" "class" "clone" "const" "continue" "declare" "default" "die" "do" "echo" "else" "elseif" "empty" "enddeclare" "endfor" "endforeach" "endif" "endswitch" "endwhile" "eval" "exception" "exit" "extends" "final" "for" "foreach" "function" "global" "goto" "if" "implements" "include" "instanceof" "interface" "isset" "list" "namespace" "new" "old_function" "or" "php_user_filter" "print" "private" "protected" "public" "require" "require_once" "return" "static" "switch" "this" "throw" "try" "unset" "use" "var" "while" "xor") (python-mode "and" "assert" "break" "class" "continue" "def" "del" "elif" "else" "except" "exec" "finally" "for" "from" "global" "if" "import" "in" "is" "lambda" "not" "or" "pass" "print" "raise" "return" "try" "while" "yield") (ruby-mode "BEGIN" "END" "alias" "and" "begin" "break" "case" "class" "def" "defined" "do" "else" "elsif" "end" "ensure" "false" "for" "if" "in" "module" "next" "nil" "not" "or" "redo" "rescue" "retry" "return" "self" "super" "then" "true" "undef" "unless" "until" "when" "while" "yield") ;; aliases (js2-mode . javascript-mode) (espresso-mode . javascript-mode) (cperl-mode . perl-mode) (jde-mode . java-mode)) "*Alist mapping major-modes to sorted keywords for `company-keywords'.") ;;;###autoload (defun company-keywords (command &optional arg &rest ignored) "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 (let ((case-fold-search nil) (symbols (cdr (assq major-mode company-keywords-alist)))) (all-completions arg (if (consp symbols) symbols (cdr (assq symbols company-keywords-alist)))))) ('sorted t))) (provide 'company-keywords) ;;; company-keywords.el ends here