From 33d2acd2a8fa3ac7e6cb5f712baa8507662cf2c8 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 1 Apr 2013 09:04:45 +0400 Subject: [PATCH] company-manual-begin: Clear `explicit-action` when no candidates --- NEWS.md | 2 +- company-tests.el | 9 +++++++++ company.el | 7 +++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4a46891c3..b6000b72f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # History of user-visible changes -## Next +## 2013-04-01 (0.6.6) * `company-elisp` doesn't offer completions when typing the name and the arguments of a new function or macro definition, allowing to fall back to diff --git a/company-tests.el b/company-tests.el index 811e4cc2e..33437d850 100644 --- a/company-tests.el +++ b/company-tests.el @@ -148,6 +148,15 @@ (company-call 'self-insert-command 1)) (should (string= "ab " (buffer-string)))))) +(ert-deftest company-clears-explicit-action-when-no-matches () + (with-temp-buffer + (company-mode) + (let (company-frontends + company-backends) + (company-call 'manual-begin) ;; fails + (should (null company-candidates)) + (should (null (company-explicit-action-p)))))) + (ert-deftest company-pseudo-tooltip-does-not-get-displaced () (with-temp-buffer (save-window-excursion diff --git a/company.el b/company.el index 35b07809f..13c61eecf 100644 --- a/company.el +++ b/company.el @@ -4,7 +4,7 @@ ;; Author: Nikolaj Schumacher ;; Maintainer: Dmitry Gutov -;; Version: 0.6.5 +;; Version: 0.6.6 ;; Keywords: abbrev, convenience, matching ;; URL: http://company-mode.github.com/ ;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x, GNU Emacs 24.x @@ -895,7 +895,10 @@ can retrieve meta-data for them." (defun company-manual-begin () (interactive) (setq company--explicit-action t) - (company-auto-begin)) + (unwind-protect + (company-auto-begin) + (unless company-candidates + (setq company--explicit-action nil)))) (defun company-other-backend (&optional backward) (interactive (list current-prefix-arg)) -- 2.39.2