-;; notmuch-company.el --- Mail address completion for notmuch via company-mode -*- lexical-binding: t -*-
+;;; notmuch-company.el --- Mail address completion for notmuch via company-mode -*- lexical-binding: t -*-
;; Authors: Trevor Jim <tjim@mac.com>
;; Michal Sojka <sojkam1@fel.cvut.cz>
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(eval-when-compile (require 'cl))
+(require 'notmuch-lib)
(defvar notmuch-company-last-prefix nil)
(make-variable-buffer-local 'notmuch-company-last-prefix)
(defun notmuch-company-setup ()
(company-mode)
(make-local-variable 'company-backends)
- (setq company-backends '(notmuch-company)))
+ (setq company-backends '(notmuch-company))
+ ;; Disable automatic company completion unless an internal
+ ;; completion method is configured. Company completion (using
+ ;; internal completion) can still be accessed via standard company
+ ;; functions, e.g., company-complete.
+ (unless (eq notmuch-address-command 'internal)
+ (notmuch-setq-local company-idle-delay nil)))
;;;###autoload
(defun notmuch-company (command &optional arg &rest _ignore)
(lambda (callback)
;; First run quick asynchronous harvest based on what the user entered so far
(notmuch-address-harvest
- (format "to:%s*" arg) nil
+ arg nil
(lambda (_proc _event)
(funcall callback (notmuch-address-matching arg))
;; Then start the (potentially long-running) full asynchronous harvest if necessary
(provide 'notmuch-company)
+
+;;; notmuch-company.el ends here