From e87b5fd248e1eba65ce26383cfb85e1a6549ca97 Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 6 Jun 2012 08:17:24 +0300 Subject: [PATCH] * guile: add format 'quoted' to contacts, use it in the example script --- guile/examples/contacts-export | 3 ++- guile/mu/contact.scm | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/guile/examples/contacts-export b/guile/examples/contacts-export index 82186429..7f111b4d 100755 --- a/guile/examples/contacts-export +++ b/guile/examples/contacts-export @@ -41,7 +41,7 @@ exec guile -e main -s $0 $@ (options (getopt-long args optionspec)) (msg (string-append "usage: contacts-export [--help] [--muhome=] " - "--format= " + "--format= " "--sort-by= [--revert] [--limit=]\n")) (help (option-ref options 'help #f)) (muhome (option-ref options 'muhome #f)) @@ -65,6 +65,7 @@ exec guile -e main -s $0 $@ ;; make a list of all contacts (mu:for-each-contact (lambda (c) (set! contacts (cons c contacts)))) + ;; should we sort it? (if sort-by (set! contacts (sort! contacts diff --git a/guile/mu/contact.scm b/guile/mu/contact.scm index 5ca35685..7165a780 100644 --- a/guile/mu/contact.scm +++ b/guile/mu/contact.scm @@ -22,6 +22,7 @@ (define-module (mu contact) :use-module (oop goops) :use-module (mu message) + :use-module (texinfo string-utils) :export ( mu:name @@ -104,7 +105,7 @@ matching EXPR." (define-method (mu:contact->string (contact ) (form )) "Convert a contact to a string in format FORM, which is a string, either \"org-contact\", \"mutt-alias\", \"mutt-ab\", -\"wanderlust\" \"plain\"." +\"wanderlust\", \"quoted\" \"plain\"." (let* ((name (mu:name contact)) (email (mu:email contact)) (nick ;; simplistic nick guessing... (string-map @@ -126,4 +127,15 @@ either \"org-contact\", \"mutt-alias\", \"mutt-ab\", ((string= form "mutt-ab") (format #f "~a\t~a\t" email (or name ""))) + ((string= form "quoted") + (string-append + "\"" + (escape-special-chars + (string-append + (if name + (format #f "\"~a\" " name) + "") + (format #f "<~a>" email)) + "\"" #\\) + "\"")) (else (error "Unsupported format")))))