* guile: add format 'quoted' to contacts, use it in the example script
This commit is contained in:
@ -41,7 +41,7 @@ exec guile -e main -s $0 $@
|
||||
(options (getopt-long args optionspec))
|
||||
(msg (string-append
|
||||
"usage: contacts-export [--help] [--muhome=<muhome>] "
|
||||
"--format=<org-contact|mutt-alias|mutt-ab|wanderlust|plain(*)> "
|
||||
"--format=<org-contact|mutt-alias|mutt-ab|wanderlust|quoted|plain(*)> "
|
||||
"--sort-by=<frequency(*)|newness> [--revert] [--limit=<n>]\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
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
(define-module (mu contact)
|
||||
:use-module (oop goops)
|
||||
:use-module (mu message)
|
||||
:use-module (texinfo string-utils)
|
||||
:export (
|
||||
<mu:contact>
|
||||
mu:name
|
||||
@ -104,7 +105,7 @@ matching EXPR."
|
||||
(define-method (mu:contact->string (contact <mu:contact>) (form <string>))
|
||||
"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")))))
|
||||
|
||||
Reference in New Issue
Block a user