]> code.delx.au - gnu-emacs-elpa/blobdiff - company-elisp.el
company-grab-lisp-symbol -> company-elisp--prefix; mark other privates
[gnu-emacs-elpa] / company-elisp.el
index e685c2f41dc5a581c7cf8dad462c0c8680cf535f..53b48855cc2d84604ba78026e4c3dfc31fd0c357 100644 (file)
@@ -1,6 +1,6 @@
 ;;; company-elisp.el --- A company-mode completion back-end for emacs-lisp-mode -*- lexical-binding: t -*-
 
-;; Copyright (C) 2009, 2011-2012  Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011-2013  Free Software Foundation, Inc.
 
 ;; Author: Nikolaj Schumacher
 
@@ -39,9 +39,12 @@ Functions are offered for completion only after ' and \(."
 
 (defcustom company-elisp-show-locals-first t
   "If enabled, locally bound variables and functions are displayed
-first in the candidates list.")
+first in the candidates list."
+  :group 'company
+  :type '(choice (const :tag "Off" nil)
+                 (const :tag "On" t)))
 
-(defun company-grab-lisp-symbol ()
+(defun company-elisp--prefix ()
   (let ((prefix (company-grab-symbol)))
     (if prefix
         (unless (and (company-in-string-or-comment)
@@ -49,7 +52,7 @@ first in the candidates list.")
           prefix)
       'stop)))
 
-(defun company-elisp-predicate (symbol)
+(defun company-elisp--predicate (symbol)
   (or (boundp symbol)
       (fboundp symbol)
       (facep symbol)
@@ -59,8 +62,8 @@ first in the candidates list.")
 (defvar company-elisp-parse-depth 100)
 
 (defvar company-elisp-var-binding-regexp
-  (concat "\\_<" (regexp-opt '("let" "defun" "defmacro" "defsubst"
-                               "lambda" "lexical-let"))
+  (concat "\\_<\\(?:cl-\\)?" (regexp-opt '("let" "defun" "defmacro" "defsubst"
+                                           "lambda" "lexical-let"))
           "\\*?\\_>")
   "Regular expression matching head of a multiple variable bindings form.")
 
@@ -69,10 +72,10 @@ first in the candidates list.")
   "Regular expression matching head of a form with one variable binding.")
 
 (defvar company-elisp-fun-binding-regexp
-  (concat "\\_<\\(?:cl-\\)?" (regexp-opt '("flet" "labels")) "\\_>")
+  (concat "\\_<\\(?:cl-\\)?" (regexp-opt '("flet" "labels")) "\\*?\\_>")
   "Regular expression matching head of a function bindings form.")
 
-(defun company-elisp-locals (prefix functions-p)
+(defun company-elisp--locals (prefix functions-p)
   (let ((regexp (concat "[ \t\n]*\\(\\_<" (regexp-quote prefix)
                         "\\(?:\\sw\\|\\s_\\)*\\_>\\)"))
         (pos (point))
@@ -111,9 +114,9 @@ first in the candidates list.")
     res))
 
 (defun company-elisp-candidates (prefix)
-  (let* ((predicate (company-elisp-candidates-predicate prefix))
-         (locals (company-elisp-locals prefix (eq predicate 'fboundp)))
-         (globals (company-elisp-globals prefix predicate))
+  (let* ((predicate (company-elisp--candidates-predicate prefix))
+         (locals (company-elisp--locals prefix (eq predicate 'fboundp)))
+         (globals (company-elisp--globals prefix predicate))
          (locals (loop for local in locals
                        when (not (member local globals))
                        collect local)))
@@ -122,10 +125,10 @@ first in the candidates list.")
                 (sort globals 'string<))
       (append locals globals))))
 
-(defun company-elisp-globals (prefix predicate)
+(defun company-elisp--globals (prefix predicate)
   (all-completions prefix obarray predicate))
 
-(defun company-elisp-candidates-predicate (prefix)
+(defun company-elisp--candidates-predicate (prefix)
   (let* ((completion-ignore-case nil)
          (before (char-before (- (point) (length prefix)))))
     (if (and company-elisp-detect-function-context
@@ -143,9 +146,9 @@ first in the candidates list.")
                            (looking-at company-elisp-var-binding-regexp))))))
             'fboundp
           'boundp)
-      'company-elisp-predicate)))
+      'company-elisp--predicate)))
 
-(defun company-elisp-doc (symbol)
+(defun company-elisp--doc (symbol)
   (let* ((symbol (intern symbol))
          (doc (if (fboundp symbol)
                   (documentation symbol t)
@@ -161,10 +164,10 @@ first in the candidates list.")
   (case command
     (interactive (company-begin-backend 'company-elisp))
     (prefix (and (eq (derived-mode-p 'emacs-lisp-mode) 'emacs-lisp-mode)
-                 (company-grab-lisp-symbol)))
+                 (company-elisp--prefix)))
     (candidates (company-elisp-candidates arg))
     (sorted company-elisp-show-locals-first)
-    (meta (company-elisp-doc arg))
+    (meta (company-elisp--doc arg))
     (doc-buffer (let ((symbol (intern arg)))
                   (save-window-excursion
                     (ignore-errors