Feng Shu tuma...@gmail.com writes:
Feng Shu tuma...@gmail.com writes:
I will change this patch again, hard coding a templates in functions
is not a good way , maybe it is a complex method to solve a simpe things.
This is the 3rd patch, which has been changed significantly,
The function will be useful when used in org-capture,
I want it can be included into master when it mature!
But there are some problems, I think it's org-capture's bug or limit:
1. works:
#+begin_example
(c Contacts entry (file ~/org/i-contacts.org)
* %(org-contacts-get-exist-contact-name-string fengshu))
#+end_example
2. doesn't work
#+begin_example
(c Contacts entry (file ~/org/i-contacts.org)
* %(org-contacts-get-exist-contact-name-string %^{prompt))
#+end_example
From 06055532dbadbfbcb620378eeec0c5e3c8ee8c0d Mon Sep 17 00:00:00 2001
From: Feng Shu tuma...@gmail.com
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
--