emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master dc4927b 158/173: Allow company-dabbrev-ignore-buffers to b


From: Dmitry Gutov
Subject: [elpa] master dc4927b 158/173: Allow company-dabbrev-ignore-buffers to be a function
Date: Thu, 23 Jun 2016 00:28:47 +0000 (UTC)

branch: master
commit dc4927b3509ae37ceec3993bacd28b7b7cfa19b3
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Allow company-dabbrev-ignore-buffers to be a function
    
    Closes #504
---
 NEWS.md            |    1 +
 company-dabbrev.el |   24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 841a62b..6612ca2 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
 
 ## Next
 
+* The value of `company-dabbrev-ignore-buffers` can also be a function.
 * `company-files` has been moved to right after `company-capf` in
   `company-backends`
   ([#463](https://github.com/company-mode/company-mode/issues/463)).
diff --git a/company-dabbrev.el b/company-dabbrev.el
index 3a533d5..1ece897 100644
--- a/company-dabbrev.el
+++ b/company-dabbrev.el
@@ -41,8 +41,10 @@ buffers with the same major mode.  See also 
`company-dabbrev-time-limit'."
                  (const :tag "All" all)))
 
 (defcustom company-dabbrev-ignore-buffers "\\`[ *]"
-  "Regexp matching the names of buffers to ignore."
-  :type 'regexp)
+  "Regexp matching the names of buffers to ignore.
+Or a function that returns non-nil for such buffers."
+  :type '(choice (regexp :tag "Regexp")
+                 (function :tag "Predicate")))
 
 (defcustom company-dabbrev-time-limit .1
   "Determines how many seconds `company-dabbrev' should look for matches."
@@ -137,14 +139,16 @@ This variable affects both `company-dabbrev' and 
`company-dabbrev-code'."
                                                   ignore-comments)))
     (when other-buffer-modes
       (cl-dolist (buffer (delq (current-buffer) (buffer-list)))
-        (with-current-buffer buffer
-          (when (if (eq other-buffer-modes 'all)
-                    (not (string-match-p company-dabbrev-ignore-buffers
-                                         (buffer-name)))
-                  (apply #'derived-mode-p other-buffer-modes))
-            (setq symbols
-                  (company-dabbrev--search-buffer regexp nil symbols start
-                                                  limit ignore-comments))))
+        (unless (if (stringp company-dabbrev-ignore-buffers)
+                    (string-match-p company-dabbrev-ignore-buffers
+                                    (buffer-name buffer))
+                  (funcall company-dabbrev-ignore-buffers buffer))
+          (with-current-buffer buffer
+            (when (or (eq other-buffer-modes 'all)
+                      (apply #'derived-mode-p other-buffer-modes))
+              (setq symbols
+                    (company-dabbrev--search-buffer regexp nil symbols start
+                                                    limit ignore-comments)))))
         (and limit
              (> (float-time (time-since start)) limit)
              (cl-return))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]