Discussion:
[Abook-devel] How to manage groups/lists with abook?
Carlos Franke
2014-06-29 22:13:52 UTC
Permalink
Hello,

first, I realize this mailing list has the "-devel" suffix, but I just
didn't find any more suitable place to ask for support. Sorry if I am
bothering anyone—feel free to ignore me if that is the case.

My question: Is there a way to manage lists/groups of contacts with
abook? By "manage" I mean not mainly (but also) seeing and editing them
in the interactive interface, but most importantly having them show up
as results of "abook --mutt-query 
", so that one could easily use them
in a MUA.

What I found so far:
– There is an editable "Group" field in each contact's "OTHER" tab in
abook. I couldn't find a way to search for group names, though (neither
from within abook, nor with --mutt-query).
– There is a commit implementing "mutt groups support" in abook,
dating two years back:
http://sourceforge.net/p/abook/git/ci/8420245db43e7f7ac1c8414a275e633e1d56c
Roger
2014-06-29 23:48:37 UTC
Permalink
Here's what I do for categorizing my addressbook. I think this works far
better then any other internal method, and is a very simple or dummy proof
method.

# $HOME/.bashrc
alias abook-commercial="abook --datafile $HOME/.abook/addressbook-commercial"
alias abook-oss="abook --datafile $HOME/.abook/addressbook-oss"
alias abook-personal="abook --datafile $HOME/.abook/addressbook-personal"
alias abook-responded="abook --datafile $HOME/.abook/addressbook-responded"
alias abook-mutt="abook --datafile $HOME/.abook/addressbook-mutt"

* OSS = Open Source Software.

Or, create aliases using your preferred shell.
--
Roger
http://rogerx.freeshell.org/
Carlos Franke
2014-06-30 21:12:44 UTC
Permalink
Thanks, Roger!

However, in my use case* contacts may be part of more than one
list/group, so that with the setup you are suggesting (one abook
datafile per list) I would have to maintain quite a lot of redundant
information.—Unless there is some clever way to synchronize address
changes between abook datafiles, or maybe with one master file. On
first thought, that should be possible. Has anyone done this?

* (Say I have a list with people to send holiday greetings, one with
people to invite to parties, one with people that share a certain hobby
– these lists will most probably overlap.)

Carlos
Roger
2014-07-01 03:14:07 UTC
Permalink
* (Say I have a list with people to send holiday greetings, one with=
people=20
to invite to parties, one with people that share a certain hobby =
=E2=80=93 these=20
lists will most probably overlap.)
So you want to tag people into multiple categories? (ie. By=20
'send_holiday_greetings', 'party_people', ...)

I would probably keep a separate text file of names of people. Since=
I have no=20
friends, I do not have a necessity for this feature. ;-)

Either a separate text file, yes redundant, but still simple and I'll=
bet dummy=20
proof as it will force the user to verify the list instead of just as=
suming=20
those tagged are still your friends. ;-)

Also, grep & awk/gawk are your friend. ;-)

Another probably better option, enter the custom field with your stan=
dard tag=20
item name (ie. holiday_cards, party_people, ...) and then use awk/gaw=
k to=20
search for contacts having those tags. Once a contact is found with =
a matching=20
tag name, selecting that contact and send to stdout.

Try searching for 'gawk|awk abook', and you might find something alre=
ady=20
written?

--=20
Roger
http://rogerx.freeshell.org/
Carlos Franke
2014-07-01 08:56:48 UTC
Permalink
Post by Carlos Franke
* (Say I have a list with people to send holiday greetings, one
with people
Post by Carlos Franke
to invite to parties, one with people that share a certain hobby –
these
Post by Carlos Franke
lists will most probably overlap.)
So you want to tag people into multiple categories? (ie. By
'send_holiday_greetings', 'party_people', ...)
Yes, "tagging" is a better word. Plus querying for tags.
Either a separate text file, yes redundant, but still simple and I'll
bet dummy
proof
I might end up doing this. If the names on the list match their
corresponding abook entries, I can easily generate a list of up-to-date
email addresses from it by looping over the names with "abook
--mutt-query". Thank you for giving me this idea.
Another probably better option, enter the custom field with your
standard tag
item name (ie. holiday_cards, party_people, ...) and then use
awk/gawk to
search for contacts having those tags. Once a contact is found with
a matching
tag name, selecting that contact and send to stdout.
Sounds good, but only as good as the best awk (or other) script I can
come up with or find.

Carlos
Gabriel Striewe
2014-07-01 12:22:55 UTC
Permalink
Post by Carlos Franke
Post by Carlos Franke
Post by Carlos Franke
* (Say I have a list with people to send holiday greetings, one with
people
Post by Carlos Franke
to invite to parties, one with people that share a certain hobby – these
lists will most probably overlap.)
So you want to tag people into multiple categories? (ie. By
'send_holiday_greetings', 'party_people', ...)
Yes, "tagging" is a better word. Plus querying for tags.
Post by Carlos Franke
Either a separate text file, yes redundant, but still simple and I'll bet
dummy
proof
I might end up doing this. If the names on the list match their
corresponding abook entries, I can easily generate a list of up-to-date
email addresses from it by looping over the names with "abook --mutt-query".
Thank you for giving me this idea.
Post by Carlos Franke
Another probably better option, enter the custom field with your standard
tag
item name (ie. holiday_cards, party_people, ...) and then use awk/gawk to
search for contacts having those tags. Once a contact is found with a
matching
tag name, selecting that contact and send to stdout.
Sounds good, but only as good as the best awk (or other) script I can come
up with or find.
Carlos
Hello,

another idea: you might want to keep your contacts in a yaml file and then
generate your abook datafiles dynamically from those using whatever scripting
language you are most comfortable with (I personally would prefer perl over
awk).

This procedure has the nice side effect that you might as well generate the rc
files of your mail user agent (for example, and in my case: mutt) dynamically.
Like this you can achieve for example different highlighting colours for
different groups of email contacts.

In this case, you would define different contact groups with your
yaml/perl[WHATEVER OTHER SCRIPTING LANGUAGE] and then dynamically generate the
corresponding abook datafiles.

I did exactly this many years ago and never had to touch my rc files again.
However, somehow I lost track of this.

Your email has brought me back on the track again.

Gabriel
Carlos Franke
2014-07-23 11:44:03 UTC
Permalink
(This is in response to Gabriel's message from 1 July. Sorry for the
delay)
Post by Gabriel Striewe
another idea: you might want to keep your contacts in a yaml file and then
generate your abook datafiles dynamically
[
]
Post by Gabriel Striewe
In this case, you would define different contact groups with your
yaml/perl[WHATEVER OTHER SCRIPTING LANGUAGE] and then dynamically generate the
corresponding abook datafiles.
That would be a very elegant and flexible approach. I am, however,
reluctant to write and maintain my own backend like that, for 1) if
something breaks, I am on my own then, and 2) I am not very proficient
in programming, so coding even something as simple as this is not just
a quick side-project for me. (I didn't even get around yet to implement
the even simpler solution I proposed a few mails before.)
Post by Gabriel Striewe
I did exactly this many years ago and never had to touch my rc files again.
However, somehow I lost track of this.
If you still have your scripts from back then, I would be very
interested in having a look at them!

Carlos
l***@mailoo.org
2014-07-23 16:44:49 UTC
Permalink
Post by Gabriel Striewe
another idea: you might want to keep your contacts in a yaml file and then
generate your abook datafiles dynamically
[
]
Post by Gabriel Striewe
In this case, you would define different contact groups with your
yaml/perl[WHATEVER OTHER SCRIPTING LANGUAGE] and then dynamically generate the
corresponding abook datafiles.
That would be a very elegant and flexible approach. I am, however, reluctant
to write and maintain my own backend like that, for 1) if something breaks,
I am on my own then, and 2) I am not very proficient in programming, so
coding even something as simple as this is not just a quick side-project for
me. (I didn't even get around yet to implement the even simpler solution I
proposed a few mails before.)
I have some knowledge in perl, so if you told me exactly what you need,
I could write the script for you.
Carlos Franke
2014-07-25 09:47:08 UTC
Permalink
Post by l***@mailoo.org
I have some knowledge in perl, so if you told me exactly what you
need,
I could write the script for you.
Thank you for the offer! Alas, I am not confident that I myself know
what exactly I need, and I don't want to burden anyone with potentially
idle work.

To illustrate, I just implemented the system I proposed a few mails
earlier (groups are textfiles with lists of names, script uses "abook
--mutt-query" to get the corresponding email address for each name),
just to discover that I cannot use it for (auto-)completion in the MUA
I am using presenlty (Balsa), as that won't accept a list of addresses
as input, but always expects me to pick one of them.

That's not too bad, though, as I can of course simply copy-paste the
output of my script. It is too slow to be used for autocompletion
anyway, since given the opportunity, I have written it in Perl6 (yes,
six), which I have long wanted to get into. For those of you interested
1) a copy the script is attached to this email. (undocumented)
2) Balsa's somewhat strange handling of external address book commands
is documented here:
http://www.theochem.kth.se/~pawsa/balsa/help/ab-conf.html ("Writing
your own load scripts")

I have something I can be content with for now.

Loading...