[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb e5bdee2 278/350: Rework ebdb-mail-yank
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb e5bdee2 278/350: Rework ebdb-mail-yank |
Date: |
Mon, 14 Aug 2017 11:46:53 -0400 (EDT) |
branch: externals/ebdb
commit e5bdee27647b1db0bcca9a240b59fcfb8332d6ef
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Rework ebdb-mail-yank
* ebdb-com.el (ebdb-mail-yank): It still isn't bound to a key, but now
it works in both message-mode and mail-mode.
---
ebdb-com.el | 58 ++++++++++++++++++++--------------------------------------
1 file changed, 20 insertions(+), 38 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 2be9e91..858700b 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -2098,49 +2098,31 @@ for `ebdb-field-action'."
(unless (string= "" to)
(ebdb-compose-mail to subject))))
-;; Is there better way to yank selected mail addresses from the EBDB
-;; buffer into a message buffer? We need some kind of a link between
-;; the EBDB buffer and the message buffer, where the mail addresses
-;; are supposed to go. Then we could browse the EBDB buffer and copy
-;; selected mail addresses from the EBDB buffer into a message buffer.
-
(defun ebdb-mail-yank ()
"CC the people displayed in the *EBDB* buffer on this mail message.
The primary mail of each of the records currently listed in the
*EBDB* buffer will be appended to the CC: field of the current buffer."
+ ;; Consider making the guts of this into a method that lives in the
+ ;; different message-sending MUA packages. All the `derived-mode-p'
+ ;; stuff is a sign...
+
+ ;; Also, collect the addresses that are already in the To: and Cc:
+ ;; headers, and make sure we don't insert duplicates.
(interactive)
- (let ((addresses (with-current-buffer ebdb-buffer-name
- (delq nil
- (mapcar (lambda (x)
- (if (ebdb-record-mail (car x))
- (ebdb-dwim-mail (car x))))
- ebdb-records))))
- (case-fold-search t))
- (goto-char (point-min))
- (if (re-search-forward "^CC:[ \t]*" nil t)
- ;; We have a CC field. Move to the end of it, inserting a comma
- ;; if there are already addresses present.
- (unless (eolp)
- (end-of-line)
- (while (looking-at "\n[ \t]")
- (forward-char) (end-of-line))
- (insert ",\n")
- (indent-relative))
- ;; Otherwise, if there is an empty To: field, move to the end of it.
- (unless (and (re-search-forward "^To:[ \t]*" nil t)
- (eolp))
- ;; Otherwise, insert an empty CC: field.
- (end-of-line)
- (while (looking-at "\n[ \t]")
- (forward-char) (end-of-line))
- (insert "\nCC:")
- (indent-relative)))
- ;; Now insert each of the addresses on its own line.
- (while addresses
- (insert (car addresses))
- (when (cdr addresses) (insert ",\n") (indent-relative))
- (setq addresses (cdr addresses)))))
-(define-obsolete-function-alias 'ebdb-yank-addresses 'ebdb-mail-yank)
+ (let ((addresses
+ (with-current-buffer (ebdb-make-buffer-name)
+ (delq nil
+ (mapcar (lambda (x)
+ (when-let ((mail (car (ebdb-record-mail (car x)
t))))
+ (ebdb-dwim-mail (car x) mail)))
+ ebdb-records)))))
+ (if (derived-mode-p 'message-mode 'mail-mode)
+ (when addresses
+ (if (derived-mode-p 'message-mode)
+ (message-goto-cc)
+ (mail-cc))
+ (insert (mapconcat #'identity addresses ",\n")))
+ (message "Not in a mail composition buffer"))))
;;; completion
- [elpa] externals/ebdb fb4d5d5 255/350: Migration should guard against unparseable emails, (continued)
- [elpa] externals/ebdb fb4d5d5 255/350: Migration should guard against unparseable emails, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb aa15250 252/350: Change newline approach in vCard handling, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 0120729 240/350: Add vcard unescaping, and some vcard tests, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6f8d59b 254/350: Fix record citation, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 3106b45 256/350: Require ebdb-format in ebdb-vcard, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7549366 259/350: New method: ebdb-db-load-records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b37356a 270/350: Fix docstring of ebdb-create-record, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5135645 260/350: Split out ebdb-notice-record and ebdb-notice-field methods, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 71a93f5 268/350: Put a load protection in ebdb-mua-update-records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb cacb97b 271/350: Fix bug in MUA record creation, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e5bdee2 278/350: Rework ebdb-mail-yank,
Eric Abrahamsen <=
- [elpa] externals/ebdb 8dd1600 273/350: Change type of anniversary field dates, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 57b2514 276/350: Use ebdb-with-record-edits in more places, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f44a797 286/350: New function ebdb-mua-in-ebdb-buffer, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4ce353e 237/350: Migrate more search routines to the ebdb-search-display thing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7040cad 247/350: Expand ebdb-helm to complete on mails as well, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a6bc423 249/350: Remove unused customization groups, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4ded53d 250/350: All vCard lines should be delimited with CRLF, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a776d37 248/350: Don't use copy-sequence plus add-text-properties on strings, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 96b113d 251/350: New functions for folding/unfolding long vCard lines, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b52cdc0 265/350: Record-insert|delete-field methods can find their own slots, Eric Abrahamsen, 2017/08/14