X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/d587bd019e04f4bda5d6d7cb08f331759d88dbb8..dc4927b3509ae37ceec3993bacd28b7b7cfa19b3:/company-dabbrev.el diff --git a/company-dabbrev.el b/company-dabbrev.el index 3a533d5b6..1ece89787 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))))