[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb e0c3311 177/350: Fix parsing of suffixes in names
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb e0c3311 177/350: Fix parsing of suffixes in names |
Date: |
Mon, 14 Aug 2017 11:46:30 -0400 (EDT) |
branch: externals/ebdb
commit e0c3311517ac7a70cde7fecbac452e0e8c32f6ce
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Fix parsing of suffixes in names
* ebdb.el (ebdb-divide-name): This function wasn't actually returning
the suffix as a separate element.
(ebdb-parse): Catch the suffix element and store it in the correct
slot.
---
ebdb.el | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/ebdb.el b/ebdb.el
index 00db613..717f809 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -843,7 +843,7 @@ simple or complex name class."
:initarg :suffix
:type (or null string)
:custom (choice (const :tag "No suffix" nil)
- (string :tag "Suffic"))
+ (string :tag "Suffix"))
:initform nil)
;; What is an affix, actually?
(affix
@@ -927,15 +927,17 @@ first one."
(ebdb-parse class (ebdb-read-string "Name: " (when obj (ebdb-string obj)))
slots)))
(cl-defmethod ebdb-parse ((class (subclass ebdb-field-name-complex)) str
&optional slots)
- (let ((bits (ebdb-divide-name str)))
+ (pcase-let ((`(,surname ,given-names ,suffix)
+ (ebdb-divide-name str)))
(unless (plist-get slots :given-names)
(setq slots (plist-put slots :given-names
- (when (car bits)
- (list (car bits))))))
+ (when given-names
+ (split-string given-names nil t)))))
(unless (plist-get slots :surname)
(setq slots (plist-put slots :surname
- (when (cdr bits)
- (cdr bits)))))
+ (or surname ""))))
+ (unless (plist-get slots :suffix)
+ (setq slots (plist-put slots :suffix suffix)))
(cl-call-next-method class str slots)))
;;; Role fields.
@@ -4277,14 +4279,15 @@ also be one of the special symbols below.
;;; Parsing other things
(defun ebdb-divide-name (string)
- "Divide STRING into a first name and a last name.
-Case is ignored. Return name as (FIRST . LAST).
-LAST is always a string (possibly empty). FIRST may be nil."
+ "Divide STRING into its component parts.
+Case is ignored. Return name as a list of (LAST FIRST SUFFIX).
+LAST is always a string (possibly empty). FIRST and SUFFIX may
+be nil."
(let ((case-fold-search t)
first suffix)
;; Separate a suffix.
(if (string-match ebdb-lastname-suffix-re string)
- (setq suffix (concat " " (match-string 1 string))
+ (setq suffix (match-string 1 string)
string (substring string 0 (match-beginning 0))))
(cond ((string-match "\\`\\(.+\\),[ \t\n]*\\(.+\\)\\'" string)
;; If STRING contains a comma, this probably means that STRING
@@ -4295,8 +4298,10 @@ LAST is always a string (possibly empty). FIRST may be
nil."
(setq first (and (not (zerop (match-beginning 0)))
(substring string 0 (match-beginning 0)))
string (match-string 1 string))))
- (cons (and first (ebdb-string-trim first))
- (ebdb-string-trim (concat string suffix)))))
+ (delq nil
+ (list (ebdb-string-trim string)
+ (and first (ebdb-string-trim first))
+ suffix))))
(defun ebdb-parse-postcode (string)
"Check whether STRING is a legal postcode.
- [elpa] externals/ebdb eea0abf 165/350: VCard export is good enough, (continued)
- [elpa] externals/ebdb eea0abf 165/350: VCard export is good enough, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 64b5e43 170/350: Fix autoloads in ebdb.el, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a968dd3 143/350: First actually-working version of snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a8e0221 179/350: Missing local variable binding, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e71548d 172/350: Allow for characters before mail addresses when snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 14b03b5 186/350: Fix menu entry of ebdb-create-record, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 10c1e76 185/350: When replying to messages, start with a populated EBDB buffer, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b9e6034 187/350: Increase base field indentation in *EBDB* buffers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a19ff0a 168/350: Simplify pop-up window splitting, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4c6b6f5 190/350: Protect gnus stuff behind eval-after-load, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e0c3311 177/350: Fix parsing of suffixes in names,
Eric Abrahamsen <=
- [elpa] externals/ebdb 429cdb0 183/350: Add safety check to ebdb-undisplay-records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 744c829 182/350: Clear *EBDB-Message* buffers when composing new message, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8ebba5d 178/350: Very basic test setup, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 927c2ac 188/350: Be more careful about name formatting, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e52e17e 192/350: Pop up EBDB buffer when using company to complete, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb fc1a480 191/350: Fix ebdb-delete-redundant-mails, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 61dcb8c 148/350: Re-initialize database records after reloading, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8694194 150/350: Use string-match-p for searching on Org tags, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e4c0442 162/350: Fix up actions and EBDB buffer menus, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 09e421f 156/350: Rework anniversary/diary integration, Eric Abrahamsen, 2017/08/14