branch: externals/ebdb commit 8ca9902869b6a3e3bb4d0d2b45b88f476146b7b6 Author: Eric Abrahamsen <e...@ericabrahamsen.net> Commit: Eric Abrahamsen <e...@ericabrahamsen.net>
Fix mis-parsing of surname prefixes Fixes #106 * ebdb.el (ebdb-divide-name): The prefix should only be found at the beginning of the string, separated by a space from the actual surname. --- ebdb-test.el | 5 +++++ ebdb.el | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ebdb-test.el b/ebdb-test.el index ad9c9c4710..ac73d37c5c 100644 --- a/ebdb-test.el +++ b/ebdb-test.el @@ -358,6 +358,11 @@ If it doesn't exist, raise `ebdb-related-unfound'." (ebdb-parse 'ebdb-field-name-complex "MURAKAMI Haruki") 'surname) "Murakami")) + (should (equal + (slot-value + (ebdb-parse 'ebdb-field-name-complex "John Reddemann") + 'surname) + "Reddemann")) (should (equal (slot-value (ebdb-parse 'ebdb-field-name-complex "Fintan O'Toole") diff --git a/ebdb.el b/ebdb.el index 9634fc3c48..065b30931c 100644 --- a/ebdb.el +++ b/ebdb.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2016-2022 Free Software Foundation, Inc. -;; Version: 0.8.14 +;; Version: 0.8.15 ;; Package-Requires: ((emacs "25.1") (seq "2.15")) ;; Maintainer: Eric Abrahamsen <e...@ericabrahamsen.net> @@ -5464,7 +5464,7 @@ usage) to represent the surname." (substring string 0 (match-beginning 0))) string (match-string 1 string))))) (setq given (when given (split-string given nil t))) - (cond ((string-match (regexp-opt ebdb-lastname-prefixes) string) + (cond ((string-match (concat "\\`" (regexp-opt ebdb-lastname-prefixes) " ") string) (setq prefix (substring string 0 (match-end 0)) string (substring string (match-end 0)))) ((and (>= (length given) 2)