- '(asm-mode batch-file-mode c++-mode c-mode cperl-mode csharp-mode css-mode
- emacs-lisp-mode erlang-mode espresso-mode f90-mode fortran-mode
- haskell-mode java-mode javascript-mode jde-mode js2-mode lisp-mode
- lua-mode objc-mode perl-mode php-mode python-mode ruby-mode scheme-mode
- shell-script-mode)
- "*Modes that use `company-dabbrev-code'.
-In all these modes `company-dabbrev-code' will complete only symbols, not text
-in comments or strings. In other modes `company-dabbrev-code' will pass control
-to other back-ends \(e.g. `company-dabbrev'\)"
- :group 'company
- :type '(repeat (symbol :tag "Major mode")))
-
-(defun company-dabbrev-code--buffer-symbols (prefix)
- (save-excursion
- (goto-char (point-min))
- (let ((regexp (concat "\\_<" (if (equal prefix "")
- "\\([a-zA-Z]\\|\\s_\\)"
- (regexp-quote prefix))
- "\\(\\sw\\|\\s_\\)*\\_>"))
- match symbols)
- (while (re-search-forward regexp nil t)
- (setq match (match-string-no-properties 0))
- (unless (company-in-string-or-comment)
- (add-to-list 'symbols match)))
- symbols)))
+ '(prog-mode
+ batch-file-mode csharp-mode css-mode erlang-mode haskell-mode jde-mode
+ lua-mode python-mode)
+ "Modes that use `company-dabbrev-code'.
+In all these modes (and their derivatives) `company-dabbrev-code' will
+complete only symbols, not text in comments or strings. In other modes
+`company-dabbrev-code' will pass control to other backends
+\(e.g. `company-dabbrev'\). Value t means complete in all modes."
+ :type '(choice (repeat :tag "Some modes" (symbol :tag "Major mode"))
+ (const :tag "All modes" t)))
+
+(defcustom company-dabbrev-code-other-buffers t
+ "Determines whether `company-dabbrev-code' should search other buffers.
+If `all', search all other buffers, except the ignored ones. If t, search
+buffers with the same major mode. If `code', search all buffers with major
+modes in `company-dabbrev-code-modes', or derived from one of them. See
+also `company-dabbrev-code-time-limit'."
+ :type '(choice (const :tag "Off" nil)
+ (const :tag "Same major mode" t)
+ (const :tag "Code major modes" code)
+ (const :tag "All" all)))
+
+(defcustom company-dabbrev-code-time-limit .1
+ "Determines how long `company-dabbrev-code' should look for matches."
+ :type '(choice (const :tag "Off" nil)
+ (number :tag "Seconds")))
+
+(defcustom company-dabbrev-code-everywhere nil
+ "Non-nil to offer completions in comments and strings."
+ :type 'boolean)
+
+(defcustom company-dabbrev-code-ignore-case nil
+ "Non-nil to ignore case when collecting completion candidates."
+ :type 'boolean)
+
+(defun company-dabbrev-code--make-regexp (prefix)
+ (concat "\\_<" (if (equal prefix "")
+ "\\([a-zA-Z]\\|\\s_\\)"
+ (regexp-quote prefix))
+ "\\(\\sw\\|\\s_\\)*\\_>"))