From 06055532dbadbfbcb620378eeec0c5e3c8ee8c0d Mon Sep 17 00:00:00 2001 From: Feng Shu Date: Mon, 3 Jun 2013 23:17:57 +0800 Subject: [PATCH] Insert (a) exist contact name(s) at point * org-contacts.el (org-contacts-get-exist-contact-name-list): New function, which can get exist contact name(s) matched 'string, return a list. (org-contacts-get-exist-contact-name-string): New macro, get exist contact name(s) matched 'string, return names string. (org-contacts-insert-contact-name): New function, which can insert (a) exist contact name(s) matched user's input at point. Add new functions, which can insert (a) exist contact name(s) at point, which is matched user's input. --- contrib/lisp/org-contacts.el | 36 ++++++++++++++++++++++++++++++++++++ 1 个文件被修改,插入 36 行(+) diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el index 5d63fcc..e3f0729 100644 --- a/contrib/lisp/org-contacts.el +++ b/contrib/lisp/org-contacts.el @@ -967,6 +967,42 @@ is created and the VCard is written into that buffer." (current-buffer) (progn (save-buffer) (kill-buffer))))) +(defun org-contacts-get-exist-contact-name-list (string) + "Get exist contact name(s) matched 'string, return a list." + (let ((contact-list (nconc + (org-contacts-filter + nil nil + (cons org-contacts-alias-property string)) + (org-contacts-filter string)))) + (setq result-name-list + (delete-dups + (loop for contact in contact-list + collect + (substring-no-properties + ((lambda (contact) + (let* ((name + (org-contacts-vcard-escape (car contact)))) name)) + contact)))))) + (if result-name-list result-name-list (list string))) + +(defmacro org-contacts-get-exist-contact-name-string (string) + "Get exist contact name(s) matched 'string, return names string." + (if (stringp string) + `(mapconcat 'identity (org-contacts-get-exist-contact-name-list ,string) " ") + `(mapconcat 'identity (org-contacts-get-exist-contact-name-list ,(format "%s" string)) " "))) + +(defun org-contacts-insert-contact-name (string) + "At point insert (a) exist contact name(s) matched 'input." + (interactive (list (read-string "Contact Alias or Name: "))) + (current-buffer) + (let ((inhibit-read-only t))) + (when (fboundp 'set-buffer-file-coding-system) + (set-buffer-file-coding-system coding-system-for-write)) + (let ((name-list (org-contacts-get-exist-contact-name-list string))) + (while name-list + (insert (concat (car name-list) " ")) + (setq name-list (cdr name-list))))) + (defun org-contacts-show-map (&optional name) "Show contacts on a map. Requires google-maps-el." -- 1.7.10.4