]> code.delx.au - gnu-emacs-elpa/blobdiff - company-elisp.el
Added special keymap that is activated on demand.
[gnu-emacs-elpa] / company-elisp.el
index 481a55b29ef3503cc5df419797358c085957b0aa..231446b7fe53e8e29ff13e229509e9222a748a42 100644 (file)
@@ -1,3 +1,22 @@
+;;; company-elisp.el --- a company-mode completion back-end for emacs-lisp-mode
+;;
+;; Copyright (C) 2009 Nikolaj Schumacher
+;;
+;; This file is part of company.
+;;
+;; 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 <http://www.gnu.org/licenses/>.
+
 (require 'company)
 (eval-when-compile (require 'cl))
 
                   (forward-sexp))))))))
     vars))
 
+(defun company-elisp-doc (symbol)
+  (let* ((symbol (intern symbol))
+         (doc (if (fboundp symbol)
+                  (documentation symbol t)
+                (documentation-property symbol 'variable-documentation t))))
+    (and (stringp doc)
+         (string-match ".*$" doc)
+         (match-string 0 doc))))
+
 (defun company-elisp (command &optional arg &rest ignored)
   (case command
     ('prefix (and (eq major-mode 'emacs-lisp-mode)
     ('candidates (let ((completion-ignore-case nil))
                    (append (all-completions arg (company-elisp-parse-let))
                            (all-completions arg obarray
-                                            'company-elisp-predicate))))))
+                                            'company-elisp-predicate))))
+    ('meta (company-elisp-doc arg))
+    ('doc-buffer (describe-function 'describe-function)
+                 (help-buffer))))
 
 (provide 'company-elisp)
 ;;; company-elisp.el ends here