Re: [O] phone links...

2013-04-20 Thread Daimrod
Michael Strey  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:f...@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:st...@myprovider.de
> :EMAIL;PREF=1:mailto:m...@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:st...@myprovider.de";)
(email "mailto:m...@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


pgpA1Yp4mnukl.pgp
Description: PGP signature


Re: [O] phone links...

2013-04-17 Thread Michael Strey
Hi Greg,

Thank you for looking into my debut feature!

On Wed, Apr 17, 2013 at 12:22:14AM +0200, Daimrod wrote:
> Michael Strey  writes:

[...]

> > It allows entries like in the following example without effecting
> > org-contacts current functions.
> >
> > #+BEGIN_SRC org
> > * Surname, Name
> > :PROPERTIES:
> > :EMAIL:mailto:te...@test.de; [[mailto:n...@test.de]] f...@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:f...@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:st...@myprovider.de
:EMAIL;PREF=1:mailto:m...@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



Re: [O] phone links...

2013-04-17 Thread Michael Strey
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



Re: [O] phone links...

2013-04-16 Thread Daimrod
Feng Shu  writes:

> Daimrod  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


pgpa_kck71TLW.pgp
Description: PGP signature


Re: [O] phone links...

2013-04-16 Thread Feng Shu
Daimrod  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,

-- 



Re: [O] phone links...

2013-04-16 Thread Daimrod
Michael Strey  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:te...@test.de; [[mailto:n...@test.de]] f...@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


pgpXWsW7sSTeB.pgp
Description: PGP signature


Re: [O] phone links...

2013-04-16 Thread Daimrod
Feng Shu  writes:

Hello Feng,

> Bastien  writes:
>
>> Hi Feng,
>>
>> Feng Shu  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


pgpqvdRQNKLgp.pgp
Description: PGP signature


Re: [O] phone links...

2013-04-16 Thread Robert P. Goldman
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  wrote:

> Michael Strey  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
> 



Re: [O] phone links...

2013-04-16 Thread Eric S Fraga
Michael Strey  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




Re: [O] phone links...

2013-04-15 Thread Feng Shu
Bastien  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

-- 



Re: [O] phone links...

2013-04-15 Thread Bastien
Hi Feng,

thanks for your reply.

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

Best,

-- 
 Bastien



Re: [O] phone links...

2013-04-14 Thread Feng Shu
Bastien  writes:

> Hi Feng,
>
> Feng Shu  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

-- 



Re: [O] phone links...

2013-04-14 Thread Michael Strey
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:te...@test.de; [[mailto:n...@test.de]] f...@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

From 69ae791cd552bacdcbc99af99a82ab699fa16d36 Mon Sep 17 00:00:00 2001
From: Michael Strey 
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:te...@test.de; [[mailto:n...@test.de]] f...@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 .
   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

Re: [O] phone links...

2013-04-14 Thread Bastien
Hi Feng,

Feng Shu  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



Re: [O] phone links...

2013-04-14 Thread Feng Shu

[update diff] make output format more beautiful

>From 500694de70f14095acc765875182d65feab7ef85 Mon Sep 17 00:00:00 2001
From: Feng Shu 
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: n...@n.com n...@n.com
 :PHONE: 123456789
 :END:

export as:

* NAME
** EMAIL: [[mailto:n...@n.com]]
** EMAIL: [[mailto:n...@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



-- 


Re: [O] phone links...

2013-04-13 Thread Feng Shu
Michael Strey  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:mst...@strey.biz f...@bar.com
> :PHONE:+493514129535 +491263213
> :END:
>
> [[mailto:mst...@strey.biz]]
> [[mailto:f...@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:n...@n.com]]
** EMAIL: [[mailto:n...@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.


>From 2c73cdfdf54fe4c882a3bc0d3ce3cd268555100e Mon Sep 17 00:00:00 2001
From: Feng Shu 
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: n...@n.com n...@n.com
 :PHONE: 123456789
 :END:

export as:

* NAME
** EMAIL: [[mailto:n...@n.com]]
** EMAIL: [[mailto:n...@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* ((fi

Re: [O] phone links...

2013-04-11 Thread Michael Strey
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



Re: [O] phone links...

2013-04-10 Thread Michael Strey
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:te...@test.de; n...@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



Re: [O] phone links...

2013-04-09 Thread Michael Strey
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



Re: [O] phone links...

2013-04-09 Thread Robert Goldman
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:mst...@strey.biz f...@bar.com
> :PHONE:+493514129535 +491263213
> :END:
> 
> [[mailto:mst...@strey.biz]]
> [[mailto:f...@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:mst...@strey.biz f...@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 ).

Cheers,
r






Re: [O] phone links...

2013-04-09 Thread Feng Shu
Michael Strey  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

-- 



Re: [O] phone links...

2013-04-09 Thread Michael Strey
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:mst...@strey.biz f...@bar.com
:PHONE:+493514129535 +491263213
:END:

[[mailto:mst...@strey.biz]]
[[mailto:f...@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



Re: [O] phone links...

2013-04-08 Thread Robert Goldman
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




Re: [O] phone links...

2013-04-08 Thread Michael Strey
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:f...@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



Re: [O] phone links...

2013-04-08 Thread Robert 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:f...@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...



Re: [O] phone links...

2013-04-08 Thread Michael Strey
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:f...@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



Re: [O] phone links...

2013-04-06 Thread Bastien
Hi Simon,

Simon Thum  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



Re: [O] phone links...

2013-04-06 Thread Simon Thum

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  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,






Re: [O] phone links...

2013-04-06 Thread Simon Thum

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  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,






Re: [O] phone links...

2013-04-04 Thread Bastien
Hi Simon,

Simon Thum  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



Re: [O] phone links...

2013-04-04 Thread Robert P. Goldman
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.



Re: [O] phone links...

2013-04-04 Thread Robert P. Goldman
On 4/4/13 Apr 4 -7:15 AM, Bastien wrote:
> Hi Robert,
> 
> Robert Goldman  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




Re: [O] phone links...

2013-04-04 Thread Simon Thum
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  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!



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

Signed-off-by: Simon Thum 
---
 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



Re: [O] phone links...

2013-04-04 Thread Michael Strey
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



Re: [O] phone links...

2013-04-04 Thread Bastien
Hi Robert,

Robert Goldman  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



Re: [O] phone links...

2013-04-04 Thread Michael Strey
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



Re: [O] phone links...

2013-04-03 Thread 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 
;; 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)



Re: [O] phone links...

2013-04-03 Thread Michael Strey
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
;;; org-dial.el --- Provide org links to dial with the softphone
;;; application linphone

;; Copyright (C) 2011  Michael Strey

;; Author: Michael Strey 
;; 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 .

;;; 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


Re: [O] phone links...

2013-04-01 Thread Robert Goldman
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





Re: [O] phone links...

2013-03-30 Thread Karl Voit
* 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.

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




[O] phone links...

2013-03-29 Thread Robert Goldman
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 
;; 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'