]> code.delx.au - gnu-emacs-elpa/commitdiff
Make dabbrev and dabbrev-code more customizable
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 30 Jan 2014 05:08:35 +0000 (07:08 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 30 Jan 2014 05:52:12 +0000 (07:52 +0200)
#52

NEWS.md
company-dabbrev-code.el
company-dabbrev.el

diff --git a/NEWS.md b/NEWS.md
index 602c174618c0996f7bf4e4e8b8b4df63722fb097..99160548f6a30e252961c1c9215db14d291604be 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,9 @@
 # History of user-visible changes
 
+## Next
+
+* New user options controlling `company-dabbrev` and `company-dabbrev-code`.
+
 ## 2014-01-25 (0.6.14)
 
 * The tooltip front-end is rendered with scrollbar, controlled by the user
index e4c548ef02f046b7c6d2c4776849b15d1e1a637e..408d2b25b150bb772432fa4a681c1f6762f11ba5 100644 (file)
@@ -60,6 +60,14 @@ See also `company-dabbrev-code-time-limit'."
   :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 in completion candidates."
+  :type 'boolean)
+
 (defsubst company-dabbrev-code--make-regexp (prefix)
   (concat "\\_<" (if (equal prefix "")
                      "\\([a-zA-Z]\\|\\s_\\)"
@@ -76,13 +84,15 @@ comments or strings."
     (interactive (company-begin-backend 'company-dabbrev-code))
     (prefix (and (or (eq t company-dabbrev-code-modes)
                      (apply 'derived-mode-p company-dabbrev-code-modes))
-                 (not (company-in-string-or-comment))
+                 (or company-dabbrev-code-everywhere
+                     (not (company-in-string-or-comment)))
                  (or (company-grab-symbol) 'stop)))
     (candidates (let ((case-fold-search nil))
                   (company-dabbrev--search
                    (company-dabbrev-code--make-regexp arg)
                    company-dabbrev-code-time-limit
                    company-dabbrev-code-other-buffers t)))
+    (ignore-case company-dabbrev-code-ignore-case)
     (duplicates t)))
 
 (provide 'company-dabbrev-code)
index 4b1a9d8a82625913a40651f1b421fb4eeb72d3f1..afe60f2a957c2cced6d062f4b6948548edcd9545 100644 (file)
@@ -50,6 +50,9 @@ See also `company-dabbrev-time-limit'."
   "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'.")
+
 (defmacro company-dabrev--time-limit-while (test start limit &rest body)
   (declare (indent 3) (debug t))
   `(let ((company-time-limit-while-counter 0))
@@ -120,7 +123,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 'keep-prefix)
+    (ignore-case company-dabbrev-ignore-case)
     (duplicates t)))
 
 (provide 'company-dabbrev)