all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* phone links...
@ 2013-03-29 23:23 Robert Goldman
  2013-03-30  9:12 ` Karl Voit
                   ` (4 more replies)
  0 siblings, 5 replies; 44+ messages in thread
From: Robert Goldman @ 2013-03-29 23:23 UTC (permalink / raw)
  To: Org Mode

Since I keep my todo tasks in my org files, and some of them involve
phone calls, I made a rudimentary handler for "phone:" links that I
would like to contribute.  It features a link declaration (in
org-phone.el) and an ancillary script (currently only working on Mac OS
X, but should be translatable to other platforms) that can be used to
place skype calls to the phone numbers.

One thing it does not do is support interactive entry of phone numbers.

The two files are below, in hopes of getting suggestions for improvement
so that someday this could find itself into contrib/.

Cheers,
r

--------------------org-phone.el--------------------
;;;---------------------------------------------------------------------------
;;; org-phone.el
;;; Add support for "phone:" links to phone numbers.
;;; Optional support for calling them with skype
;;;---------------------------------------------------------------------------

;;; Copyright (C) 2013 Free Software Foundation, Inc.

;; Author: Robert P. Goldman <rpgoldman at sift dot net>
;; Homepage: http://orgmode.org
;; Version: 0.01

;; This file is not yet part of GNU Emacs.
(require 'org)

(org-add-link-type "phone" 'org-phone-open)
;; not sure whether we need/want this yet...
;;(add-hook 'org-store-link-functions 'org-phone-store-link)

(defcustom org-phone-function 'skype-call
  "The Emacs function to be used to call a phone number."
  :group 'org-link
  :type 'symbol)

(defcustom org-skype-command "skype-call"
  "The executable command to be used to call a phone number.
This should be a script that starts the call and returns: it
should not block."
  :group 'org-link
  :type 'string)


(defun org-phone-open (phone-number)
  "Phone the number PHONE-NUMBER.
PHONE-NUMBER should be a string for a PSTN phone number."
  (funcall org-phone-function phone-number))

(defun skype-call (phone-number)
  (shell-command (format "%s %s"
			 org-skype-command
			 phone-number)))



;; (defun org-phone-store-link ()
;;   "Store a link to a phone number."
;;     ;; This is a man page, we do make this link
;;     (let* ((page (org-man-get-page-name))
;; 	   (link (concat "man:" page))
;; 	   (description (format "Manpage for %s" page)))
;;       (org-store-link-props
;;        :type "man"
;;        :link link
;;        :description description))))


(provide 'org-phone)

--------------------skype-call--------------------
#!/bin/sh

command="CALL $1"

osascript -e 'tell application "Skype"' \
          -e "send command \"${command}\" script name \"skype-call\"" \
          -e 'end tell'

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-03-29 23:23 phone links Robert Goldman
@ 2013-03-30  9:12 ` Karl Voit
  2013-04-01 13:30 ` Robert Goldman
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 44+ messages in thread
From: Karl Voit @ 2013-03-30  9:12 UTC (permalink / raw)
  To: emacs-orgmode

* Robert Goldman <rpgoldman@sift.info> wrote:
> Since I keep my todo tasks in my org files, and some of them involve
> phone calls, I made a rudimentary handler for "phone:" links that I
> would like to contribute.  It features a link declaration (in
> org-phone.el) and an ancillary script (currently only working on Mac OS
> X, but should be translatable to other platforms) that can be used to
> place skype calls to the phone numbers.
>
> One thing it does not do is support interactive entry of phone numbers.

Cool stuff! Thank you!

I want to add a pointer (not particularly for you) here to Memacs
(see signature) which is able to automatically add Android phone
calls (and more) to your Agenda.

Of course, anyone can add a Memacs module for other phone call logs
and even Skype call logs (if there are any which can be parsed
easily).

-- 
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-03-29 23:23 phone links Robert Goldman
  2013-03-30  9:12 ` Karl Voit
@ 2013-04-01 13:30 ` Robert Goldman
  2013-04-03 14:52 ` Michael Strey
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 44+ messages in thread
From: Robert Goldman @ 2013-04-01 13:30 UTC (permalink / raw)
  To: Org Mode

On 3/29/13 Mar 29 -6:23 PM, Robert Goldman wrote:
> Since I keep my todo tasks in my org files, and some of them involve
> phone calls, I made a rudimentary handler for "phone:" links that I
> would like to contribute.  It features a link declaration (in
> org-phone.el) and an ancillary script (currently only working on Mac OS
> X, but should be translatable to other platforms) that can be used to
> place skype calls to the phone numbers.
> 
> One thing it does not do is support interactive entry of phone numbers.

Looks like the Right Thing here is to add a definition for an
org-phone-complete-link function.  I didn't read the manual carefully
enough....

I'll see if I can whip something up, perhaps something that would use a
contacts database.

cheers,
r

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-03-29 23:23 phone links Robert Goldman
  2013-03-30  9:12 ` Karl Voit
  2013-04-01 13:30 ` Robert Goldman
@ 2013-04-03 14:52 ` Michael Strey
  2013-04-03 15:05   ` Robert Goldman
  2013-04-04 12:15 ` Bastien
  2013-04-10 14:17 ` Michael Strey
  4 siblings, 1 reply; 44+ messages in thread
From: Michael Strey @ 2013-04-03 14:52 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert Goldman

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

This gives me the opportunitie to publish my own attempt to implement
telephone functionality into org.  I'm using Linphone
(http://www.linphone.org/) instead of Skype.

Best regards
-- 
Michael Strey 
www.strey.biz

[-- Attachment #2: org-dial.el --]
[-- Type: text/plain, Size: 1893 bytes --]

;;; org-dial.el --- Provide org links to dial with the softphone
;;; application linphone

;; Copyright (C) 2011  Michael Strey

;; Author: Michael Strey <mstrey@strey.de>
;; Keywords: dial, phone, softphone, contacts, hypermedia

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distaributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; `org-dial.el' defines the new link type `dial' for telephone
;; numbers in contacts (refer to org-contacts). Calling this link type
;; leads to the execution of a linphone command dialing this number.

;;; Code:

(require 'org)

;; org link functions
;; dial link
(org-add-link-type "tel" 'org-dial)

(defcustom org-dial-program "linphonecsh dial "
  "Name of the softphone executable used to dial a phone number in a `tel:' link."
  :type '(string)
  :group 'org)

(defun org-dial (phonenumber)
  "Dial the phone number. The variable phonenumber should contain only numbers, whitespaces, backslash and maybe a `+' at the beginning."
  ;; remove whitespaces from phonenumber
  (shell-command (concat org-dial-program (trim-phone-number phonenumber))))

(defun trim-phone-number (phonenumber)
  "Remove whitespaces from a telephone number"
  (setq trimmed_phonenumber
	(mapconcat 'identity
		   (delete "(0)" (split-string phonenumber "[ /-]")) "")))

(provide 'org-dial)

;;; org-dial.el ends here

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-03 14:52 ` Michael Strey
@ 2013-04-03 15:05   ` Robert Goldman
  2013-04-04  8:26     ` Michael Strey
  0 siblings, 1 reply; 44+ messages in thread
From: Robert Goldman @ 2013-04-03 15:05 UTC (permalink / raw)
  To: emacs-orgmode, Robert Goldman

On 4/3/13 Apr 3 -9:52 AM, Michael Strey wrote:
> This gives me the opportunitie to publish my own attempt to implement
> telephone functionality into org.  I'm using Linphone
> (http://www.linphone.org/) instead of Skype.

Thanks!  I am folding the linphone code in to make org-phone more generic.  

Question: why the removal of "(0)"?  For international calls?  Why "(0)" only,
instead of any 0 prefix?

Also, do you ever want to remove it anywhere but as a prefix?  
If so, maybe DELETE is the wrong function call.

Current draft:

;;;---------------------------------------------------------------------------
;;; org-phone.el
;;; Add support for "phone:" links to phone numbers.
;;; Optional support for calling them with skype
;;;---------------------------------------------------------------------------

;;; Copyright (C) 2013 Free Software Foundation, Inc.

;; Author: Robert P. Goldman <rpgoldman at sift dot net>
;; Homepage: http://orgmode.org
;; Version: 0.02

;; This file is not yet part of GNU Emacs.
(require 'org)

(org-add-link-type "phone" 'org-phone-open)
;; not sure whether we need/want this yet...
;;(add-hook 'org-store-link-functions 'org-phone-store-link)

(defcustom org-phone-function 'org-phone-call
  "The Emacs function to be used to call a phone number.
By default, a simple function that uses shell-command to 
apply org-phone-call-command (qv.) to the phone number."
  :group 'org-link
  :type 'symbol)

(defcustom org-phone-call-command "skype-call"
  "The executable command to be used to call a phone number.
This should be a script that starts the call and returns: it
should not block."
  :group 'org-link
  :type 'string)


(defun org-phone-open (phone-number)
  "Phone the number PHONE-NUMBER.
PHONE-NUMBER should be a string for a PSTN phone number."
  (funcall org-phone-function phone-number))

(defun org-phone-call (phone-number)
  (shell-command (format "%s %s"
			 org-phone-call-command
			 phone-number)))
  
(defun trim-phone-number (phone-number)
  "Remove whitespaces from a telephone number"
  (mapconcat 'identity
	     (delete "(0)" (split-string phone-number "[ /-]")) ""))
  

;; (defun org-phone-store-link ()
;;   "Store a link to a phone number."
;;     ;; This is a man page, we do make this link
;;     (let* ((page (org-man-get-page-name))
;; 	   (link (concat "man:" page))
;; 	   (description (format "Manpage for %s" page)))
;;       (org-store-link-props
;;        :type "man"
;;        :link link
;;        :description description))))


(provide 'org-phone)

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-03 15:05   ` Robert Goldman
@ 2013-04-04  8:26     ` Michael Strey
  2013-04-04 13:55       ` Michael Strey
  0 siblings, 1 reply; 44+ messages in thread
From: Michael Strey @ 2013-04-04  8:26 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert Goldman

Hi Robert,

On Wed, Apr 03, 2013 at 10:05:57AM -0500, Robert Goldman wrote:
> On 4/3/13 Apr 3 -9:52 AM, Michael Strey wrote:
> > This gives me the opportunitie to publish my own attempt to implement
> > telephone functionality into org.  I'm using Linphone
> > (http://www.linphone.org/) instead of Skype.
> 
> Thanks!  I am folding the linphone code in to make org-phone more generic.  

Great!

> Question: why the removal of "(0)"?  For international calls?  Why "(0)" only,
> instead of any 0 prefix?
> 
> Also, do you ever want to remove it anywhere but as a prefix?  
> If so, maybe DELETE is the wrong function call.

Linphone requires the numbers in form 0033456833 or +33456833 respectively.

Usually my phone links look like [[tel:+49 351 4129535]]; but since I
imported data sets from a larger contact data base that had evolved over
time, I ended up with stuff like this in my data base:
1. [[tel:0033 (0) 4568-33]]
2. [[tel:+49 (0)3 8899 66]]
3. [[tel:0351 41295-35]]
4. [[tel:0351/4129535]]
5. [[tel:(0351) 412 95-35]]

My filter function currently handles the cases 1. to 4. but (for no
other reason than carelessness) not 5.
#+BEGIN_SRC emacs-lisp
(defun trim-phone-number (phonenumber)
  "Remove whitespaces from a telephone number"
  (setq trimmed_phonenumber
	(mapconcat 'identity
		   (delete "(0)" (split-string phonenumber "[ /-]")) "")))
#+END_SRC

Regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-03-29 23:23 phone links Robert Goldman
                   ` (2 preceding siblings ...)
  2013-04-03 14:52 ` Michael Strey
@ 2013-04-04 12:15 ` Bastien
  2013-04-04 20:38   ` Simon Thum
  2013-04-05  2:38   ` Robert P. Goldman
  2013-04-10 14:17 ` Michael Strey
  4 siblings, 2 replies; 44+ messages in thread
From: Bastien @ 2013-04-04 12:15 UTC (permalink / raw)
  To: Robert Goldman; +Cc: Org Mode

Hi Robert,

Robert Goldman <rpgoldman@sift.info> writes:

> The two files are below, in hopes of getting suggestions for improvement
> so that someday this could find itself into contrib/.

Looks like a good start -- please keep us updated about your progress
and your will to include this in contrib/, I'm sure many users would
enjoy it.

Thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-04  8:26     ` Michael Strey
@ 2013-04-04 13:55       ` Michael Strey
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Strey @ 2013-04-04 13:55 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert Goldman

On Thu, Apr 04, 2013 at 10:26:53AM +0200, Michael Strey wrote:

[...]

> Usually my phone links look like [[tel:+49 351 4129535]]; but since I
> imported data sets from a larger contact data base that had evolved over
> time, I ended up with stuff like this in my data base:
> 1. [[tel:0033 (0) 4568-33]]
> 2. [[tel:+49 (0)3 8899 66]]
> 3. [[tel:0351 41295-35]]
> 4. [[tel:0351/4129535]]
> 5. [[tel:(0351) 412 95-35]]
> 
> My filter function currently handles the cases 1. to 4. but (for no
> other reason than carelessness) not 5.

[...]

Here is a re-work of the filter function that handles all off the above
cases correctly.

#+BEGIN_SRC emacs-lisp
(defun trim-phone-number (phonenumber)
  "Remove whitespaces from a telephone number"
  (setq trimmed_phonenumber
     (mapconcat 'identity
        (split-string
        (mapconcat 'identity
		   (split-string phonenumber "(0)") "") "[()/ -]") "")))
#+END_SRC

I'm a Elisp newbie.  I'm sure that there are smarter solutions to solve this
problem.

Regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-04 12:15 ` Bastien
@ 2013-04-04 20:38   ` Simon Thum
  2013-04-05  3:04     ` Robert P. Goldman
  2013-04-05  6:42     ` Bastien
  2013-04-05  2:38   ` Robert P. Goldman
  1 sibling, 2 replies; 44+ messages in thread
From: Simon Thum @ 2013-04-04 20:38 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Robert Goldman

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

Since you're at it: I keep the attached patch personally. I use it to 
sync org-contacts entries to my phone.

I didn't sign up to the FSF so far, and suck at maintaining emacs commit 
msg conventions. If the patch is interesting I'll do what is required.

Cheers,

Simon


On 04/04/2013 02:15 PM, Bastien wrote:
> Hi Robert,
>
> Robert Goldman <rpgoldman@sift.info> writes:
>
>> The two files are below, in hopes of getting suggestions for improvement
>> so that someday this could find itself into contrib/.
>
> Looks like a good start -- please keep us updated about your progress
> and your will to include this in contrib/, I'm sure many users would
> enjoy it.
>
> Thanks!
>


[-- Attachment #2: 0003-add-telephone-capability-to-org-contacts.patch --]
[-- Type: text/x-patch, Size: 2187 bytes --]

From c3b151d30a45f32679a166ac9fb220f85ad39dd0 Mon Sep 17 00:00:00 2001
From: Simon Thum <simon.thum@gmx.de>
Date: Sat, 27 Oct 2012 18:25:24 +0200
Subject: [PATCH 3/3] add telephone capability to org-contacts

Signed-off-by: Simon Thum <simon.thum@gmx.de>
---
 contrib/lisp/org-contacts.el |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index 30b9ed0..dba717f 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -64,6 +64,16 @@ If set to nil, all your Org files will be used."
   :type 'string
   :group 'org-contacts)
 
+(defcustom org-contacts-private-telephone-property "TEL"
+  "Name of the property for contact private/home telephone."
+  :type 'string
+  :group 'org-contacts)
+
+(defcustom org-contacts-work-telephone-property "WORKTEL"
+  "Name of the property for contact work/office telephone."
+  :type 'string
+  :group 'org-contacts)
+
 (defcustom org-contacts-birthday-property "BIRTHDAY"
   "Name of the property for contact birthday date."
   :type 'string
@@ -565,11 +575,15 @@ Org-contacts does not specify how to encode the name. So we try to do our best."
 	 (email (org-contacts-vcard-escape (cdr (assoc-string org-contacts-email-property properties))))
 	 (bday (org-contacts-vcard-escape (cdr (assoc-string org-contacts-birthday-property properties))))
 	 (addr (cdr (assoc-string org-contacts-address-property properties)))
+	 (telpriv (org-contacts-vcard-escape (cdr (assoc-string org-contacts-private-telephone-property properties))))
+	 (telwork (org-contacts-vcard-escape (cdr (assoc-string org-contacts-work-telephone-property properties))))
 	 (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname-property properties))))
 
 	 (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name)))
     (concat head
 	    (when email (format "EMAIL:%s\n" email))
+	    (when telpriv (format "TEL;TYPE=HOME,VOICE:%s\n" telpriv))
+	    (when telwork (format "TEL;TYPE=WORK,VOICE:%s\n" telwork))
 	    (when addr
 	      (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr)))
 	    (when bday
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-04 12:15 ` Bastien
  2013-04-04 20:38   ` Simon Thum
@ 2013-04-05  2:38   ` Robert P. Goldman
  2013-04-08 10:38     ` Michael Strey
  1 sibling, 1 reply; 44+ messages in thread
From: Robert P. Goldman @ 2013-04-05  2:38 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

On 4/4/13 Apr 4 -7:15 AM, Bastien wrote:
> Hi Robert,
> 
> Robert Goldman <rpgoldman@sift.info> writes:
> 
>> The two files are below, in hopes of getting suggestions for improvement
>> so that someday this could find itself into contrib/.
> 
> Looks like a good start -- please keep us updated about your progress
> and your will to include this in contrib/, I'm sure many users would
> enjoy it.

I will be happy to include this into contrib (and do the relevant
assignment) at any time when people think that it is sufficiently ready
to go.  I have been testing it in contrib/ in a testing branch in my git
repo.

I think a minor refactoring would make it more general: split the phone
handler into two components: a filter function (like the one for
linphone), defaulting to identity; and a command, probably revised to be
a format string (so that the dialed number could be place in an
arbitrary location).

I will try to have a new version with these changes very soon.

Best,
r

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-04 20:38   ` Simon Thum
@ 2013-04-05  3:04     ` Robert P. Goldman
  2013-04-05  6:42     ` Bastien
  1 sibling, 0 replies; 44+ messages in thread
From: Robert P. Goldman @ 2013-04-05  3:04 UTC (permalink / raw)
  To: Simon Thum; +Cc: Bastien, Org Mode

On 4/4/13 Apr 4 -3:38 PM, Simon Thum wrote:
> Since you're at it: I keep the attached patch personally. I use it to
> sync org-contacts entries to my phone.
> 
> I didn't sign up to the FSF so far, and suck at maintaining emacs commit
> msg conventions. If the patch is interesting I'll do what is required.


I'm afraid I don't use org-contacts, so I don't exactly understand how
this relates.  Are "phone:" links desired?  I.e., would you make the
values of the phone fields be phone-type org hyperlinks?  Or would you
just expect to be able to push phone numbers directly into the
org-phone-call function, without having to make the contact entries
explicitly be hyperlinks?

I suppose one should also attempt to make this compatible with the
org/BBDB integration, another thing about which I'm quite ignorant....

Best,
r

P.S. I note that the contacts databases I have access typically have FAX
and mobile entries as well as home and work.  Many also allow "custom"
phone number types.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-04 20:38   ` Simon Thum
  2013-04-05  3:04     ` Robert P. Goldman
@ 2013-04-05  6:42     ` Bastien
  2013-04-06 12:05       ` Simon Thum
  2013-04-06 12:10       ` Simon Thum
  1 sibling, 2 replies; 44+ messages in thread
From: Bastien @ 2013-04-05  6:42 UTC (permalink / raw)
  To: Simon Thum; +Cc: Org Mode, Robert Goldman

Hi Simon,

Simon Thum <simon.thum@gmx.de> writes:

> Since you're at it: I keep the attached patch personally. I use it to sync
> org-contacts entries to my phone.

I applied Feng's patches against org-contacts.el, maybe you don't need
your patch anymore.

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-05  6:42     ` Bastien
@ 2013-04-06 12:05       ` Simon Thum
  2013-04-06 12:10       ` Simon Thum
  1 sibling, 0 replies; 44+ messages in thread
From: Simon Thum @ 2013-04-06 12:05 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Robert Goldman

Hi,

seem like I am losing the work/home distinction. Not terribly useful (to 
me at least), so ok.

I do have several contact with more than one number though, and I also 
like to use spaces to delineate phone number part, like [country SPACE 
city SPACE subscriber]. Therefore it would be useful to have docs on how 
the splitting would work, e.g. in the property docstring.

Cheers,

Simon

On 04/05/2013 08:42 AM, Bastien wrote:
> Hi Simon,
>
> Simon Thum <simon.thum@gmx.de> writes:
>
>> Since you're at it: I keep the attached patch personally. I use it to sync
>> org-contacts entries to my phone.
>
> I applied Feng's patches against org-contacts.el, maybe you don't need
> your patch anymore.
>
> Best,
>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-05  6:42     ` Bastien
  2013-04-06 12:05       ` Simon Thum
@ 2013-04-06 12:10       ` Simon Thum
  2013-04-06 20:58         ` Bastien
  1 sibling, 1 reply; 44+ messages in thread
From: Simon Thum @ 2013-04-06 12:10 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Robert Goldman

Bastien,

one more thing: I have

(setq org-contacts-matcher "BIRTHDAY<>\"\"|ADR<>\"\"|EMAIL<>\"\"|TEL<>\"\"")

to be able to find contacts not having an email. Something like it would 
need to become the new default.

Cheers,

Simon


On 04/05/2013 08:42 AM, Bastien wrote:
> Hi Simon,
>
> Simon Thum <simon.thum@gmx.de> writes:
>
>> Since you're at it: I keep the attached patch personally. I use it to sync
>> org-contacts entries to my phone.
>
> I applied Feng's patches against org-contacts.el, maybe you don't need
> your patch anymore.
>
> Best,
>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-06 12:10       ` Simon Thum
@ 2013-04-06 20:58         ` Bastien
  0 siblings, 0 replies; 44+ messages in thread
From: Bastien @ 2013-04-06 20:58 UTC (permalink / raw)
  To: Simon Thum; +Cc: Org Mode, Robert Goldman

Hi Simon,

Simon Thum <simon.thum@gmx.de> writes:

> (setq org-contacts-matcher "BIRTHDAY<>\"\"|ADR<>\"\"|EMAIL<>\"\"|TEL<>\"\"")
>
> to be able to find contacts not having an email. Something like it would
> need to become the new default.

This now uses 

  (mapconcat 'identity (list org-contacts-email-property
			     org-contacts-tel-property
			     org-contacts-address-property
			     org-contacts-birthday-property)
			     "<>\"\"|")
Thanks for suggesting this,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-05  2:38   ` Robert P. Goldman
@ 2013-04-08 10:38     ` Michael Strey
  2013-04-08 12:47       ` Robert Goldman
  2013-04-09  9:57       ` Feng Shu
  0 siblings, 2 replies; 44+ messages in thread
From: Michael Strey @ 2013-04-08 10:38 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert P. Goldman

Robert,

On Do, Apr 04, 2013 at 09:38:48 -0500, Robert P. Goldman wrote:

[...]

> I will be happy to include this into contrib (and do the relevant
> assignment) at any time when people think that it is sufficiently ready
> to go.  I have been testing it in contrib/ in a testing branch in my git
> repo.

What about integrating these few functions into org-contacts?  Most
users will use telephony functions in conjunction with a contact
database.  The recently applied patches from Feng are already steps into
this direction.  The next logical step would be to define some basic
rules about how to write phone numbers and to support links in the EMAIL
and PHONE properties like in the following example.

#+BEGIN_SRC org
* Surname, Name
  :PROPERTIES:
  :EMAIL:    mailto:foo@bar.com
  :PHONE:    [[phone:+49 351 4129535]]; [[phone:+49 176 6626196]]
  :END:
#+END_SRC

Moreover the definition of the phone link would allow to extend the
current functionality of MobileOrg by a phone call function.

Regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-08 10:38     ` Michael Strey
@ 2013-04-08 12:47       ` Robert Goldman
  2013-04-08 14:07         ` Michael Strey
  2013-04-09  9:57       ` Feng Shu
  1 sibling, 1 reply; 44+ messages in thread
From: Robert Goldman @ 2013-04-08 12:47 UTC (permalink / raw)
  To: emacs-orgmode, Robert P. Goldman

Michael Strey wrote:
> Robert,
> 
> On Do, Apr 04, 2013 at 09:38:48 -0500, Robert P. Goldman wrote:
> 
> [...]
> 
>> I will be happy to include this into contrib (and do the relevant
>> assignment) at any time when people think that it is sufficiently ready
>> to go.  I have been testing it in contrib/ in a testing branch in my git
>> repo.
> 
> What about integrating these few functions into org-contacts?  

I am very reluctant to do this.

I don't use org-contacts at all, but I *do* like to have phone numbers
in my TODO items.

I don't believe a person should have to use org contacts in order to
permit themselves to use phone links.

I think we can get an appropriate combination by having org-phone be
free-standing, and simply let the org-contacts user adopt them if s/he
likes.

Related question:  if the org-contact entries are *known* to be phone
numbers (keyed by the field), why not automagically treat those values
as phone numbers, instead of requiring them to be phone links (which add
cruft to the files)?  And similarly for EMAIL.

I.e., why not simply have:

#+BEGIN_SRC org
* Surname, Name
  :PROPERTIES:
  :EMAIL:    foo@bar.com
  :PHONE:    +49 351 4129535; +49 176 6626196
  :END:
#+END_SRC
?

But as a non-org-contacts user, my opinion is obviously not so important
here...

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-08 12:47       ` Robert Goldman
@ 2013-04-08 14:07         ` Michael Strey
  2013-04-08 14:44           ` Robert Goldman
  0 siblings, 1 reply; 44+ messages in thread
From: Michael Strey @ 2013-04-08 14:07 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert P. Goldman

On Mo, Apr 08, 2013 at 07:47:52 -0500, Robert Goldman wrote:
> Michael Strey wrote:

[...]

> > What about integrating these few functions into org-contacts?  
> 
> I am very reluctant to do this.
> 
> I don't use org-contacts at all, but I *do* like to have phone numbers
> in my TODO items.

Actually, I do not use org-contacts either but I use an org file as
contact data base that follows the conventions defined in org-contacts.
Nevertheless, I would like to be able to use some of the newer functions of
org-contacts, namely the VCard export.

Currently org-phone.el as well as my org-dial.el are incompatible with
org-contacts.  The only idea behind my proposal was to make the contributors
of both packages aware of each other.


> I think we can get an appropriate combination by having org-phone be
> free-standing, and simply let the org-contacts user adopt them if s/he
> likes.

Yes, of course, with some persuading.

> Related question:  if the org-contact entries are *known* to be phone
> numbers (keyed by the field), why not automagically treat those values
> as phone numbers, instead of requiring them to be phone links (which add
> cruft to the files)?  And similarly for EMAIL.
> 
> I.e., why not simply have:
> 
> #+BEGIN_SRC org
> * Surname, Name
>   :PROPERTIES:
>   :EMAIL:    foo@bar.com
>   :PHONE:    +49 351 4129535; +49 176 6626196
>   :END:
> #+END_SRC
> ?

That would be convenient indeed.  But considering the given syntax rules
for links in org-mode, I'm not sure whether I really would like it.  Too
much magic can be confusing.

Moreover that would create a dependency between org-contacts and org-phone.
Org-contacts would require org-phone in order to work as intended, thus
creating a strong argument for my proposal of merging both packages.

Regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-08 14:07         ` Michael Strey
@ 2013-04-08 14:44           ` Robert Goldman
  2013-04-09  7:31             ` Michael Strey
  0 siblings, 1 reply; 44+ messages in thread
From: Robert Goldman @ 2013-04-08 14:44 UTC (permalink / raw)
  To: emacs-orgmode

Michael Strey wrote:
> Currently org-phone.el as well as my org-dial.el are incompatible with
> org-contacts.  The only idea behind my proposal was to make the contributors
> of both packages aware of each other.

Can you explain what makes org-phone incompatible with org-contacts?
Maybe my naming of some function?

If so, I will make sure to remove any incompatiblities on my side.

BTW, I would be happy to push org-phone.el into contrib/lisp...

I *think* I may have commit privileges as a hang-over from once
committing patches to the old generic exporter.....

cheers,
r

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-08 14:44           ` Robert Goldman
@ 2013-04-09  7:31             ` Michael Strey
  2013-04-09 12:19               ` Robert Goldman
                                 ` (2 more replies)
  0 siblings, 3 replies; 44+ messages in thread
From: Michael Strey @ 2013-04-09  7:31 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert P. Goldman

Robert,

On Mo, Apr 08, 2013 at 09:44:12 -0500, Robert Goldman wrote:
> Michael Strey wrote:
> > Currently org-phone.el as well as my org-dial.el are incompatible with
> > org-contacts.  The only idea behind my proposal was to make the contributors
> > of both packages aware of each other.
> 
> Can you explain what makes org-phone incompatible with org-contacts?
> Maybe my naming of some function?

The problem is on the side of org-contacts.  Org-contacts does not
support links in its properties.  Thus, currently the only solution to
use the advantages of org-contacts and org-phone is to give the
information twice, like in the following example.

#+BEGIN_SRC org
* Strey, Michael
:PROPERTIES:
:EMAIL:    mstrey@strey.biz foo@bar.com
:PHONE:    +493514129535 +491263213
:END:

[[mailto:mstrey@strey.biz]]
[[mailto:foo@bar.com]]
[[phone:+49 (0)351 41295-35]]
[[phone:+49 126 3213]]
#+END_SRC

This shortcoming effects not only the phone links but email links as
well.

Regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-08 10:38     ` Michael Strey
  2013-04-08 12:47       ` Robert Goldman
@ 2013-04-09  9:57       ` Feng Shu
  1 sibling, 0 replies; 44+ messages in thread
From: Feng Shu @ 2013-04-09  9:57 UTC (permalink / raw)
  To: emacs-orgmode

Michael Strey <mstrey@strey.biz> writes:

> Robert,
>
> On Do, Apr 04, 2013 at 09:38:48 -0500, Robert P. Goldman wrote:
>
> [...]
>
>> I will be happy to include this into contrib (and do the relevant
>> assignment) at any time when people think that it is sufficiently ready
>> to go.  I have been testing it in contrib/ in a testing branch in my git
>> repo.
>

> Moreover the definition of the phone link would allow to extend the
> current functionality of MobileOrg by a phone call function.

It  will be  a great feature and  mobileorg is a good way of managing
phone numbers 


>
> Regards

-- 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-09  7:31             ` Michael Strey
@ 2013-04-09 12:19               ` Robert Goldman
  2013-04-09 14:40                 ` Michael Strey
  2013-04-13 14:12               ` Feng Shu
  2013-04-14 20:49               ` Michael Strey
  2 siblings, 1 reply; 44+ messages in thread
From: Robert Goldman @ 2013-04-09 12:19 UTC (permalink / raw)
  To: emacs-orgmode

Michael Strey wrote:
> Robert,
> 
> On Mo, Apr 08, 2013 at 09:44:12 -0500, Robert Goldman wrote:
>> Michael Strey wrote:
>>> Currently org-phone.el as well as my org-dial.el are incompatible with
>>> org-contacts.  The only idea behind my proposal was to make the contributors
>>> of both packages aware of each other.
>> Can you explain what makes org-phone incompatible with org-contacts?
>> Maybe my naming of some function?
> 
> The problem is on the side of org-contacts.  Org-contacts does not
> support links in its properties.  Thus, currently the only solution to
> use the advantages of org-contacts and org-phone is to give the
> information twice, like in the following example.
> 
> #+BEGIN_SRC org
> * Strey, Michael
> :PROPERTIES:
> :EMAIL:    mstrey@strey.biz foo@bar.com
> :PHONE:    +493514129535 +491263213
> :END:
> 
> [[mailto:mstrey@strey.biz]]
> [[mailto:foo@bar.com]]
> [[phone:+49 (0)351 41295-35]]
> [[phone:+49 126 3213]]
> #+END_SRC
> 
> This shortcoming effects not only the phone links but email links as
> well.
> 
> Regards

I think in that case it might be best to have a function in org-contacts
that "knows" that PHONE contains phone numbers, and that can parse them
out, and shoot them off to org-phone.

Vague thought: Make C-c C-c aware of PHONE properties so that it can
perform this magic.

Again, I am not an org-contacts user, so this may be a stupid question,
but how does org-contacts "know" when it has a contact?  I am looking at
the sample record you present above, and it looks just like an org-mode
header to me.  There is no marker, as far as I can tell, that would tell
org-mode that it is a contact record, instead of some other arbitrary
thing.  This seems odd to me.  Why isn't it something like

#+BEGIN_SRC org
* CONTACT Strey, Michael
:PROPERTIES:
:EMAIL:    mstrey@strey.biz foo@bar.com
:PHONE:    +493514129535 +491263213
:END:
#+END_SRC

by analogy to the way TODO flags a task?

At any rate, any function that could parse a :PHONE: property could
easily (funcall org-phone-function <phone-number>).

Cheers,
r

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-09 12:19               ` Robert Goldman
@ 2013-04-09 14:40                 ` Michael Strey
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Strey @ 2013-04-09 14:40 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, Apr 09, 2013 at 07:19:35AM -0500, Robert Goldman wrote:

[...]

> Again, I am not an org-contacts user, so this may be a stupid question,
> but how does org-contacts "know" when it has a contact?  I am looking at
> the sample record you present above, and it looks just like an org-mode
> header to me.

The original idea behind org-contacts was to treat every heading
containing the property :EMAIL: as contact.  This has been extended to a
set of customisable properties that define a heading as contact.  By
default :EMAIL:, :PHONE:, :ADDRESS:, or :BIRTHDAY: make a contact from
any normal heading.

Best regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-03-29 23:23 phone links Robert Goldman
                   ` (3 preceding siblings ...)
  2013-04-04 12:15 ` Bastien
@ 2013-04-10 14:17 ` Michael Strey
  2013-04-11 10:27   ` Michael Strey
  4 siblings, 1 reply; 44+ messages in thread
From: Michael Strey @ 2013-04-10 14:17 UTC (permalink / raw)
  To: emacs-orgmode

FYI, I just posted the following mail to the MobileOrg mailing list.

,----
| Hello,
| 
| I'm using a contact data base inspired by org-contacts, where contact
| details are stored in the properties drawer.
| 
| First question: Are there any plans to show drawer content in the MobileOrg
| read view (not only in the edit view)?
| 
| The contact details contain phone numbers as well.  Recently we had some
| discussion about phone links in the Org-Mode mailing list.  This inspired
| me to make a little test with various forms of links and phone numbers.
| 
| I synchronised the following contact with MobileOrg.
| 
| #+BEGIN_SRC org
| ** Surname, Name
| :PROPERTIES:
| :EMAIL:    test2@test.de; name@test.de
| :PHONE:    +493514129535; +491766626196
| :END:
| 
| Visible as link and working:
| [[tel:+493514129535][+49 (0)351 41295-35]]
| [[tel:+49 (351) 41295-35][+49 (0)351 41295-35]]
| 
| Visible as link but not working:
| [[phone:+493514129535][+49 (0)351 41295-35]]
| 
| Not recognized as links by MobileOrg:
| [[tel:+49 351 4129535]]
| [[tel:+493514129535]]
| [[phone:+49 351 4129535]]
| [[phone:+49 (351) 4129535]]
| [[phone:+493514129535]]
| 
| Not working:
| +493514129535
| +49 351 4129535
| +49 351 41295-35
| +49 (351) 4129535
| #+END_SRC
| 
| In MobileOrg some of the above links are displayed as links and some not.
| The links with the key "tel:" lead me to the phone application on my
| smartphone, those with the key "phone" don't.  Pure numbers sometimes lead
| to the phone app but only parts of the complete number are transmitted.
| 
| What is the reason for the tel: links working and the phone: links not?
| AFAIK non of them is supported yet by Org-Mode.
`----


-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-10 14:17 ` Michael Strey
@ 2013-04-11 10:27   ` Michael Strey
  2013-04-16  7:57     ` Eric S Fraga
  0 siblings, 1 reply; 44+ messages in thread
From: Michael Strey @ 2013-04-11 10:27 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert P. Goldman

Here is the most important part of Mat's reply:

,----
| note that "tel:" is a common uri for indicating that something is a
| telephone number (http://tools.ietf.org/html/rfc3966)
`----

Seems that we should prefer 'tel' as key for the phone link.

Regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-09  7:31             ` Michael Strey
  2013-04-09 12:19               ` Robert Goldman
@ 2013-04-13 14:12               ` Feng Shu
  2013-04-13 14:43                 ` Feng Shu
  2013-04-14 20:49               ` Michael Strey
  2 siblings, 1 reply; 44+ messages in thread
From: Feng Shu @ 2013-04-13 14:12 UTC (permalink / raw)
  To: emacs-orgmode

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

Michael Strey <mstrey@strey.biz> writes:

> Robert,
>
> On Mo, Apr 08, 2013 at 09:44:12 -0500, Robert Goldman wrote:
>> Michael Strey wrote:
>> > Currently org-phone.el as well as my org-dial.el are incompatible with
>> > org-contacts.  The only idea behind my proposal was to make the contributors
>> > of both packages aware of each other.
>> 
>> Can you explain what makes org-phone incompatible with org-contacts?
>> Maybe my naming of some function?
>
> The problem is on the side of org-contacts.  Org-contacts does not
> support links in its properties.  Thus, currently the only solution to
> use the advantages of org-contacts and org-phone is to give the
> information twice, like in the following example.
> #+BEGIN_SRC org
> * Strey, Michael
> :PROPERTIES:
> :EMAIL:    mstrey@strey.biz foo@bar.com
> :PHONE:    +493514129535 +491263213
> :END:
>
> [[mailto:mstrey@strey.biz]]
> [[mailto:foo@bar.com]]
> [[phone:+49 (0)351 41295-35]]
> [[phone:+49 126 3213]]
> #+END_SRC

I use a export function which can export all contacts to the format:
#+begin_example

    * NAME
    ** EMAIL: [[mailto:n1@n.com]]
    ** EMAIL: [[mailto:n2@n.com]]
    ** PHONE: [[tel:123456789]]
    ** PHONE: [[tel:123456789]]

#+end_example

It it only a temporary solution, may be someone will need it ,but  adding it to the master may
be not a good idea.



[-- Attachment #2: 0001-org-contacts.el-export-contacts-to-outline-format.patch --]
[-- Type: text/x-diff, Size: 4510 bytes --]

From 2c73cdfdf54fe4c882a3bc0d3ce3cd268555100e Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
Date: Sat, 13 Apr 2013 22:00:03 +0800
Subject: [PATCH] org-contacts.el, export contacts to outline-format

* contrib/lisp/org-contacts.el (org-contacts-outline-file): new
  variable
(org-contacts-outline-format): new function which formats a contact to
outline-format
(org-contacts-export-as-outline-format): new function, formats all
contacts to outline-format

* NAME
 :PROPERTIES:
 :EMAIL: n1@n.com n2@n.com
 :PHONE: 123456789
 :END:

export as:

* NAME
** EMAIL: [[mailto:n1@n.com]]
** EMAIL: [[mailto:n2@n.com]]
** PHONE: [[tel:123456789]]
** PHONE: [[tel:123456789]]
---
 contrib/lisp/org-contacts.el |   69 ++++++++++++++++++++++++++++++++++++++++++
 1 个文件被修改,插入 69 行(+)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index a3c4aed..dd89251 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -156,6 +156,12 @@ This overrides `org-email-link-description-format' if set."
   :group 'org-contacts
   :type 'file)
 
+(defcustom org-contacts-outline-file "contacts-outline.org"
+  "Default file for outline-format export."
+  :group 'org-contacts
+  :type 'file)
+
+
 (defcustom org-contacts-enable-completion t
   "Enable or not the completion in `message-mode' with `org-contacts'."
   :group 'org-contacts
@@ -896,6 +902,69 @@ is created and the VCard is written into that buffer."
 	(current-buffer)
       (progn (save-buffer) (kill-buffer)))))
 
+(defun org-contacts-outline-format (contact)
+  "Formats CONTACT in outline format."
+  (let* ((properties (caddr contact))
+	 (name (org-contacts-vcard-escape (car contact)))
+	 (n (org-contacts-vcard-encode-name name))
+	 (email (cdr (assoc-string org-contacts-email-property properties)))
+	 (tel  (cdr (assoc-string org-contacts-tel-property properties)))
+	 (note (cdr (assoc-string org-contacts-note-property properties)))
+	 (bday (org-contacts-vcard-escape (cdr (assoc-string org-contacts-birthday-property properties))))
+	 (addr (cdr (assoc-string org-contacts-address-property properties)))
+	 (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname-property properties))))
+	 (head (format "* %s\n" name)))
+    (concat head
+	    (when email (progn
+			  (setq emails-list (split-string email "[,;: ]+"))
+			  (setq result "")
+			  (while emails-list
+			    (setq result (concat result  "** EMAIL: " (concat "[[mailto:" (car emails-list) "]]") "\n"))
+			    (setq emails-list (cdr emails-list)))
+			  result))
+	    (when addr
+	      (format "** ADRESS: " (replace-regexp-in-string "\\, ?" ";" addr)))
+	    (when tel (progn
+			(setq phones-list (split-string tel "[,;: ]+"))
+			(setq result "")
+			(while phones-list
+			  (setq result (concat result  "** TEL: " (concat "[[tel:" (car phones-list) "]]" ) "\n"))
+			  (setq phones-list (cdr phones-list)))
+			result))
+	    (when bday
+	      (let ((cal-bday (calendar-gregorian-from-absolute (org-time-string-to-absolute bday))))
+		(format "** BDAY:%04d-%02d-%02d\n"
+			(calendar-extract-year cal-bday)
+			(calendar-extract-month cal-bday)
+			(calendar-extract-day cal-bday))))
+	    (when nick (format "** NICKNAME: %s\n" nick))
+	    (when note (format "** NOTE: %s\n" note)))))
+
+
+
+(defun org-contacts-export-as-outline-format (&optional name file to-buffer)
+  "Export all contacts matching NAME as outline format
+If TO-BUFFER is nil, the content is written to FILE or
+`org-contacts-outline-file'.  If TO-BUFFER is non-nil, the buffer
+is created and the outlines is written into that buffer."
+  (interactive) ; TODO ask for name?
+  (let* ((filename (or file org-contacts-outline-file))
+	 (buffer (if to-buffer
+		     (get-buffer-create to-buffer)
+		   (find-file-noselect filename))))
+    (message "Exporting...")
+    (set-buffer buffer)
+    (let ((inhibit-read-only t)) (erase-buffer))
+    (fundamental-mode)
+    (when (fboundp 'set-buffer-file-coding-system)
+      (set-buffer-file-coding-system coding-system-for-write))
+    (loop for contact in (org-contacts-filter name)
+	  do (insert (org-contacts-outline-format contact)))
+    (if to-buffer
+	(current-buffer)
+      (progn (save-buffer) (kill-buffer)))))
+
+
 (defun org-contacts-show-map (&optional name)
   "Show contacts on a map.
 Requires google-maps-el."
-- 
1.7.10.4


[-- Attachment #3: Type: text/plain, Size: 101 bytes --]




>
> This shortcoming effects not only the phone links but email links as
> well.
>
> Regards

-- 

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-13 14:12               ` Feng Shu
@ 2013-04-13 14:43                 ` Feng Shu
  2013-04-14  8:38                   ` Bastien
  0 siblings, 1 reply; 44+ messages in thread
From: Feng Shu @ 2013-04-13 14:43 UTC (permalink / raw)
  To: emacs-orgmode

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


[update diff] make output format more beautiful


[-- Attachment #2: 0001-org-contacts.el-export-contacts-to-outline-format.patch --]
[-- Type: text/x-diff, Size: 4655 bytes --]

From 500694de70f14095acc765875182d65feab7ef85 Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
Date: Sat, 13 Apr 2013 22:00:03 +0800
Subject: [PATCH] org-contacts.el, export contacts to outline-format

* contrib/lisp/org-contacts.el (org-contacts-outline-file): new
  variable
(org-contacts-outline-format): new function which formats a contact to
outline-format
(org-contacts-export-as-outline-format): new function, formats all
contacts to outline-format

* NAME
 :PROPERTIES:
 :EMAIL: n1@n.com n2@n.com
 :PHONE: 123456789
 :END:

export as:

* NAME
** EMAIL: [[mailto:n1@n.com]]
** EMAIL: [[mailto:n2@n.com]]
** PHONE: [[tel:123456789]]
** PHONE: [[tel:123456789]]
---
 contrib/lisp/org-contacts.el |   72 ++++++++++++++++++++++++++++++++++++++++++
 1 个文件被修改,插入 72 行(+)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index a3c4aed..c65ebf0 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -156,6 +156,12 @@ This overrides `org-email-link-description-format' if set."
   :group 'org-contacts
   :type 'file)
 
+(defcustom org-contacts-outline-file "contacts-outline.org"
+  "Default file for outline-format export."
+  :group 'org-contacts
+  :type 'file)
+
+
 (defcustom org-contacts-enable-completion t
   "Enable or not the completion in `message-mode' with `org-contacts'."
   :group 'org-contacts
@@ -896,6 +902,72 @@ is created and the VCard is written into that buffer."
 	(current-buffer)
       (progn (save-buffer) (kill-buffer)))))
 
+(defun org-contacts-outline-format (contact)
+  "Formats CONTACT in outline format."
+  (let* ((properties (caddr contact))
+	 (name (org-contacts-vcard-escape (car contact)))
+	 (n (org-contacts-vcard-encode-name name))
+	 (email (cdr (assoc-string org-contacts-email-property properties)))
+	 (alias (cdr (assoc-string org-contacts-alias-property properties)))
+	 (tel  (cdr (assoc-string org-contacts-tel-property properties)))
+	 (note (cdr (assoc-string org-contacts-note-property properties)))
+	 (bday (org-contacts-vcard-escape (cdr (assoc-string org-contacts-birthday-property properties))))
+	 (addr (cdr (assoc-string org-contacts-address-property properties)))
+	 (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname-property properties))))
+	 (head (format "* %s\n" name)))
+    (concat head
+	    (when alias
+	      (format "** ALIAS:   %s\n" alias))
+	    (when email (progn
+			  (setq emails-list (split-string email "[,;: ]+"))
+			  (setq result "")
+			  (while emails-list
+			    (setq result (concat result  "** EMAIL:   " (concat "[[mailto:" (car emails-list) "]]") "\n"))
+			    (setq emails-list (cdr emails-list)))
+			  result))
+	    (when addr
+	      (format "** ADRESS:  " (replace-regexp-in-string "\\, ?" ";" addr)))
+	    (when tel (progn
+			(setq phones-list (split-string tel "[,;: ]+"))
+			(setq result "")
+			(while phones-list
+			  (setq result (concat result  "** TEL:     " (concat "[[tel:" (car phones-list) "]]" ) "\n"))
+			  (setq phones-list (cdr phones-list)))
+			result))
+	    (when bday
+	      (let ((cal-bday (calendar-gregorian-from-absolute (org-time-string-to-absolute bday))))
+		(format "** BDAY:%04d-%02d-%02d\n"
+			(calendar-extract-year cal-bday)
+			(calendar-extract-month cal-bday)
+			(calendar-extract-day cal-bday))))
+	    (when nick (format "** NICKNAME: %s\n" nick))
+	    (when note (format "** NOTE:    %s\n" note)))))
+
+
+
+(defun org-contacts-export-as-outline-format (&optional name file to-buffer)
+  "Export all contacts matching NAME as outline format
+If TO-BUFFER is nil, the content is written to FILE or
+`org-contacts-outline-file'.  If TO-BUFFER is non-nil, the buffer
+is created and the outlines is written into that buffer."
+  (interactive) ; TODO ask for name?
+  (let* ((filename (or file org-contacts-outline-file))
+	 (buffer (if to-buffer
+		     (get-buffer-create to-buffer)
+		   (find-file-noselect filename))))
+    (message "Exporting...")
+    (set-buffer buffer)
+    (let ((inhibit-read-only t)) (erase-buffer))
+    (fundamental-mode)
+    (when (fboundp 'set-buffer-file-coding-system)
+      (set-buffer-file-coding-system coding-system-for-write))
+    (loop for contact in (org-contacts-filter name)
+	  do (insert (org-contacts-outline-format contact)))
+    (if to-buffer
+	(current-buffer)
+      (progn (save-buffer) (kill-buffer)))))
+
+
 (defun org-contacts-show-map (&optional name)
   "Show contacts on a map.
 Requires google-maps-el."
-- 
1.7.10.4


[-- Attachment #3: Type: text/plain, Size: 6 bytes --]



-- 

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-13 14:43                 ` Feng Shu
@ 2013-04-14  8:38                   ` Bastien
  2013-04-14 14:31                     ` Feng Shu
  0 siblings, 1 reply; 44+ messages in thread
From: Bastien @ 2013-04-14  8:38 UTC (permalink / raw)
  To: Feng Shu; +Cc: Grégoire Jadi, emacs-orgmode

Hi Feng,

Feng Shu <tumashu@gmail.com> writes:

> [update diff] make output format more beautiful

thanks for the patch -- at first sight, the formatting should be
fixed, let's try to avoid lines longer than 80 characters.  But in
general, I'd be more comfortable with someone taking org-contacts.el
in charge: I copy Grégoire as he proposed to do this.

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-14  8:38                   ` Bastien
@ 2013-04-14 14:31                     ` Feng Shu
  2013-04-15 15:39                       ` Bastien
  2013-04-16 21:11                       ` Daimrod
  0 siblings, 2 replies; 44+ messages in thread
From: Feng Shu @ 2013-04-14 14:31 UTC (permalink / raw)
  To: Bastien; +Cc: Grégoire Jadi, emacs-orgmode

Bastien <bzg@gnu.org> writes:

> Hi Feng,
>
> Feng Shu <tumashu@gmail.com> writes:
>
>> [update diff] make output format more beautiful
>
> thanks for the patch -- at first sight, the formatting should be
> fixed, let's try to avoid lines longer than 80 characters.  But in
> general, I'd be more comfortable with someone taking org-contacts.el
> in charge: I copy Grégoire as he proposed to do this.
>
> Thanks,

Hi Bastien,

I don't think this patch should be include into master,
I don't want people run between two different format.

Now org-mobile can't show propertiy quickly ,may be it's only a tmp
solution of the problem.

I want org-contact.el can manage this kind of format directly instead of 
exporting, but it's beyond my ability for I'm not a programmer


Feng Shu

-- 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-09  7:31             ` Michael Strey
  2013-04-09 12:19               ` Robert Goldman
  2013-04-13 14:12               ` Feng Shu
@ 2013-04-14 20:49               ` Michael Strey
  2013-04-16 22:22                 ` Daimrod
  2 siblings, 1 reply; 44+ messages in thread
From: Michael Strey @ 2013-04-14 20:49 UTC (permalink / raw)
  To: emacs-orgmode

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

On Tue, Apr 09, 2013 at 09:31:40AM +0200, Michael Strey wrote:

[...]

> The problem is on the side of org-contacts.  Org-contacts does not
> support links in its properties.
[...]

> This shortcoming effects not only the phone links but email links as
> well.

Attached is a patch to allow org links in org-contacts properties.
It allows entries like in the following example without effecting
org-contacts current functions.

#+BEGIN_SRC org
* Surname, Name
:PROPERTIES:
:EMAIL:    mailto:test2@test.de; [[mailto:name@test.de]] foo@bar.biz
:PHONE:    [[tel:+49 351 4129535]], +491766626196 [[+49 (351) 41295-35]]
:END:
#+END_SRC

Phone links of the form [[tel:+49 351 412 95-35][My phone number]] or
[[tel:+49 351 41295-35]] are expected.  `-', `/', `(', `)' and
whitespace characters are allowed in telephone numbers.


-- 
Michael Strey 
www.strey.biz


[-- Attachment #2: 0174-Org-contacts-Allow-org-links-in-properties.patch --]
[-- Type: text/plain, Size: 9954 bytes --]

From 69ae791cd552bacdcbc99af99a82ab699fa16d36 Mon Sep 17 00:00:00 2001
From: Michael Strey <mstrey@strey.biz>
Date: Fri, 12 Apr 2013 12:33:16 +0200
Subject: [PATCH 174/174] Org-contacts: Allow org links in properties

* org-contacts.el (org-contacts-split-property, chomp): Introduce a custom
  version of split-string that keeps org links intact. `chomp' is a
  helper function for `org-contacts-split-property'.
* org-contacts.el (org-contacts-strip-link): Introduce a new function
  that removes brackets, description, link type and colon from an org
  link string returning the pure link key.
* org-contacts.el (org-contacts-complete-group)
	(org-contacts-complete-name, org-contacts-view-send-email)
	(org-contacts-get-icon, org-contacts-vcard-format): Apply the
  new functions to the already existing functions extracting telephone numbers
  and email addresses from the properties.

Allowed separators for email addresses and phone numbers are `,', `;'
and whitespace.  `:' is not allowed anymore as separator to avoid
confusion with implizit links.

Examples of properties that are possible after those changes:

* Surname, Name
:PROPERTIES:
:EMAIL:    mailto:test2@test.de; [[mailto:name@test.de]] foo@bar.biz
:PHONE:    [[tel:+49 351 4129535]], +491766626196 [[+49 (351) 41295-35]]
:END:

Phone links of the form [[tel:+49 351 412 95-35][My phone number]] or
[[tel:+49 351 41295-35]] are expected.  `-', `/', `(', `)' and
whitespace characters are allowed in telephone numbers.
---
 contrib/lisp/org-contacts.el | 83 ++++++++++++++++++++++++++++++++++++--------
 5 files changed, 106 insertions(+), 28 deletions(-)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index 65eeea8..a502674 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -218,7 +218,7 @@ This overrides `org-email-link-description-format' if set."
     org-contacts-db))
 
 (defun org-contacts-filter (&optional name-match tags-match)
-  "Search for a contact maching NAME-MATCH and TAGS-MATCH.
+  "Search for a contact matching NAME-MATCH and TAGS-MATCH.
 If both match values are nil, return all contacts."
   (if (and (null name-match)
 	   (null tags-match))
@@ -426,7 +426,7 @@ A group FOO is composed of contacts with the tag FOO."
 				    (or (cdr (assoc-string "ALLTAGS" (caddr contact))) "") ":")))))))
 	(list start end
 	      (if (= (length completion-list) 1)
-		  ;; We've foudn the correct group, returns the address
+		  ;; We've found the correct group, returns the address
 		  (lexical-let ((tag (get-text-property 0 'org-contacts-group
 							(car completion-list))))
 		    (lambda (string pred &optional to-ignore)
@@ -438,11 +438,11 @@ A group FOO is composed of contacts with the tag FOO."
 				       ;; returned by `org-contacts-filter'.
 				       for contact-name = (car contact)
 				       ;; Grab the first email of the contact
-				       for email = (car (split-string
+				       for email = (org-contacts-strip-link (car (org-contacts-split-property
 							 (or
 							  (cdr (assoc-string org-contacts-email-property
 									     (caddr contact)))
-							  "")))
+							  ""))))
 				       ;; If the user has an email address, append USER <EMAIL>.
 				       if email collect (org-contacts-format-email contact-name email))
 				 ", ")))
@@ -459,14 +459,14 @@ A group FOO is composed of contacts with the tag FOO."
 		;; returned by `org-contacts-filter'.
 		for contact-name = (car contact)
 		;; Build the list of the user email addresses.
-		for email-list = (split-string (or
+		for email-list = (org-contacts-split-property (or
 						(cdr (assoc-string org-contacts-email-property
 								   (caddr contact))) ""))
 		;; If the user has email addresses…
 		if email-list
 		;; … append a list of USER <EMAIL>.
 		nconc (loop for email in email-list
-			    collect (org-contacts-format-email contact-name email))))
+			    collect (org-contacts-format-email contact-name (org-contacts-strip-link email)))))
 	 (completion-list (org-contacts-all-completions-prefix
 			   string
 			   (org-uniquify completion-list))))
@@ -731,11 +731,12 @@ address."
     (org-with-point-at marker
       (let ((emails (org-entry-get (point) org-contacts-email-property)))
         (if emails
-            (let ((email-list (split-string emails)))
+            (let ((email-list (org-contacts-split-property emails)))
               (if (and (= (length email-list) 1) (not ask))
                   (compose-mail (org-contacts-format-email
                                  (org-get-heading t) emails))
                 (let ((email (completing-read "Send mail to which address: " email-list)))
+		  (setq email (org-contacts-strip-link email))
                   (org-contacts-check-mail-address email)
                   (compose-mail (org-contacts-format-email (org-get-heading t) email)))))
           (error (format "This contact has no mail address set (no %s property)."
@@ -759,8 +760,8 @@ address."
              (email-list (org-entry-get pom org-contacts-email-property))
              (gravatar
               (when email-list
-                (loop for email in (split-string email-list)
-                      for gravatar = (gravatar-retrieve-synchronously email)
+                (loop for email in (org-contacts-split-property email-list)
+                      for gravatar = (gravatar-retrieve-synchronously (org-contacts-strip-link email))
                       if (and gravatar
                               (not (eq gravatar 'error)))
                       return gravatar))))
@@ -842,19 +843,19 @@ to do our best."
 	 (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name)))
     (concat head
 	    (when email (progn
-			  (setq emails-list (split-string email "[,;: ]+"))
+			  (setq emails-list (org-contacts-split-property email "[,; ]+"))
 			  (setq result "")
 			  (while emails-list
-			    (setq result (concat result  "EMAIL:" (car emails-list) "\n"))
+			    (setq result (concat result  "EMAIL:" (org-contacts-strip-link (car emails-list)) "\n"))
 			    (setq emails-list (cdr emails-list)))
 			  result))
 	    (when addr
 	      (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr)))
 	    (when tel (progn
-			(setq phones-list (split-string tel "[,;: ]+"))
+			(setq phones-list (org-contacts-split-property tel "[,; ]+"))
 			(setq result "")
 			(while phones-list
-			  (setq result (concat result  "TEL:" (car phones-list) "\n"))
+			  (setq result (concat result  "TEL:" (org-contacts-strip-link (car phones-list)) "\n"))
 			  (setq phones-list (cdr phones-list)))
 			result))
 	    (when bday
@@ -903,7 +904,61 @@ Requires google-maps-el."
     if addr
     collect (cons (list addr) (list :label (string-to-char (car contact)))))))
 
-(provide 'org-contacts)
+(defun org-contacts-strip-link (link)
+  "Remove brackets, description, link type and colon from an org link string and return the pure link key."
+   (let (startpos colonpos endpos)
+     (setq startpos (string-match (regexp-opt '("[[tel:" "[[mailto:")) link))
+     (if startpos
+         (progn
+            (setq colonpos (string-match ":" link))
+            (setq endpos (string-match "\\]" link))
+            (if endpos (substring link (1+ colonpos) endpos) link))
+         (progn
+            (setq startpos (string-match "mailto:" link))
+            (setq colonpos (string-match ":" link))
+            (if startpos (substring link (1+ colonpos)) link)))))
+
+(defun org-contacts-split-property (string &optional separators omit-nulls)
+  "Custom version of `split-string'.
+Split a property STRING into sub-strings bounded by matches
+for SEPARATORS but keep Org links intact.
+
+The beginning and end of STRING, and each match for SEPARATORS, are
+splitting points.  The substrings matching SEPARATORS are removed, and
+the substrings between the splitting points are collected as a list,
+which is returned.
+
+If SEPARATORS is non-nil, it should be a regular expression matching text
+which separates, but is not part of, the substrings.  If nil it defaults to
+`split-string-default-separators', normally \"[ \\f\\t\\n\\r\\v]+\", and
+OMIT-NULLS is forced to t.
+
+If OMIT-NULLS is t, zero-length substrings are omitted from the list \(so
+that for the default value of SEPARATORS leading and trailing whitespace
+are effectively trimmed).  If nil, all zero-length substrings are retained."
+(let* ((keep-nulls (or nil omit-nulls))
+         (rexp (or separators split-string-default-separators))
+         (inputlist (split-string string rexp keep-nulls))
+         (linkstring "")
+         (bufferstring "")
+         (proplist (list "")))
+    (while inputlist
+      (setq bufferstring (pop inputlist))
+      (if (string-match "\\[\\[" bufferstring)
+          (progn
+            (setq linkstring (concat bufferstring " "))
+            (while (not (string-match "\\]\\]" bufferstring))
+              (setq bufferstring (pop inputlist))
+              (setq linkstring (concat  linkstring bufferstring " ")))
+            (setq proplist (cons (chomp linkstring) proplist)))
+        (setq proplist (cons bufferstring proplist))))
+    (cdr (reverse proplist))))
+
+(defun chomp (str)
+  "Chomp leading and tailing whitespace from STR."
+  (while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'" str)
+    (setq str (replace-match "" t t str)))
+  str)
 
 (provide 'org-contacts)
 
-;; This program is distaributed in the hope that it will be useful,
+;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-14 14:31                     ` Feng Shu
@ 2013-04-15 15:39                       ` Bastien
  2013-04-15 23:37                         ` Feng Shu
  2013-04-16 21:11                       ` Daimrod
  1 sibling, 1 reply; 44+ messages in thread
From: Bastien @ 2013-04-15 15:39 UTC (permalink / raw)
  To: Feng Shu; +Cc: emacs-orgmode, Grégoire Jadi

Hi Feng,

thanks for your reply.

I'll let Grégoire decide on what to apply to org-contacts.el.

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-15 15:39                       ` Bastien
@ 2013-04-15 23:37                         ` Feng Shu
  0 siblings, 0 replies; 44+ messages in thread
From: Feng Shu @ 2013-04-15 23:37 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Grégoire Jadi

Bastien <bzg@gnu.org> writes:

> Hi Feng,
>
> thanks for your reply.
>
> I'll let Grégoire decide on what to apply to org-contacts.el.
>
> Best,

It's a good decision

-- 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-11 10:27   ` Michael Strey
@ 2013-04-16  7:57     ` Eric S Fraga
  2013-04-16 12:25       ` Robert P. Goldman
  0 siblings, 1 reply; 44+ messages in thread
From: Eric S Fraga @ 2013-04-16  7:57 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Robert P. Goldman

Michael Strey <mstrey@strey.biz> writes:

> Here is the most important part of Mat's reply:
>
> ,----
> | note that "tel:" is a common uri for indicating that something is a
> | telephone number (http://tools.ietf.org/html/rfc3966)
> `----
>
> Seems that we should prefer 'tel' as key for the phone link.

+1
-- 
: Eric S Fraga, GnuPG: 0xC89193D8FFFCF67D
: in Emacs 24.3.50.1 and Org release_7.9.3f-1199-g3a0e55

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-16  7:57     ` Eric S Fraga
@ 2013-04-16 12:25       ` Robert P. Goldman
  2013-04-17  8:14         ` Michael Strey
  0 siblings, 1 reply; 44+ messages in thread
From: Robert P. Goldman @ 2013-04-16 12:25 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: <emacs-orgmode@gnu.org>

Well, but note that we don't use file URLs -- we have special org hyperlinks with their own syntax...

The reason I am reluctant to adopt tel: is that that would suggest we should adopt the phone number syntax of RFC 3966. I confess that I haven't slogged my way through it, nor am I likely to have time to in the near future....

It seems like false advertising to adopt a scheme without playing by its rules: I'd be happier doing this if I had an RFC 3966-compliant parser to use.... All I have done so far is trust that phone: is followed by something the org-phone-call can deal with.

What do you all think? Am I being too fussy?

On Apr 16, 2013, at 2:57, Eric S Fraga <e.fraga@ucl.ac.uk> wrote:

> Michael Strey <mstrey@strey.biz> writes:
> 
>> Here is the most important part of Mat's reply:
>> 
>> ,----
>> | note that "tel:" is a common uri for indicating that something is a
>> | telephone number (http://tools.ietf.org/html/rfc3966)
>> `----
>> 
>> Seems that we should prefer 'tel' as key for the phone link.
> 
> +1
> -- 
> : Eric S Fraga, GnuPG: 0xC89193D8FFFCF67D
> : in Emacs 24.3.50.1 and Org release_7.9.3f-1199-g3a0e55
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-14 14:31                     ` Feng Shu
  2013-04-15 15:39                       ` Bastien
@ 2013-04-16 21:11                       ` Daimrod
  2013-04-17  3:55                         ` Feng Shu
  1 sibling, 1 reply; 44+ messages in thread
From: Daimrod @ 2013-04-16 21:11 UTC (permalink / raw)
  To: Feng Shu; +Cc: Bastien, Grégoire Jadi, emacs-orgmode

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

Feng Shu <tumashu@gmail.com> writes:

Hello Feng,

> Bastien <bzg@gnu.org> writes:
>
>> Hi Feng,
>>
>> Feng Shu <tumashu@gmail.com> writes:
>>
>>> [update diff] make output format more beautiful
>>
>> thanks for the patch -- at first sight, the formatting should be
>> fixed, let's try to avoid lines longer than 80 characters.  But in
>> general, I'd be more comfortable with someone taking org-contacts.el
>> in charge: I copy Grégoire as he proposed to do this.
>>
>> Thanks,
>
> Hi Bastien,
>
> I don't think this patch should be include into master,
> I don't want people run between two different format.
>
> Now org-mobile can't show propertiy quickly ,may be it's only a tmp
> solution of the problem.
>
> I want org-contact.el can manage this kind of format directly instead of 
> exporting, but it's beyond my ability for I'm not a programmer

I agree with you, it would be much better if org-contacts managed links
within properties.

I'll look at Michael's patch which implements this.

Regards,

-- 
Daimrod/Greg

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-14 20:49               ` Michael Strey
@ 2013-04-16 22:22                 ` Daimrod
  2013-04-17 10:28                   ` Michael Strey
  0 siblings, 1 reply; 44+ messages in thread
From: Daimrod @ 2013-04-16 22:22 UTC (permalink / raw)
  To: emacs-orgmode

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

Michael Strey <mstrey@strey.biz> writes:

Hello Michael,

> On Tue, Apr 09, 2013 at 09:31:40AM +0200, Michael Strey wrote:
>
> [...]
>
>> The problem is on the side of org-contacts.  Org-contacts does not
>> support links in its properties.
> [...]
>
>> This shortcoming effects not only the phone links but email links as
>> well.
>
> Attached is a patch to allow org links in org-contacts properties.
> It allows entries like in the following example without effecting
> org-contacts current functions.
>
> #+BEGIN_SRC org
> * Surname, Name
> :PROPERTIES:
> :EMAIL:    mailto:test2@test.de; [[mailto:name@test.de]] foo@bar.biz
> :PHONE:    [[tel:+49 351 4129535]], +491766626196 [[+49 (351) 41295-35]]
> :END:
> #+END_SRC
>
> Phone links of the form [[tel:+49 351 412 95-35][My phone number]] or
> [[tel:+49 351 41295-35]] are expected.  `-', `/', `(', `)' and
> whitespace characters are allowed in telephone numbers.

Thank you for your patch, though here are a few suggestions:
- It looks like `chomp' does the same thing the `org-trim' (in `org.el')
  if so you should use it.

- You should use `org-link-display-format' instead of
  `org-contacts-strip-link'.

- You have done some unrelated changes (fix some typos, ...), could you
  provide a separated patches for them?

Regarding `org-contacts-split-property', I haven't found anything about
multiple values within a node property in `org-element' and the syntax
description doesn't mention it, so you were right to roll your own. :)
However, I think it would be better to store the separators in a
variable (like `org-contacts-property-values-separator') and maybe even
to use it by default instead of `split-string-default-separators'
because we use it more and because it's easy to forget.

> +                (loop for email in (org-contacts-split-property email-list)
                                                                           ^^^^
> +                      for gravatar = (gravatar-retrieve-synchronously (org-contacts-strip-link email))

What do you think?


Thanks again for your time!

Regards,

-- 
Daimrod/Greg

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-16 21:11                       ` Daimrod
@ 2013-04-17  3:55                         ` Feng Shu
  2013-04-17  6:10                           ` Daimrod
  0 siblings, 1 reply; 44+ messages in thread
From: Feng Shu @ 2013-04-17  3:55 UTC (permalink / raw)
  To: Daimrod; +Cc: Bastien, Grégoire Jadi, emacs-orgmode

Daimrod <daimrod@gmail.com> writes:

>
> I agree with you, it would be much better if org-contacts managed
> links
> within properties.
I think the two format have less difference



org-android and org-android-NG can't show properties like outline,
I expect to see the implement of this feature


>
> I'll look at Michael's patch which implements this.
>
> Regards,

-- 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-17  3:55                         ` Feng Shu
@ 2013-04-17  6:10                           ` Daimrod
  0 siblings, 0 replies; 44+ messages in thread
From: Daimrod @ 2013-04-17  6:10 UTC (permalink / raw)
  To: Feng Shu; +Cc: Bastien, Grégoire Jadi, emacs-orgmode

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

Feng Shu <tumashu@gmail.com> writes:

> Daimrod <daimrod@gmail.com> writes:
>
>>
>> I agree with you, it would be much better if org-contacts managed
>> links
>> within properties.
> I think the two format have less difference
>
> org-android and org-android-NG can't show properties like outline,
> I expect to see the implement of this feature

Hmm, I don't understand what you want.
Do you need the outline format:
- to use it with another application/mode?
- to quickly show/hide contacts information?
- to support links?
- something else?

Regards,

-- 
Daimrod/Greg

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-16 12:25       ` Robert P. Goldman
@ 2013-04-17  8:14         ` Michael Strey
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Strey @ 2013-04-17  8:14 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, Apr 16, 2013 at 07:25:38AM -0500, Robert P. Goldman wrote:

[...]

> The reason I am reluctant to adopt tel: is that that would suggest we
> should adopt the phone number syntax of RFC 3966. I confess that I
> haven't slogged my way through it, nor am I likely to have time to in
> the near future....

[...]

> What do you all think? Am I being too fussy?

Yes ;-)

Honestly, using the `tel:' syntax doesn't require to adopt the complete
RFC 3966.  Your syntax rules can be more strict than those of RFC 3966
and nontheless phone numbers in the resulting org files will be
interpretable by all other systems that are able to do sensible things
of the RFC 3966 syntax (in particular MobileOrg).

Moreover my filtering function addresses at least some aspects of RFC
3966 allowing phone numbers like

     [[tel:(0351) 412 95-35]]
     [[tel:+49 351/412-95-35]]
     [[tel:+493514129535]]
     [[tel:+49-351-41295-35]]

Best regards
-- 
Michael Strey 
www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-16 22:22                 ` Daimrod
@ 2013-04-17 10:28                   ` Michael Strey
  2013-04-20 15:59                     ` Daimrod
  0 siblings, 1 reply; 44+ messages in thread
From: Michael Strey @ 2013-04-17 10:28 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Daimrod

Hi Greg,

Thank you for looking into my debut feature!

On Wed, Apr 17, 2013 at 12:22:14AM +0200, Daimrod wrote:
> Michael Strey <mstrey@strey.biz> writes:

[...]

> > It allows entries like in the following example without effecting
> > org-contacts current functions.
> >
> > #+BEGIN_SRC org
> > * Surname, Name
> > :PROPERTIES:
> > :EMAIL:    mailto:test2@test.de; [[mailto:name@test.de]] foo@bar.biz
> > :PHONE:    [[tel:+49 351 4129535]], +491766626196 [[+49 (351) 41295-35]]
                                                        ^
should be
:PHONE:    [[tel:+49 351 4129535]], +491766626196 [[tel:+49 (351) 41295-35]]
> > :END:
> > #+END_SRC

[...]

> Thank you for your patch, though here are a few suggestions:
> - It looks like `chomp' does the same thing the `org-trim' (in `org.el')
>   if so you should use it.

Done.  Thanks for the hint.

> - You should use `org-link-display-format' instead of
>   `org-contacts-strip-link'.

I don't think so.  `org-link-display-format' returns the description of
the link if there is one.  My `org-contacts-strip-link' always returns
the target.  Using `org-link-display-format' would lead to wrong results
with links like
     [[mailto:foo@bar.com][foo (at) bar (dot) com]]
     [[tel:+49 351 4129535][+49 (0)351 4129535]]

> - You have done some unrelated changes (fix some typos, ...), could you
>   provide a separated patches for them?

Oh =:-|, another struggle with Git.  I'm still learning and will do my best.

> Regarding `org-contacts-split-property', I haven't found anything about
> multiple values within a node property in `org-element' and the syntax
> description doesn't mention it, so you were right to roll your own. :)

That wasn't me.  This (disputable) feature was already there for the
:EMAIL: proprerty.  Actually, I don't like multiple values within a node
property and would prefer a VCard-like syntax like

#+BEGIN_SRC org
*** Strey, Michael
:PROPERTIES:
:KIND:     individual
:ORG:      STREY Consult
:FN:       Michael Strey
:N:        Strey;Michael;;
:ADR;TYPE=home:;;my street;my city;federal state;post code;my country
:EMAIL:           mailto:strey@myprovider.de
:EMAIL;PREF=1:    mailto:me@mycompany.biz
:TEL;TYPE="fax,work":[[tel:0321 21104568]]
:TEL;TYPE="fax,home":[[tel:0351 4129535]]
:TEL;TYPE="voice,home":[[tel:0351 4129535]]
:LANG:     de
:ICON:     ~/GTD/Icons/icon-strey_michael.jpg
:END:
#+END_SRC

> However, I think it would be better to store the separators in a
> variable (like `org-contacts-property-values-separator') and maybe even
> to use it by default instead of `split-string-default-separators'
> because we use it more and because it's easy to forget.

That was already hard-coded before in Feng's
`org-contacts-vcard-format'.  But yes, you are right.  Since it is
limited by some constraints we should make it an extra variable.

> 
> > +                (loop for email in (org-contacts-split-property email-list)
>                                                                            ^^^^
> > +                      for gravatar = (gravatar-retrieve-synchronously (org-contacts-strip-link email))

This should be correctly and worked for me during my tests.
Confusingly `email-list' is not a list but a string here.

Regards
-- 
Michael Strey
http://www.strey.biz

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: phone links...
  2013-04-17 10:28                   ` Michael Strey
@ 2013-04-20 15:59                     ` Daimrod
  2013-04-26 12:48                       ` [Patch] " Michael Strey
  0 siblings, 1 reply; 44+ messages in thread
From: Daimrod @ 2013-04-20 15:59 UTC (permalink / raw)
  To: emacs-orgmode

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

Michael Strey <mstrey@strey.biz> writes:

>> - You should use `org-link-display-format' instead of
>>   `org-contacts-strip-link'.
>
> I don't think so.  `org-link-display-format' returns the description of
> the link if there is one.  My `org-contacts-strip-link' always returns
> the target.  Using `org-link-display-format' would lead to wrong results
> with links like
>      [[mailto:foo@bar.com][foo (at) bar (dot) com]]
>      [[tel:+49 351 4129535][+49 (0)351 4129535]]

You're right, I had misunderstood the function.

>> - You have done some unrelated changes (fix some typos, ...), could you
>>   provide a separated patches for them?
>
> Oh =:-|, another struggle with Git.  I'm still learning and will do my best.

If you're not already using magit[1] I highly recommend it to you. You
can use it to commit only a portion of the changes (you can also do it
with "git commit --interactive" but I find it easier with magit).

>> Regarding `org-contacts-split-property', I haven't found anything about
>> multiple values within a node property in `org-element' and the syntax
>> description doesn't mention it, so you were right to roll your own. :)
>
> That wasn't me.  This (disputable) feature was already there for the
> :EMAIL: proprerty.  Actually, I don't like multiple values within a node
> property and would prefer a VCard-like syntax like
>
> #+BEGIN_SRC org
> *** Strey, Michael
> :PROPERTIES:
> :KIND:     individual
> :ORG:      STREY Consult
> :FN:       Michael Strey
> :N:        Strey;Michael;;
> :ADR;TYPE=home:;;my street;my city;federal state;post code;my country
> :EMAIL:           mailto:strey@myprovider.de
> :EMAIL;PREF=1:    mailto:me@mycompany.biz
> :TEL;TYPE="fax,work":[[tel:0321 21104568]]
> :TEL;TYPE="fax,home":[[tel:0351 4129535]]
> :TEL;TYPE="voice,home":[[tel:0351 4129535]]
> :LANG:     de
> :ICON:     ~/GTD/Icons/icon-strey_michael.jpg
> :END:
> #+END_SRC

I must admit I am unsure about this. On one side it does solve some
problems, on the other side I don't really like the idea of adding this
extra syntax on top of properties.

I think it's fine to use semicolons to separate values in node
properties, but I would like to expose a clean API to manipulate users
and user's properties so that we don't have to use `*-split-*'
everywhere.

For example it could expose your previous example into this:
#+BEGIN_SRC lisp
  '((kind "individual")
    (org "STREY Consult")
    (fn "Michael Strey")
    (n ("Stry" "Michael" ""))
    (adr ("" "" "my street" "my city" "federal state" "post code" "my country") :type home)
    (email "mailto:strey@myprovider.de")
    (email "mailto:me@mycompany.biz" :pref 1)
    (tel "[[tel:0321 21104568]]" :type "fax,work")
    (tel "[[tel:0351 4129535]]" :type "fax,home")
    (tel "[[tel:0351 4129535]]" :type "voice,home")
    (lang "de")
    (icon "~/GTD/Icons/icon-strey_michael.jpg"))  
#+END_SRC

>> However, I think it would be better to store the separators in a
>> variable (like `org-contacts-property-values-separator') and maybe even
>> to use it by default instead of `split-string-default-separators'
>> because we use it more and because it's easy to forget.
>
> That was already hard-coded before in Feng's
> `org-contacts-vcard-format'.  But yes, you are right.  Since it is
> limited by some constraints we should make it an extra variable.
>
>> 
>> > +                (loop for email in (org-contacts-split-property email-list)
>>                                                                            ^^^^
>> > +                      for gravatar = (gravatar-retrieve-synchronously (org-contacts-strip-link email))
>
> This should be correctly and worked for me during my tests.
> Confusingly `email-list' is not a list but a string here.

My bad (again :/).

Regards,

1. https://github.com/magit/magit

-- 
Daimrod/Greg

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Patch] phone links...
  2013-04-20 15:59                     ` Daimrod
@ 2013-04-26 12:48                       ` Michael Strey
  2013-04-30  9:09                         ` Daimrod
  2013-05-31  0:04                         ` Daimrod
  0 siblings, 2 replies; 44+ messages in thread
From: Michael Strey @ 2013-04-26 12:48 UTC (permalink / raw)
  To: emacs-orgmode

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

Greg,

Here are the reworked patches.

0390: fixes two typos
0391: contains all the changes from my last patch and your corrections
0392: introduces a constant for the default value of separators

Best regards
Michael Strey

On Sat, Apr 20, 2013 at 05:59:39PM +0200, Daimrod wrote:
> Michael Strey <mstrey@strey.biz> writes:

> > Oh =:-|, another struggle with Git.  I'm still learning and will do my best.
> 
> If you're not already using magit[1] I highly recommend it to you. You
> can use it to commit only a portion of the changes (you can also do it
> with "git commit --interactive" but I find it easier with magit).

Thanks for the hint.  It helped a lot.

-- 
Michael Strey 
www.strey.biz

[-- Attachment #2: 0390-org-contacts-Fix-two-typos-in-comments.patch --]
[-- Type: text/plain, Size: 1593 bytes --]

From 2b59a2800de7066dde72121bc72ba75ea88f3c5a Mon Sep 17 00:00:00 2001
From: Michael Strey <mstrey@strey.biz>
Date: Fri, 26 Apr 2013 12:06:34 +0200
Subject: [PATCH 390/392] org-contacts: Fix two typos in comments

* contrib/lisp/org-contacts.el (org-contacts-db): fix typo in the
  word `matching'.
* contrib/lisp/org-contacts.el (org-contacts-complete-group): fix typo
  in the word `found'.

TINYCHANGE
---
 contrib/lisp/org-contacts.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index a3c4aed..626ad7a 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -225,7 +225,7 @@ This overrides `org-email-link-description-format' if set."
     org-contacts-db))
 
 (defun org-contacts-filter (&optional name-match tags-match)
-  "Search for a contact maching NAME-MATCH and TAGS-MATCH.
+  "Search for a contact matching NAME-MATCH and TAGS-MATCH.
 If both match values are nil, return all contacts."
   (if (and (null name-match)
 	   (null tags-match))
@@ -433,7 +433,7 @@ A group FOO is composed of contacts with the tag FOO."
 				    (or (cdr (assoc-string "ALLTAGS" (caddr contact))) "") ":")))))))
 	(list start end
 	      (if (= (length completion-list) 1)
-		  ;; We've foudn the correct group, returns the address
+		  ;; We've found the correct group, returns the address
 		  (lexical-let ((tag (get-text-property 0 'org-contacts-group
 							(car completion-list))))
 		    (lambda (string pred &optional to-ignore)
-- 
1.8.2


[-- Attachment #3: 0391-Org-contacts-Allow-org-links-in-properties.patch --]
[-- Type: text/plain, Size: 8610 bytes --]

From 68145d055b7a48821d9aec308cd44764a5b889ec Mon Sep 17 00:00:00 2001
From: Michael Strey <mstrey@strey.biz>
Date: Fri, 26 Apr 2013 12:29:55 +0200
Subject: [PATCH 391/392] Org-contacts: Allow org links in properties

* contrib/lisp/org-contacts.el (org-contacts-split-property):
  Introduce a custom version of split-string that keeps org links
  intact.

* contrib/lisp/org-contacts.el (org-contacts-strip-link): Introduce a
  new function that removes brackets, description, link type and colon
  from an org link string returning the pure link target.

* contrib/lisp/org-contacts.el (provide 'org-contacts): Remove a
  redundant line.

* contrib/lisp/org-contacts.el (org-contacts-complete-group,
  org-contacts-complete-name, org-contacts-view-send-email,
  org-contacts-get-icon, org-contacts-vcard-format): Apply the new
  functions to the already existing functions extracting telephone
  numbers and email addresses from the properties.

Allowed separators for email addresses and phone numbers are `,', `;'
and whitespace.  `:' is not allowed anymore as separator to avoid
confusion with implizit links.

Examples of properties that are possible after those changes:

* Surname, Name
:PROPERTIES:
:EMAIL:    mailto:test2@test.de; [[mailto:name@test.de]] foo@bar.biz
:PHONE:    [[tel:+49 351 4129535]], +491766626196 [[+49 (351) 41295-35]]
:END:

Phone links of the form [[tel:+49 351 412 95-35][My phone number]] or
[[tel:+49 351 41295-35]] are expected.  `-', `/', `(', `)' and
whitespace characters are allowed in telephone numbers.
---
 contrib/lisp/org-contacts.el | 73 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 61 insertions(+), 12 deletions(-)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index 626ad7a..eb3fc09 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -445,11 +445,11 @@ A group FOO is composed of contacts with the tag FOO."
 				       ;; returned by `org-contacts-filter'.
 				       for contact-name = (car contact)
 				       ;; Grab the first email of the contact
-				       for email = (car (split-string
+				       for email = (org-contacts-strip-link (car (org-contacts-split-property
 							 (or
 							  (cdr (assoc-string org-contacts-email-property
 									     (caddr contact)))
-							  "")))
+							  ""))))
 				       ;; If the user has an email address, append USER <EMAIL>.
 				       if email collect (org-contacts-format-email contact-name email))
 				 ", ")))
@@ -466,14 +466,14 @@ A group FOO is composed of contacts with the tag FOO."
 		;; returned by `org-contacts-filter'.
 		for contact-name = (car contact)
 		;; Build the list of the user email addresses.
-		for email-list = (split-string (or
+		for email-list = (org-contacts-split-property (or
 						(cdr (assoc-string org-contacts-email-property
 								   (caddr contact))) ""))
 		;; If the user has email addresses…
 		if email-list
 		;; … append a list of USER <EMAIL>.
 		nconc (loop for email in email-list
-			    collect (org-contacts-format-email contact-name email))))
+			    collect (org-contacts-format-email contact-name (org-contacts-strip-link email)))))
 	 (completion-list (org-contacts-all-completions-prefix
 			   string
 			   (org-uniquify completion-list))))
@@ -738,11 +738,12 @@ address."
     (org-with-point-at marker
       (let ((emails (org-entry-get (point) org-contacts-email-property)))
         (if emails
-            (let ((email-list (split-string emails)))
+            (let ((email-list (org-contacts-split-property emails)))
               (if (and (= (length email-list) 1) (not ask))
                   (compose-mail (org-contacts-format-email
                                  (org-get-heading t) emails))
                 (let ((email (completing-read "Send mail to which address: " email-list)))
+		  (setq email (org-contacts-strip-link email))
                   (org-contacts-check-mail-address email)
                   (compose-mail (org-contacts-format-email (org-get-heading t) email)))))
           (error (format "This contact has no mail address set (no %s property)."
@@ -766,8 +767,8 @@ address."
              (email-list (org-entry-get pom org-contacts-email-property))
              (gravatar
               (when email-list
-                (loop for email in (split-string email-list)
-                      for gravatar = (gravatar-retrieve-synchronously email)
+                (loop for email in (org-contacts-split-property email-list)
+                      for gravatar = (gravatar-retrieve-synchronously (org-contacts-strip-link email))
                       if (and gravatar
                               (not (eq gravatar 'error)))
                       return gravatar))))
@@ -849,19 +850,19 @@ to do our best."
 	 (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name)))
     (concat head
 	    (when email (progn
-			  (setq emails-list (split-string email "[,;: ]+"))
+			  (setq emails-list (org-contacts-split-property email "[,; ]+"))
 			  (setq result "")
 			  (while emails-list
-			    (setq result (concat result  "EMAIL:" (car emails-list) "\n"))
+			    (setq result (concat result  "EMAIL:" (org-contacts-strip-link (car emails-list)) "\n"))
 			    (setq emails-list (cdr emails-list)))
 			  result))
 	    (when addr
 	      (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr)))
 	    (when tel (progn
-			(setq phones-list (split-string tel "[,;: ]+"))
+			(setq phones-list (org-contacts-split-property tel "[,; ]+"))
 			(setq result "")
 			(while phones-list
-			  (setq result (concat result  "TEL:" (car phones-list) "\n"))
+			  (setq result (concat result  "TEL:" (org-contacts-strip-link (car phones-list)) "\n"))
 			  (setq phones-list (cdr phones-list)))
 			result))
 	    (when bday
@@ -910,7 +911,55 @@ Requires google-maps-el."
     if addr
     collect (cons (list addr) (list :label (string-to-char (car contact)))))))
 
-(provide 'org-contacts)
+(defun org-contacts-strip-link (link)
+  "Remove brackets, description, link type and colon from an org link string and return the pure link target."
+   (let (startpos colonpos endpos)
+     (setq startpos (string-match (regexp-opt '("[[tel:" "[[mailto:")) link))
+     (if startpos
+         (progn
+            (setq colonpos (string-match ":" link))
+            (setq endpos (string-match "\\]" link))
+            (if endpos (substring link (1+ colonpos) endpos) link))
+         (progn
+            (setq startpos (string-match "mailto:" link))
+            (setq colonpos (string-match ":" link))
+            (if startpos (substring link (1+ colonpos)) link)))))
+
+(defun org-contacts-split-property (string &optional separators omit-nulls)
+  "Custom version of `split-string'.
+Split a property STRING into sub-strings bounded by matches
+for SEPARATORS but keep Org links intact.
+
+The beginning and end of STRING, and each match for SEPARATORS, are
+splitting points.  The substrings matching SEPARATORS are removed, and
+the substrings between the splitting points are collected as a list,
+which is returned.
+
+If SEPARATORS is non-nil, it should be a regular expression matching text
+which separates, but is not part of, the substrings.  If nil it defaults to
+`split-string-default-separators', normally \"[ \\f\\t\\n\\r\\v]+\", and
+OMIT-NULLS is forced to t.
+
+If OMIT-NULLS is t, zero-length substrings are omitted from the list \(so
+that for the default value of SEPARATORS leading and trailing whitespace
+are effectively trimmed).  If nil, all zero-length substrings are retained."
+(let* ((keep-nulls (or nil omit-nulls))
+         (rexp (or separators split-string-default-separators))
+         (inputlist (split-string string rexp keep-nulls))
+         (linkstring "")
+         (bufferstring "")
+         (proplist (list "")))
+    (while inputlist
+      (setq bufferstring (pop inputlist))
+      (if (string-match "\\[\\[" bufferstring)
+          (progn
+            (setq linkstring (concat bufferstring " "))
+            (while (not (string-match "\\]\\]" bufferstring))
+              (setq bufferstring (pop inputlist))
+              (setq linkstring (concat  linkstring bufferstring " ")))
+            (setq proplist (cons (org-trim linkstring) proplist)))
+        (setq proplist (cons bufferstring proplist))))
+    (cdr (reverse proplist))))
 
 (provide 'org-contacts)
 
-- 
1.8.2


[-- Attachment #4: 0392-Org-contacts-Introduce-the-constant-org-contacts-pro.patch --]
[-- Type: text/plain, Size: 4322 bytes --]

From a4018be0b34c3c40ad6b43f2380e0fd52a171591 Mon Sep 17 00:00:00 2001
From: Michael Strey <mstrey@strey.biz>
Date: Fri, 26 Apr 2013 13:57:46 +0200
Subject: [PATCH 392/392] Org-contacts: Introduce the constant
 `org-contacts-property-values-separators'

* contrib/lisp/org-contacts.el (org-contacts-property-values-separators):
  Definition of a new constant that will be used as default value of
  separators for `org-contacts-split-property'.

* contrib/lisp/org-contacts.el (org-contacts-vcard-format): We are now
  using the default separator in general.

* contrib/lisp/org-contacts.el (org-contacts-show-map): Line break
  corrected.

* contrib/lisp/org-contacts.el (org-contacts-split-property): Correct
  the comment describing the function.  Application of the newly
  defined constant `org-contacts-property-values-separators'.
---
 contrib/lisp/org-contacts.el | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index eb3fc09..84ebc9d 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -174,6 +174,11 @@ This overrides `org-email-link-description-format' if set."
 (declare-function std11-narrow-to-header "ext:std11")
 (declare-function std11-fetch-field "ext:std11")
 
+(defconst org-contacts-property-values-separators "[,; \f\t\n\r\v]+"
+  "The default value of separators for `org-contacts-split-property'.
+
+A regexp matching strings of whitespace, `,' and `;'.")
+
 (defvar org-contacts-keymap
   (let ((map (make-sparse-keymap)))
     (define-key map "M" 'org-contacts-view-send-email)
@@ -850,7 +855,7 @@ to do our best."
 	 (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name)))
     (concat head
 	    (when email (progn
-			  (setq emails-list (org-contacts-split-property email "[,; ]+"))
+			  (setq emails-list (org-contacts-split-property email))
 			  (setq result "")
 			  (while emails-list
 			    (setq result (concat result  "EMAIL:" (org-contacts-strip-link (car emails-list)) "\n"))
@@ -859,7 +864,7 @@ to do our best."
 	    (when addr
 	      (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr)))
 	    (when tel (progn
-			(setq phones-list (org-contacts-split-property tel "[,; ]+"))
+			(setq phones-list (org-contacts-split-property tel))
 			(setq result "")
 			(while phones-list
 			  (setq result (concat result  "TEL:" (org-contacts-strip-link (car phones-list)) "\n"))
@@ -912,7 +917,8 @@ Requires google-maps-el."
     collect (cons (list addr) (list :label (string-to-char (car contact)))))))
 
 (defun org-contacts-strip-link (link)
-  "Remove brackets, description, link type and colon from an org link string and return the pure link target."
+  "Remove brackets, description, link type and colon from an org
+link string and return the pure link target."
    (let (startpos colonpos endpos)
      (setq startpos (string-match (regexp-opt '("[[tel:" "[[mailto:")) link))
      (if startpos
@@ -935,16 +941,16 @@ splitting points.  The substrings matching SEPARATORS are removed, and
 the substrings between the splitting points are collected as a list,
 which is returned.
 
-If SEPARATORS is non-nil, it should be a regular expression matching text
-which separates, but is not part of, the substrings.  If nil it defaults to
-`split-string-default-separators', normally \"[ \\f\\t\\n\\r\\v]+\", and
-OMIT-NULLS is forced to t.
+If SEPARATORS is non-nil, it should be a regular expression
+matching text which separates, but is not part of, the
+substrings.  If nil it defaults to `org-contacts-property-values-separators',
+normally \"[,; \f\t\n\r\v]+\", and OMIT-NULLS is forced to t.
 
 If OMIT-NULLS is t, zero-length substrings are omitted from the list \(so
 that for the default value of SEPARATORS leading and trailing whitespace
 are effectively trimmed).  If nil, all zero-length substrings are retained."
 (let* ((keep-nulls (or nil omit-nulls))
-         (rexp (or separators split-string-default-separators))
+         (rexp (or separators org-contacts-property-values-separators))
          (inputlist (split-string string rexp keep-nulls))
          (linkstring "")
          (bufferstring "")
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [Patch] phone links...
  2013-04-26 12:48                       ` [Patch] " Michael Strey
@ 2013-04-30  9:09                         ` Daimrod
  2013-05-31  0:04                         ` Daimrod
  1 sibling, 0 replies; 44+ messages in thread
From: Daimrod @ 2013-04-30  9:09 UTC (permalink / raw)
  To: emacs-orgmode

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

Michael Strey <mstrey@strey.biz> writes:

> Greg,
>
> Here are the reworked patches.
>
> 0390: fixes two typos
> 0391: contains all the changes from my last patch and your corrections
> 0392: introduces a constant for the default value of separators

Excellent.

> On Sat, Apr 20, 2013 at 05:59:39PM +0200, Daimrod wrote:
>> Michael Strey <mstrey@strey.biz> writes:
>
>> > Oh =:-|, another struggle with Git.  I'm still learning and will do my best.
>> 
>> If you're not already using magit[1] I highly recommend it to you. You
>> can use it to commit only a portion of the changes (you can also do it
>> with "git commit --interactive" but I find it easier with magit).
>
> Thanks for the hint.  It helped a lot.

Merged & pulled. Thanks!

-- 
Daimrod/Greg

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [Patch] phone links...
  2013-04-26 12:48                       ` [Patch] " Michael Strey
  2013-04-30  9:09                         ` Daimrod
@ 2013-05-31  0:04                         ` Daimrod
  1 sibling, 0 replies; 44+ messages in thread
From: Daimrod @ 2013-05-31  0:04 UTC (permalink / raw)
  To: emacs-orgmode

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

Michael Strey <mstrey@strey.biz> writes:

Hello Michael,

While merging a patch (from Feng Shu) I have found a bug in
`org-contacts-split-property'. Though the docstring says that OMIT-NULLS
is forced to t when SEPARATORS is nil (just like `split-string'), it
wasn't the case. I've pushed a fix; could you check on your side that it
doesn't break anything in your workflow?

Thanks,

-- 
Daimrod/Greg

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2013-05-31  0:00 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-29 23:23 phone links Robert Goldman
2013-03-30  9:12 ` Karl Voit
2013-04-01 13:30 ` Robert Goldman
2013-04-03 14:52 ` Michael Strey
2013-04-03 15:05   ` Robert Goldman
2013-04-04  8:26     ` Michael Strey
2013-04-04 13:55       ` Michael Strey
2013-04-04 12:15 ` Bastien
2013-04-04 20:38   ` Simon Thum
2013-04-05  3:04     ` Robert P. Goldman
2013-04-05  6:42     ` Bastien
2013-04-06 12:05       ` Simon Thum
2013-04-06 12:10       ` Simon Thum
2013-04-06 20:58         ` Bastien
2013-04-05  2:38   ` Robert P. Goldman
2013-04-08 10:38     ` Michael Strey
2013-04-08 12:47       ` Robert Goldman
2013-04-08 14:07         ` Michael Strey
2013-04-08 14:44           ` Robert Goldman
2013-04-09  7:31             ` Michael Strey
2013-04-09 12:19               ` Robert Goldman
2013-04-09 14:40                 ` Michael Strey
2013-04-13 14:12               ` Feng Shu
2013-04-13 14:43                 ` Feng Shu
2013-04-14  8:38                   ` Bastien
2013-04-14 14:31                     ` Feng Shu
2013-04-15 15:39                       ` Bastien
2013-04-15 23:37                         ` Feng Shu
2013-04-16 21:11                       ` Daimrod
2013-04-17  3:55                         ` Feng Shu
2013-04-17  6:10                           ` Daimrod
2013-04-14 20:49               ` Michael Strey
2013-04-16 22:22                 ` Daimrod
2013-04-17 10:28                   ` Michael Strey
2013-04-20 15:59                     ` Daimrod
2013-04-26 12:48                       ` [Patch] " Michael Strey
2013-04-30  9:09                         ` Daimrod
2013-05-31  0:04                         ` Daimrod
2013-04-09  9:57       ` Feng Shu
2013-04-10 14:17 ` Michael Strey
2013-04-11 10:27   ` Michael Strey
2013-04-16  7:57     ` Eric S Fraga
2013-04-16 12:25       ` Robert P. Goldman
2013-04-17  8:14         ` Michael Strey

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.