]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/company/company-dabbrev.el
Merge commit '67ab56a5469f16652e73667ec3b4f76ff6befee6' from company
[gnu-emacs-elpa] / packages / company / company-dabbrev.el
index 80d2e5f47d8e1cf3ed264d1a9b0e9a494d02a374..b9d47a3470c064c048b3bb6da31a5f0834ff3a37 100644 (file)
@@ -1,4 +1,4 @@
-;;; company-dabbrev.el --- dabbrev-like company-mode completion back-end
+;;; company-dabbrev.el --- dabbrev-like company-mode completion back-end
 
 ;; Copyright (C) 2009, 2011  Free Software Foundation, Inc.
 
 
 
 ;;; Commentary:
-;; 
+;;
 
 ;;; Code:
 
 (require 'company)
 (eval-when-compile (require 'cl))
 
+(defgroup company-dabbrev nil
+  "dabbrev-like completion back-end."
+  :group 'company)
+
 (defcustom company-dabbrev-other-buffers 'all
-  "*Determines whether `company-dabbrev' should search other buffers.
+  "Determines whether `company-dabbrev' should search other buffers.
 If `all', search all other buffers.  If t, search buffers with the same
 major mode.
 See also `company-dabbrev-time-limit'."
-  :group 'company
   :type '(choice (const :tag "Off" nil)
                  (const :tag "Same major mode" t)
                  (const :tag "All" all)))
 
-(defcustom company-dabbrev-time-limit .5
-  "*Determines how many seconds `company-dabbrev' should look for matches."
-  :group 'company
+(defcustom company-dabbrev-time-limit .1
+  "Determines how many seconds `company-dabbrev' should look for matches."
   :type '(choice (const :tag "Off" nil)
                  (number :tag "Seconds")))
 
 (defcustom company-dabbrev-char-regexp "\\sw"
-  "*A regular expression matching the characters `company-dabbrev' looks for."
-  :group 'company
+  "A regular expression matching the characters `company-dabbrev' looks for."
   :type 'regexp)
 
+(defcustom company-dabbrev-ignore-case 'keep-prefix
+  "The value of `ignore-case' returned by `company-dabbrev'.")
+
+(defcustom company-dabbrev-minimum-length (1+ company-minimum-prefix-length)
+  "The minimum length for the string to be included.")
+
 (defmacro company-dabrev--time-limit-while (test start limit &rest body)
   (declare (indent 3) (debug t))
   `(let ((company-time-limit-while-counter 0))
@@ -78,7 +85,8 @@ See also `company-dabbrev-time-limit'."
         (setq match (match-string-no-properties 0))
         (if (and ignore-comments (company-in-string-or-comment))
             (re-search-backward "\\s<\\|\\s!\\|\\s\"\\|\\s|" nil t)
-          (push match symbols)))
+          (when (>= (length match) company-dabbrev-minimum-length)
+            (push match symbols))))
       (goto-char (or pos (point-min)))
       ;; search after pos
       (company-dabrev--time-limit-while (re-search-forward regexp nil t)
@@ -86,7 +94,8 @@ See also `company-dabbrev-time-limit'."
         (setq match (match-string-no-properties 0))
         (if (and ignore-comments (company-in-string-or-comment))
             (re-search-forward "\\s>\\|\\s!\\|\\s\"" nil t)
-          (push match symbols)))
+          (when (>= (length match) company-dabbrev-minimum-length)
+            (push match symbols))))
       symbols)))
 
 (defun company-dabbrev--search (regexp &optional limit other-buffers
@@ -109,7 +118,7 @@ See also `company-dabbrev-time-limit'."
 
 ;;;###autoload
 (defun company-dabbrev (command &optional arg &rest ignored)
-  "dabbrev-like `company-mode' completion back-end."
+  "dabbrev-like `company-mode' completion back-end."
   (interactive (list 'interactive))
   (case command
     (interactive (company-begin-backend 'company-dabbrev))
@@ -119,7 +128,7 @@ See also `company-dabbrev-time-limit'."
              (company-dabbrev--search (company-dabbrev--make-regexp arg)
                                       company-dabbrev-time-limit
                                       company-dabbrev-other-buffers)))
-    (ignore-case t)
+    (ignore-case company-dabbrev-ignore-case)
     (duplicates t)))
 
 (provide 'company-dabbrev)