From: Feng Shu <tumashu@gmail.com>
To: orgmode <emacs-orgmode@gnu.org>
Subject: [patch] [2update] Add functions, which can quickly insert org-contacts template(s) in current buffer
Date: Tue, 04 Jun 2013 00:49:04 +0800 [thread overview]
Message-ID: <87vc5vm96n.fsf@news.tumashu-localhost.org> (raw)
[-- Attachment #1: 0001-Quickly-insert-a-template-s-in-current-buffer.patch --]
[-- Type: text/x-diff, Size: 3418 bytes --]
From 938c2d0e3eb04faf2fd9708a382da9bac43d0bf9 Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
Date: Mon, 3 Jun 2013 23:17:57 +0800
Subject: [PATCH] Quickly insert (a) template(s) in current buffer
* contrib/lisp/org-contacts.el (org-contacts-build-template-with-exist-contact):Build
a contact template with exist contact, It is useful when you want to update exist contact(s).
(org-contacts-build-template-with-string): Build contact template with
a string, It is useful when you want to add a new contact.
(org-contacts-insert-template): Insert contact template(s) at point,
the template(s) will be built with the input string and exist contacts
informations.
Add a new function, which can quickly insert (a) contact templete(s),
the templete(s) are built using user's input and the exist contacts information.
---
contrib/lisp/org-contacts.el | 48 ++++++++++++++++++++++++++++++++++++++++++
1 个文件被修改,插入 48 行(+)
diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index ffd17a1..78e7fef 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -951,6 +951,54 @@ is created and the VCard is written into that buffer."
(current-buffer)
(progn (save-buffer) (kill-buffer)))))
+(defun org-contacts-build-template-with-exist-contact (contact)
+ "Build a contact template with exist contact, It is useful
+when you want to update exist contact(s)."
+ (let* ((properties (caddr contact))
+ (name (org-contacts-vcard-escape (car contact)))
+ (n (org-contacts-vcard-encode-name name))
+ (alias (cdr (assoc-string org-contacts-alias-property properties))))
+ (concat "** " name "\n"
+ ":PROPERTIES:\n"
+ ":" org-contacts-alias-property ": " alias "\n"
+ ":" org-contacts-note-property ":\n"
+ ":" org-contacts-email-property ":\n"
+ ":" org-contacts-tel-property ":\n"
+ ":" org-contacts-ignore-property ":\n"
+ ":END:\n\n")))
+
+(defun org-contacts-build-template-with-string (string)
+ "Build contact template with a string, It is useful
+when you want to add a new contact."
+ (concat "** " string "\n"
+ ":PROPERTIES:\n"
+ ":" org-contacts-alias-property ": " string "\n"
+ ":" org-contacts-note-property ":\n"
+ ":" org-contacts-email-property ":\n"
+ ":" org-contacts-tel-property ":\n"
+ ":" org-contacts-ignore-property ":\n"
+ ":END:\n\n"))
+
+(defun org-contacts-insert-template (string)
+ "Insert contact template(s) at point, the template(s) will be built
+with the input string and exist contacts informations."
+ (interactive (list (read-string "Name or Alias: ")))
+ (let ((point (point))
+ (contact-list
+ (delete-dups (nconc
+ (org-contacts-filter
+ nil nil
+ (cons org-contacts-alias-property string))
+ (org-contacts-filter string)))))
+ (current-buffer)
+ (let ((inhibit-read-only t)))
+ (when (fboundp 'set-buffer-file-coding-system)
+ (set-buffer-file-coding-system coding-system-for-write))
+ (loop for contact in contact-list
+ do (insert (org-contacts-build-template-with-exist-contact contact)))
+ (if contact-list nil (insert (org-contacts-build-template-with-string string)))
+ (goto-char point)))
+
(defun org-contacts-show-map (&optional name)
"Show contacts on a map.
Requires google-maps-el."
--
1.7.10.4
[-- Attachment #2: Type: text/plain, Size: 5 bytes --]
--
next reply other threads:[~2013-06-03 16:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-03 16:49 Feng Shu [this message]
2013-06-03 23:07 ` [patch] [2update] Add functions, which can quickly insert org-contacts template(s) in current buffer 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
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=87vc5vm96n.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).