emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Feng Shu <tumashu@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [patch] [3update] Add functions, Insert a exist contact name at point
Date: Tue, 04 Jun 2013 17:41:53 +0800	[thread overview]
Message-ID: <87li6q1ace.fsf@news.tumashu-localhost.org> (raw)
In-Reply-To: <87txle1rkl.fsf_-_@news.tumashu-localhost.org> (Feng Shu's message of "Tue, 04 Jun 2013 11:29:46 +0800")

[-- Attachment #1: Type: text/plain, Size: 21 bytes --]



This is 4 update:


[-- Attachment #2: 0001-Insert-a-exist-contact-name-s-at-point.patch --]
[-- Type: text/x-diff, Size: 2781 bytes --]

From 326642e8cdcfcb507d82a2508e1cde91e9236540 Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@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..70a78e1 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  (symbol-name (quote ,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


  reply	other threads:[~2013-06-04  9:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03 16:49 [patch] [2update] Add functions, which can quickly insert org-contacts template(s) in current buffer Feng Shu
2013-06-03 23:07 ` Feng Shu
2013-06-04  3:29   ` [patch] [3update] Add functions, Insert a exist contact name at point Feng Shu
2013-06-04  9:41     ` Feng Shu [this message]
2013-06-04  9:55 ` [patch] [2update] Add functions, which can quickly insert org-contacts template(s) in current buffer Bastien
2013-06-04 11:17   ` Feng Shu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87li6q1ace.fsf@news.tumashu-localhost.org \
    --to=tumashu@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).