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

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

[elpa] master e0d2bf0 157/173: company-bbdb: Use full names as prefix


From: Dmitry Gutov
Subject: [elpa] master e0d2bf0 157/173: company-bbdb: Use full names as prefix
Date: Thu, 23 Jun 2016 00:28:47 +0000 (UTC)

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

    company-bbdb: Use full names as prefix
    
    Fixing regression from #453.
---
 company-bbdb.el    |    2 +-
 test/bbdb-tests.el |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/company-bbdb.el b/company-bbdb.el
index 36307d0..872e1fc 100644
--- a/company-bbdb.el
+++ b/company-bbdb.el
@@ -50,7 +50,7 @@
     (interactive (company-begin-backend 'company-bbdb))
     (prefix (and (memq major-mode company-bbdb-modes)
                  (featurep 'bbdb-com)
-                 (looking-back "^\\(To\\|Cc\\|Bcc\\): *.*?\\([^,; ]*\\)"
+                 (looking-back "^\\(To\\|Cc\\|Bcc\\): *.*? *\\([^,;]*\\)"
                                (line-beginning-position))
                  (match-string-no-properties 2)))
     (candidates (company-bbdb--candidates arg))
diff --git a/test/bbdb-tests.el b/test/bbdb-tests.el
new file mode 100644
index 0000000..b1f21b9
--- /dev/null
+++ b/test/bbdb-tests.el
@@ -0,0 +1,46 @@
+;;; bbdb-tests.el --- company-mode tests  -*- lexical-binding: t -*-
+
+;; Copyright (C) 2016  Free Software Foundation, Inc.
+
+;; Author: Dmitry Gutov
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+(require 'company-tests)
+(require 'company-bbdb)
+
+(provide 'bbdb-com)
+
+(ert-deftest company-bbdb-prefix-looks-in-header-value ()
+  (with-temp-buffer
+    (insert "To: J")
+    (setq-local major-mode 'message-mode)
+    (should (equal (company-bbdb 'prefix)
+                   "J"))))
+
+(ert-deftest company-bbdb-prefix-includes-space ()
+  (with-temp-buffer
+    (insert "To: John Sm")
+    (setq-local major-mode 'message-mode)
+    (should (equal (company-bbdb 'prefix)
+                   "John Sm"))))
+
+(ert-deftest company-bbdb-prefix-begins-after-comma-or-semi ()
+  (with-temp-buffer
+    (insert "To: John Smythe <address@hidden>, Jess C")
+    (setq-local major-mode 'message-mode)
+    (should (equal (company-bbdb 'prefix)
+                   "Jess C"))))



reply via email to

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