* contact management in emacs
@ 2021-02-27 11:08 Alan Schmitt
2021-02-27 11:31 ` Martin Steffen
` (4 more replies)
0 siblings, 5 replies; 31+ messages in thread
From: Alan Schmitt @ 2021-02-27 11:08 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1337 bytes --]
Hello,
This may be slightly off-topic for the list, but as I’m considering
org-contacts for my question, I hope it will be of interest here.
I would like to migrate my contact management to emacs, as I’m already
using it for email. My requirements are the following ones:
- address completion in emacs email clients (I currently use notmuch)
- support for multiple email addresses and custom fields
- creation of org links to contacts
- export to vcard format for synchronization to my mobile phone (using
vdirsyncer)
- keep the data under version control
I have looked at two tools, which almost seem fit for the job.
- ebdb does most of this, with the exception of vcard export (it seems
to be worked on, https://github.com/girzel/ebdb/issues/60), and I’m not
sure using version control on an sqlite file is a good idea.
- org-contacts also seem to have all the required features, including
vcard export (and if not sufficient there is
https://github.com/novoid/org-contacts2vcard). I was worried it was
unmaintained when looking at the copyright line, but I see in
https://code.orgmode.org/bzg/org-mode/commits/master/contrib/lisp/org-contacts.el
that there are recent commits to the file.
Do you manage your contacts in emacs? And if so, what tools or workflow
do you recommend?
Best,
Alan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 11:08 contact management in emacs Alan Schmitt
@ 2021-02-27 11:31 ` Martin Steffen
2021-02-27 13:20 ` andrés ramírez
2021-02-27 17:00 ` Dr. Arne Babenhauserheide
2021-02-27 16:53 ` Bob Newell
` (3 subsequent siblings)
4 siblings, 2 replies; 31+ messages in thread
From: Martin Steffen @ 2021-02-27 11:31 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
I use bbdb (big-brother data base). I use it since a looong time
already, and amassed 15000 or so contracts. It does what I want, it's
text-based, so versioning is not a problem.
I think it can do vcard export (though when I used vcards is a long
time ago, I can't remember if that was smooth, I think it was with one
of my first smart phone, and I wanted to quick fill up the phone book
there with my ``emacs-managed'' contact data base.).
One can add used defined fields (where one can ``match'' all contacts
for some criterion, and send then ``bulk'' email.
Org is also bbdb-aware, insofar one can do those links: instead of
[[file:xxxx][yyy]] one can use [[bbdb:somecriterion]].
I don't know if it matches your needs, but I can't say bad things about
that bbdb-thing.
Martin
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 11:31 ` Martin Steffen
@ 2021-02-27 13:20 ` andrés ramírez
2021-02-27 14:40 ` Eric S Fraga
2021-02-27 17:00 ` Dr. Arne Babenhauserheide
1 sibling, 1 reply; 31+ messages in thread
From: andrés ramírez @ 2021-02-27 13:20 UTC (permalink / raw)
To: Martin Steffen; +Cc: Alan Schmitt, emacs-orgmode
Hi. Martin and Alan.
>>>>> "Martin" == Martin Steffen <msteffen@ifi.uio.no> writes:
[...]
Martin> Org is also bbdb-aware, insofar one can do those links: instead of [[file:xxxx][yyy]]
Martin> one can use [[bbdb:somecriterion]].
bbdb anniversaries could also appear on agenda:
--8<---------------cut here---------------start------------->8---
10 days-agenda (W08-W09):
Wednesday 24 February 2021
Thursday 25 February 2021
Friday 26 February 2021
Saturday 27 February 2021
Sunday 28 February 2021
Monday 1 March 2021 W09
Tuesday 2 March 2021
Wednesday 3 March 2021
bbdb: [[bbdb:Pedro ][Pedro 61st custom anniversary]]
Thursday 4 March 2021
Friday 5 March 2021
--8<---------------cut here---------------end--------------->8---
Andrés Ramírez
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 13:20 ` andrés ramírez
@ 2021-02-27 14:40 ` Eric S Fraga
2021-02-27 15:12 ` andrés ramírez
2021-02-27 15:14 ` Martin Steffen
0 siblings, 2 replies; 31+ messages in thread
From: Eric S Fraga @ 2021-02-27 14:40 UTC (permalink / raw)
To: andrés ramírez; +Cc: emacs-orgmode
On Saturday, 27 Feb 2021 at 13:20, andrés ramírez wrote:
> bbdb anniversaries could also appear on agenda:
How do you get these to appear? Or is the "could" a wish?
thank you, eric
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-231-gf46925
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 14:40 ` Eric S Fraga
@ 2021-02-27 15:12 ` andrés ramírez
2021-02-28 10:21 ` Eric S Fraga
2021-02-27 15:14 ` Martin Steffen
1 sibling, 1 reply; 31+ messages in thread
From: andrés ramírez @ 2021-02-27 15:12 UTC (permalink / raw)
To: andrés ramírez, emacs-orgmode
Hi. Eric.
>>>>> "Eric" == Eric S Fraga <e.fraga@ucl.ac.uk> writes:
[...]
Eric> How do you get these to appear? Or is the "could" a wish?
This is my setup:
--8<---------------cut here---------------start------------->8---
(setq org-agenda-files (directory-files "~/docs/org/deft/" t ".*agenda\.org$"))
--8<---------------cut here---------------end--------------->8---
~/docs/org/deft/bbdb-anniversary-trick.agenda.org:
--8<---------------cut here---------------start------------->8---
* anniversary [isodate]
:PROPERTIES:
:CATEGORY: bbdb
:END:
%%(when (fboundp 'my/org-bbdb-anniversaries) (my/org-bbdb-anniversaries))
--8<---------------cut here---------------end--------------->8---
--8<---------------cut here---------------start------------->8---
(defun my/org-bbdb-anniversaries ()
"It does not work on emacs-23"
(when (/= 23 emacs-major-version)
(org-bbdb-anniversaries)
)
)
--8<---------------cut here---------------end--------------->8---
the bbdb record should have the field anniversary:
--8<---------------cut here---------------start------------->8---
anniversary: 1960-03-03 custom
--8<---------------cut here---------------end--------------->8---
Best Regards
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 14:40 ` Eric S Fraga
2021-02-27 15:12 ` andrés ramírez
@ 2021-02-27 15:14 ` Martin Steffen
1 sibling, 0 replies; 31+ messages in thread
From: Martin Steffen @ 2021-02-27 15:14 UTC (permalink / raw)
To: andrés ramírez; +Cc: emacs-orgmode
>>>>> "Eric" == Eric S Fraga <e.fraga@ucl.ac.uk> writes:
Eric> How do you get these to appear? Or is the "could" a wish?
It's ``automatic''. The entry of the person needs a field "anniversary",
if that's filled with a date in yyyy-mm-dd format, it's included
(perhaps one has to set a variable like ``show-bbdb-anniversaries''
and/or load a corresponding elisp-addition.)
Martin
Eric> thank you, eric -- : Eric S Fraga via Emacs 28.0.50, Org
Eric> release_9.4.4-231-gf46925
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 11:08 contact management in emacs Alan Schmitt
2021-02-27 11:31 ` Martin Steffen
@ 2021-02-27 16:53 ` Bob Newell
2021-02-28 9:06 ` Russell Adams
` (2 subsequent siblings)
4 siblings, 0 replies; 31+ messages in thread
From: Bob Newell @ 2021-02-27 16:53 UTC (permalink / raw)
To: emacs-orgmode
I've used BBDB for years, and have tried org-contact, but it
didn't seem to scale to the now rather large size of my BBDB
database.
I've looked at migrating to EBDB but as I have many custom
functions I haven't yet made the move.
BBDB can do amazing things. I've mentioned some of them
before. Of course org links are supported, and in conjunction
with the 'gnorb' package, Gnus email can be associated with
BBDB entries in interesting ways.
I use BBDB to easily maintain a slew of mailing lists. I also
have custom functions to set the input language mode for those
with whom I correspond in non-English languages. I even use
BBDB to initiate phone calls when I'm on my desktop computer.
I hadn't thought to put BBDB under version control but that
would be very easy.
However you don't need to get fancy right away. All the basics
are there. Like many things Emacs, it does take time to get
things set up the way you wish, but that time is well repaid
down the road a little.
--
Bob Newell
Honolulu, Hawai`i
- Via GNU/Linux/Emacs/Gnus/BBDB
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 11:31 ` Martin Steffen
2021-02-27 13:20 ` andrés ramírez
@ 2021-02-27 17:00 ` Dr. Arne Babenhauserheide
1 sibling, 0 replies; 31+ messages in thread
From: Dr. Arne Babenhauserheide @ 2021-02-27 17:00 UTC (permalink / raw)
To: Martin Steffen; +Cc: Alan Schmitt, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 429 bytes --]
Martin Steffen <msteffen@ifi.uio.no> writes:
> I use bbdb (big-brother data base). I use it since a looong time
> already, and amassed 15000 or so contracts. It does what I want, it's
> text-based, so versioning is not a problem.
And it is fast; lookup feels instantaneous — different from many other
address-manager solutions.
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 11:08 contact management in emacs Alan Schmitt
2021-02-27 11:31 ` Martin Steffen
2021-02-27 16:53 ` Bob Newell
@ 2021-02-28 9:06 ` Russell Adams
2021-02-28 11:09 ` Alan Schmitt
` (2 more replies)
2021-03-07 22:13 ` Jean Louis
2022-09-09 16:11 ` Sébastien Rey-Coyrehourcq
4 siblings, 3 replies; 31+ messages in thread
From: Russell Adams @ 2021-02-28 9:06 UTC (permalink / raw)
To: emacs-orgmode
On Sat, Feb 27, 2021 at 12:08:04PM +0100, Alan Schmitt wrote:
> Hello,
>
> This may be slightly off-topic for the list, but as I’m considering
> org-contacts for my question, I hope it will be of interest here.
>
> I would like to migrate my contact management to emacs, as I’m already
> using it for email. My requirements are the following ones:
> - address completion in emacs email clients (I currently use notmuch)
> - support for multiple email addresses and custom fields
> - creation of org links to contacts
> - export to vcard format for synchronization to my mobile phone (using
> vdirsyncer)
> - keep the data under version control
>
> I have looked at two tools, which almost seem fit for the job.
> - ebdb does most of this, with the exception of vcard export (it seems
> to be worked on, https://github.com/girzel/ebdb/issues/60), and I’m not
> sure using version control on an sqlite file is a good idea.
> - org-contacts also seem to have all the required features, including
> vcard export (and if not sufficient there is
> https://github.com/novoid/org-contacts2vcard). I was worried it was
> unmaintained when looking at the copyright line, but I see in
> https://code.orgmode.org/bzg/org-mode/commits/master/contrib/lisp/org-contacts.el
> that there are recent commits to the file.
>
> Do you manage your contacts in emacs? And if so, what tools or workflow
> do you recommend?
The only reason I don't use BBDB is I want to use Org to allow me to
maintain notes about contacts (ie: CRM). Yes, I get that I could have
a CRM file and link in BBDB contacts, but that feels like adding
layers.
The stumbling point for me has been exporting to my mobile phone. I'm
fine with a one way sync from my BBDB/Org solution to the phone, but
I feel like I never found a good option.
Please share what you find works for you.
------------------------------------------------------------------
Russell Adams RLAdams@AdamsInfoServ.com
PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/
Fingerprint: 1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 15:12 ` andrés ramírez
@ 2021-02-28 10:21 ` Eric S Fraga
0 siblings, 0 replies; 31+ messages in thread
From: Eric S Fraga @ 2021-02-28 10:21 UTC (permalink / raw)
To: andrés ramírez; +Cc: emacs-orgmode
On Saturday, 27 Feb 2021 at 15:12, andrés ramírez wrote:
> This is my setup:
Thank you for this. Works perfectly!
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-231-gf46925
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-28 9:06 ` Russell Adams
@ 2021-02-28 11:09 ` Alan Schmitt
2021-03-03 14:40 ` TRS-80
2021-03-07 22:57 ` Jean Louis
2 siblings, 0 replies; 31+ messages in thread
From: Alan Schmitt @ 2021-02-28 11:09 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 155 bytes --]
Hello,
Thanks a lot for all the replies. I migrated from bbdb to ebdb a long
time ago, and I may go back following your suggestions.
Thanks again,
Alan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-28 9:06 ` Russell Adams
2021-02-28 11:09 ` Alan Schmitt
@ 2021-03-03 14:40 ` TRS-80
2021-03-07 22:57 ` Jean Louis
2 siblings, 0 replies; 31+ messages in thread
From: TRS-80 @ 2021-03-03 14:40 UTC (permalink / raw)
To: emacs-orgmode
On 2021-02-28 04:06, Russell Adams wrote:
> The stumbling point for me has been exporting to my mobile
> phone. I'm fine with a one way sync from my BBDB/Org solution to the
> phone, but I feel like I never found a good option.
>
> Please share what you find works for you.
I never got further than reading about it, but I have done quite a lot
of that. And it always seems like this is the stumbling block.
Especially two way sync (as I probably most often add new contacts
into my phone, when I am out and about).
OTOH, my PinePhone has just recently shipped, so perhaps having an
actual GNU/Linux phone (instead of Android) may suddenly obviate the
need for all these complicated workarounds... I suppose I will be
interested in what sort of format the Contacts "app" will be storing
them on the PinePhone. In fact, I think I will search for (or make) a
thread about that at Pine64 forums...
Cheers,
TRS-80
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 11:08 contact management in emacs Alan Schmitt
` (2 preceding siblings ...)
2021-02-28 9:06 ` Russell Adams
@ 2021-03-07 22:13 ` Jean Louis
2021-03-08 7:49 ` Alan Schmitt
2022-09-09 16:11 ` Sébastien Rey-Coyrehourcq
4 siblings, 1 reply; 31+ messages in thread
From: Jean Louis @ 2021-03-07 22:13 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
* Alan Schmitt <alan.schmitt@polytechnique.org> [2021-02-27 14:09]:
> Hello,
>
> This may be slightly off-topic for the list, but as I’m considering
> org-contacts for my question, I hope it will be of interest here.
>
> I would like to migrate my contact management to emacs, as I’m already
> using it for email. My requirements are the following ones:
> - address completion in emacs email clients (I currently use
> notmuch)
Your question I consider very important.
I am using heavily contact management with Emacs and PostgreSQL
database. Connection between Emacs and the database is provided by the
module `emacs-libpq`: https://github.com/anse1/emacs-libpq Currently I
manage over 220,000 contacts and more than 10,000 groups that I have
named "accounts" in the database, following the long term CRM
conventions.
Address completion is simple, I press the key and query for contacts,
insert name with email address nicely formatted.
> - support for multiple email addresses and custom fields
I have made for myself such a system that I may designate Cc: Bcc:
fields or tell that all email addresses of certain person will be
used. That header format is automatically created on the fly when
composing emails. Some email attachments are sent by using external
program `mutt` on the command line. And I am using multiple
identities. Contact may have single identity or may be under account
that has assigned identity or under multiple accounts with assigned
identities.
> - creation of org links to contacts
As there is display of a contact or profile, and I keep also Org
profiles of a contact, thus I can also create simple link to the
contact. Link creation is also easy, query for contact, insert link.
> - export to vcard format for synchronization to my mobile phone (using
> vdirsyncer)
I have made my own exporter to vcards, so all contacts are managed by
using PostgreSQL database through Emacs. By pressing `A` I am entering
the contact into the address book. Program is meant to have multiple
address books, for example private address book could be for device
nr. 1 and business address book for device nr. 2. This way all my
devices are synchronized from my central computer. No need for remote
insecure cloud databases.
> - keep the data under version control
Any editing may be under the database backed version control. For
example in this function here below:
(defun hlink-change-type ()
(interactive)
(let ((id (tabulated-list-get-id)))
(when id
(let ((new-type (hlink-types)))
(when new-type
;; version control begins here
(hyperscope-vc "hlinks" "hlinks_hlinktypes" id)
(rcd-db-update-entry "hlinks" "hlinks_hlinktypes" "integer" id new-type *hs*)
(hyperscope-refresh id))))))
Simple function `hyperscope-vc` keeps care of the version control.
(defun hyperscope-vc (table column id &optional description)
"Simple version system."
(let* ((value (rcd-db-get-entry table column id *hs*))
(value (format "%s" value))
(value (sql-escape-string value))
(description (if description (sql-escape-string description) "NULL"))
(sql (format "INSERT into vc (vc_table,
vc_column,
vc_tableid,
vc_value,
vc_description) values ('%s', '%s', %s, %s, %s)
RETURNING vc_id"
table column id value description))
(id (rcd-sql sql *hs*)))
(if id id nil)))
Version control is thus not automatic, it has to be chosen by myself
which databases or which editing would be under version control. The
above function first obtains all values from the database and then
inserts them into the table `vc` in the database. I could then browse
the table and return back the values if I wish so. Once in the
function, I do not think about it any more.
> Do you manage your contacts in emacs? And if so, what tools or workflow
> do you recommend?
I am recommending that you start using PostgreSQL database. I can
guide you. My software is not so finished for public, but I can guide
you personally and you will get stable system that lasts for years.
First thing would be to setup the PostgreSQL module for Emacs from
sources. If you are able to do that, I can guide you to get the rest
of functionality.
Jean
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-28 9:06 ` Russell Adams
2021-02-28 11:09 ` Alan Schmitt
2021-03-03 14:40 ` TRS-80
@ 2021-03-07 22:57 ` Jean Louis
2021-03-08 20:06 ` John Kitchin
2 siblings, 1 reply; 31+ messages in thread
From: Jean Louis @ 2021-03-07 22:57 UTC (permalink / raw)
To: emacs-orgmode
* Russell Adams <RLAdams@AdamsInfoServ.Com> [2021-02-28 12:07]:
> The only reason I don't use BBDB is I want to use Org to allow me to
> maintain notes about contacts (ie: CRM). Yes, I get that I could have
> a CRM file and link in BBDB contacts, but that feels like adding
> layers.
I have replaced using Org file as the central system with the `people`
database as the central system. This may sound confusing. Instead of
using exclusively Org file, I am using the database and addint notes
to people in the database. A note can have any major or minor mode,
thus it could be text or Org file or markdown file, enriched mode or
restructured text, asciidoc, or similar.
My workflow is to find the person first, then press N to see notes, or
M-n to create a new note. Concepts I am explaining may serve some
people to create their own workflows.
Using database for that allows easily collaboration in real time with
other team members and inclusion or insertion of new contacts during
marketing activities without interruption. Org files are not suitable
for such collaborative updates.
> The stumbling point for me has been exporting to my mobile phone. I'm
> fine with a one way sync from my BBDB/Org solution to the phone, but
> I feel like I never found a good option.
bbdb-vcard package is here:
https://melpa.org/packages/bbdb-vcard-20201016.1902.tar
Jean
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-03-07 22:13 ` Jean Louis
@ 2021-03-08 7:49 ` Alan Schmitt
2021-03-08 8:12 ` Jose E. Marchesi
0 siblings, 1 reply; 31+ messages in thread
From: Alan Schmitt @ 2021-03-08 7:49 UTC (permalink / raw)
To: Jean Louis; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 394 bytes --]
Hello,
On 2021-03-08 01:13, Jean Louis <bugs@gnu.support> writes:
> I am recommending that you start using PostgreSQL database. I can
> guide you. My software is not so finished for public, but I can guide
> you personally and you will get stable system that lasts for years.
Thank you for the suggestion, but for the moment I think I will
experiment with text-based solutions.
Best,
Alan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-03-08 7:49 ` Alan Schmitt
@ 2021-03-08 8:12 ` Jose E. Marchesi
2021-03-10 8:32 ` Jean Louis
0 siblings, 1 reply; 31+ messages in thread
From: Jose E. Marchesi @ 2021-03-08 8:12 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode, Jean Louis
>> I am recommending that you start using PostgreSQL database. I can
>> guide you. My software is not so finished for public, but I can guide
>> you personally and you will get stable system that lasts for years.
>
> Thank you for the suggestion, but for the moment I think I will
> experiment with text-based solutions.
I use a recfile [1] to manage contacts.
[1] http://www.gnu.org/s/recutils
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-03-07 22:57 ` Jean Louis
@ 2021-03-08 20:06 ` John Kitchin
2021-03-10 8:32 ` Jean Louis
0 siblings, 1 reply; 31+ messages in thread
From: John Kitchin @ 2021-03-08 20:06 UTC (permalink / raw)
To: Jean Louis; +Cc: emacs-orgmode
This question is going to go a little off the original topic. I wonder
how far you can push your model of replacing the org-file with a
database. It looks like it would be easy to extend to something like a
shared bibliography.
How far could you push it for something like a shared set of documents,
e.g. a shared notebook on a project? How feasible would it be to access
tables or src blocks in these if they were in a database? or to build an
agenda from entries in the database?
Jean Louis <bugs@gnu.support> writes:
> * Russell Adams <RLAdams@AdamsInfoServ.Com> [2021-02-28 12:07]:
>> The only reason I don't use BBDB is I want to use Org to allow me to
>> maintain notes about contacts (ie: CRM). Yes, I get that I could have
>> a CRM file and link in BBDB contacts, but that feels like adding
>> layers.
>
> I have replaced using Org file as the central system with the `people`
> database as the central system. This may sound confusing. Instead of
> using exclusively Org file, I am using the database and addint notes
> to people in the database. A note can have any major or minor mode,
> thus it could be text or Org file or markdown file, enriched mode or
> restructured text, asciidoc, or similar.
>
> My workflow is to find the person first, then press N to see notes, or
> M-n to create a new note. Concepts I am explaining may serve some
> people to create their own workflows.
>
> Using database for that allows easily collaboration in real time with
> other team members and inclusion or insertion of new contacts during
> marketing activities without interruption. Org files are not suitable
> for such collaborative updates.
>
>> The stumbling point for me has been exporting to my mobile phone. I'm
>> fine with a one way sync from my BBDB/Org solution to the phone, but
>> I feel like I never found a good option.
>
> bbdb-vcard package is here:
> https://melpa.org/packages/bbdb-vcard-20201016.1902.tar
>
> Jean
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-03-08 20:06 ` John Kitchin
@ 2021-03-10 8:32 ` Jean Louis
0 siblings, 0 replies; 31+ messages in thread
From: Jean Louis @ 2021-03-10 8:32 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
* John Kitchin <jkitchin@andrew.cmu.edu> [2021-03-08 23:06]:
> This question is going to go a little off the original topic. I wonder
> how far you can push your model of replacing the org-file with a
> database.
Those functions which I use most often I can fully replace with the
database work. The visual stuff is handled by tabulated-list-mode, so
I cannot currently see the contents of a simple heading unless I press
a key. But I am sure that database based Org style editing is possible
in general.
What I mean is that one could have an Org file displayed but
internally all of its structures could be translated on the fly into
the database. This would allow collaboration with many users and
finely based version control of each elements of the structure.
I think that automatic update and version control of each contents of
a heading could be saved to database, or it could be saved to database
by using key or by switching from one heading to other heading.
If user switches to other heading, would that other heading be edited
by other user in the same time, that other heading could be
automatically updated.
I was making simple functions to move Org headings into the database,
and functions to move database entries into Org files on the fly.
IMHO, what Org does is either intentionally or not intentionally, or
mixed-wise related to Doug Engelbart's work.
TECHNOLOGY TEMPLATE PROJECT OHS Framework
https://www.dougengelbart.org/content/view/110/460/
> This question is going to go a little off the original topic. I wonder
> how far you can push your model of replacing the org-file with a
> database.
After that introduction, and I hope you understand what I wrote (as I
am not sure if I have expressed myself well enough), then I can answer
how far it may be pushed. I have defined in my software Hyperscope
that each node can have different type. All nodes have its ID
numbers. So now I could say that nodes have various finely grained
types such as:
- Subtree (This could be considered either heading or title in Org
editing), it contains other nodes.
- headings or subtrees within subtree are similar to sub-headings in
Org editing
- I can define Org Babel-like nodes, for example now I have SQL
output, I can enter SQL SELECT and get the report. That type of node
definition is alternative to Org Babel. I did not work much on it,
but it is not hard to define. As soon as the node type is defined,
inside of the node type there could be defined, even inside of the
database, on how to run or execute that code block. Right now I am
hardcoding that.
- then I can go finely grained, I could say: this node is
paragraph. But I need not do that.
- then I could go more finely grained, I could say this node is a list
of items, but I could also say this node is one item within a list.
- I could say this is one line as node, or this is one sentence as
node.
- I could say this is one word within a sentence.
That means I can defined "Elementary objects" as defined here:
https://www.dougengelbart.org/content/view/110/460/#2a1a
Objects are basic content packets of an arbitrary, user and developer
extensible nature. Types of elementary objects could contain text,
graphics, equations, tables, spreadsheets, canned-images, video,
sound, code elements, etc.
Now you can imagine that those paragraphs could be reused in various
Org files, reusing such paragraphs becomes trivial. There is no copy
and paste any more, just one time definition where some paragraph
shall be inserted:
- edit subtree of nodes
- decide where to insert some other existing node
- insert it and forget about it
This then allows editing of the subtree (Org equivalent) node A or
node B, and each time that paragraph is edited it is also changed in
the other subtree. Copying subtrees so that they do not synchronize is
naturally possible.
Finely grained definition of nodes allows for finely grained
referencing to those nodes what is currently not possible with Org
mode. I have researched that option.
Review this page: https://www.dougengelbart.org/content/view/110/460/
and you will see how each paragraph is finely referenced on that
page. Specific referencing enhances educational capabilities in
specialization on specific subject. It saves times, efforts, also a
lot of money.
Imagine group of 20 miners and their 3 administrators who are supposed
to work on a lead mine, they did finish their general education, but
now they are faced with specialized subject of "lead mining". Having a
very precise set of references to lead mining saves money, as
education of miners and administrators is paid in their salaries, if
they are reading irrelevant instructions or if they are offered whole
books to read and find references themselves, that would spend 20
times plus 3 times more money for their time to gain that special
knowledge. Having a finely grained set of references that has to be
read by those specific people specializes those people to the specific
subject of knowledge quickly and efficiently, they can get only
information that relates to galena as mineral, melting, refining,
collecting of galena and processing of it.
Fine referencing thus helps in research and education and other
subjects.
To index bodies of knowledge is not so hard with computerized
information. Once index is made, such index contains the subject, for
example "galena". By using larger index, one can then form and curate
a subtree or heading of nodes and use that heading for education to
specialize miners in a specific subject.
Indexing and converting to Org file is possible, then if one does not
work with database, one can still select those headings that relate to
specific subject with Emacs functions and then copy and paste those
specific headings into a new file.
But what if any node is changed either in the new file or the main
index? They are not automatically synchronized. Database backed
editing allows automatic synchronization. Or nodes may be made
separate by duplicating them.
It also allows instead of creating a new subtree, to create just a
result based on query and exclude/include some other lines and create
new Org file with those entries for later research. Org file can be
converted to PDF and distributed to people.
> It looks like it would be easy to extend to something like a shared
> bibliography.
I wish I could understand better what you mean with shared
bibliography. Explain me better.
As side notes to bibliography subject, in the table of nodes I have
included some basic bibliographic entries, but not all, I have not
been thinking enough of that. I do use it for finely grained personal
bibliographic collection of hyperlinks and hyperdocuments and now I
have more than 20000 items, mostly PDF files with references to
articles inside of PDF file, their titles and similar. It is like
index of indexes. Subtrees or all system can be converted to Org files
on the fly and saved if necessary, but there is much work to make it
more detailed and nice, well hyperlinked.
Table `hlinks' should be maybe called hyperdocuments, but I chose this
name for now, has the following structure:
hlinks_id
hlinks_datecreated
hlinks_datemodified
hlinks_usercreated
hlinks_usermodified
hlinks_hlinkstatuses
hlinks_date
hlinks_expiration
hlinks_curator
hlinks_hlinktypes
hlinks_mimetypes
hlinks_name
hlinks_link
hlinks_arguments
hlinks_description
hlinks_text
hlinks_tags
hlinks_parent
hlinks_author
hlinks_hlinkpermissions
hlinks_revision
hlinks_numberofpages
hlinks_language
hlinks_filesize
hlinks_timelength
hlinks_width
hlinks_height
hlinks_hash
hlinks_signature p
hlinks_pages
hlinks_accounts
hlinks_people
hlinks_businesses
hlinks_opportunities
hlinks_priorities
hlinks_authorname
hlinks_properties
hlinks_elisphash
hlinks_publisher
hlinks_groups
hlinks_groupassigned
hlinks_assignedperson
hlinks_rank
hlinks_active
hlinks_actionstatuses
hlinks_globalpriority
hlinks_relatedfile
The nature of the database is collaborative. Adding new users and
allowing users finely grained access is possible. Users could edit
either all tables and fields, or just some tables and fields. Those
features are handled by the database and configuration, not by users'
run program (as otherwise user could circumvent it).
Users could access the database from any distant location and edit
nodes. Output could be Org file or any other output, but using Org
file as output is beneficial as Org itself has many various other
export formats.
This type of work is not well suitable for collaborative real time
online editing. However, it is suitable for concurrent non-real time
editing of any items.
For example, user A could designate new scheduled time, but user B
could change the scheduled time to something else. All changes can be
inside of the database backed version control to see who changed what
at which time. It is suitable for collaborative business or
organization work. Marketing, sales, communications, notes, anything
is possible when collaboration takes place.
Example workflow could be:
- manager views Org file of customer Joe
- assign customer Joe to salesman Jane
- salesman Jane calls customer and makes notes on customer Joe
- manager is notified of note visualized in Org file, it seem like
customer Joe was handled in past better by salesman Juan
- manager schedules call to customer Joe by Juan at Tuesday 10 o'clock
- Juan calls customer at 10:30 Tuesday and closes the sale, invoice is
generated
- all parties, manager, salesmen Jane and Juan can view what has taken
place, visualization can take place as Org file
By using the package `crdt' from
https://code.librehq.com/qhong/crdt.el.git one can involve online
real-time collaboration of a single item. This works right now with
Org mode.
Each node of the database system could be edited with `crdt-mode'
enabled if one requires real time online collaboration.
> How far could you push it for something like a shared set of documents,
> e.g. a shared notebook on a project?
Each node is considered elementary object. There are no files. But
each node can be exported into a file.
As it is database backed, it is already shared notebook. Each subtree
can be considered Org file or Mixed-Object documents as defined by
Engelbart institute.
> How feasible would it be to access tables or src blocks in these if
> they were in a database?
Just as easy:
- concurrent updates, additions and deletions are possible with the
automated database backed version control (no thinking).
- real time online collaborative editing is possible with `crdt'
package for single entries
- editing any entry, any node in the database can be done by any
mode, not just Org mode. If I define the type of the node to be Org
type, then editing switches to Org mode and I can edit the tables by
using Org mode. When saved, table is saved in the database, but can
be if user wish and want, be also each time saved into the file as
full Org or single node.
- src blocks I mostly constuct from SQL select statements, so they
contain SQL, and I have implemented node with SQL, so I just put SQL
statement there, it provides the report just as Org babel. It is not
hard to implement any language and get literate programming
functions.
Similar node based editing is provided by Leo editor, also inspired by
Org and other similar systems.
Leo programmable editor
http://leoeditor.com/
> or to build an agenda from entries in the database?
It is simple to provide agenda from entries in the database then from
entries in multiple Org files.
- each elementary object can have assigned "ACTION" at my side. Each
assignement of ACTION is recorded with date/time/username, each
COMPLETED designation is also recorded, each removal of designation
is also recorded. One can know in future which items were actionable
in past and which items were completed in past or maybe completed
and then again assigned as actionable. This is currently not a
feature in Org file. One could know that by editing Org file with
file system version control. Single user without file system version
control cannot know if some headings had TODO in past and now they
do not have it.
- each item may be or may be not assigned to specific person. All
people are in the database. So choice of people comes from the
database itself. Assignment to specific person is recorded with
date/time/username and deletion of assignment is recorded,
modification is recorded automatically. This way it is possible to
see which task was assigned to whom.
- agenda thus may be managed centralized for many people, or by people
decentralized. Tasks may sent to assigned person with keys like "s
a", either one task, or all tasks at once. Reminders can be
programmed with various communication lines, including automated
phone calls, SMS, emails, faxes, letters or visual reminders on
computer, or printouts for dispatch.
- that allows collaborative based agenda, it is possible to list items
assigned to person Joe, or person Jane, Joe may insert his own
items, Jane may insert her own items, both Joe and Jane could see
each other items, or finely grained permissions could be defined
(database backed). Manager who is neither Joe or Jane could see all
the items, regardless where users are located in the world. Access
to the database could be through Org extensions, or through software
I am making, or through other software from various
devices. Software is independent of the database entries.
Special table collects information such as SCHEDULED, DEADLINE,
CLOCK-IN, CLOCK-OUT, ACTION, COMPLETED, ACTION-REMOVED. This table
may add different other timestamps by their types. So each node can
receive any of those timestamps.
It is then trivial to add new timestamp or find the difference between
CLOCK-IN, CLOCK-OUT, to list items by SCHEDULED or DEADLINES, or past
DEADLINES.
Your questions gave me to thinking that I should make some basic
functions:
- when editing Org mode, to easily insert database entry from
Hyperscope system so that the entry can be edited in a file itself,
and automatically updated in the database when file is saved, or
special command invoked, or user switched to other heading
- inserting of such item from database entry would make Org
properties, such as HOSTNAME, DATABASE used, (username, passwords
could be externally saved), TABLE, COLUMN in the table and TABLE
ID.
- then an extension function to Org would need to check if there is
some database entry like that, so that saving of the file or
invocation of that function finds the entry and updates it to the
remote database. Database could be local or remote.
- if another user on other part of the world wish to insert or edit
that Org entry, that user would get the updated version
With above extensions, user would still be editing file, it could be
saved file, file on the disk, but the database entries would be
updated either from the database or to the database in the
background and without interruptions to user.
Multiple users could then edit the Org files, which would get updated
on each new opening of a file or the invocation of a function.
This then limits entries to Org mode, while my entries are now in any
mode. I have enriched mode notes or Org type notes in the database, or
markdown nodes, or anything. When markdown note is viewed,
markdown-mode is invoked, when Org type node is viewed in Emacs, then
Org mode is invoked in read only mode.
The list of defined nodes that I have now available are:
Possible completions are:
1 File 10 Directory 11 Launch Program
12 Media 13 Info Node 14 PDF
15 HyperScope ID 16 PDF Query 17 Org Heading
18 Org 19 PDF by Page Nr. 2 WWW
20 DJVU 21 Video 22 Message-ID
23 WRS Page Annotation 24 Directory Action ➜ 25 Shell Command
26 Self 27 Action
29 FOLLOW-UP 3 MPV play video at exact time 30 aMule
31 Task 32 Password 33 PostgreSQL
34 Markdown 35 Paraset 36 Enriched
37 txt2tags 38 EPUB 4 Local File
5 Set ➜ 6 YouTube Video at exact time 7 YouTube Video
8 Emacs Lisp 9 Note
There are no limits to what a node can look like. Each node can be a
note in itself, even if it is a file, there can be note for the file,
number 28. I have deleted not to confuse people. Password is maybe
encrypted in the database, directory action has similar meaning like
in Hyperbole package where file ~/tmp/.hyperscope may contain this:
(hyperscope-directory-action 35243)
and the node ID 35243 decides which directory actions relate to
directory ~/tmp and then window splits with options from the database
such as maybe to read some notes related to directory, or remove all
docview directories or to remove all GIF files in ~/tmp - the idea
comes from Hyperbole package that has similar feature.
People in the database may be assigned specific subtrees or Org files
or nodes, so by finding person one can find the notes, tasks,
assignments, related to people.
At export to Org file, those nodes that are not compatible to Org file
such as Markdown, txt2tags, video, would be exported as separate file
and such file would be hyperlinked from the main Org file similar to
what is defined here:
https://www.dougengelbart.org/content/view/110/460/#2a1b
Complete exported package could then be dispatched onto DVD rom, USB
stick, sent by email or uploaded. Org file can be used in similar
fashion as MIME to define on higher level collection of various
documents.
As my goal is not to provide all features to users, but to use
Hyperscope, that is why my development goes slow and is not yet
available to public. I would need to verify many functions before it
becomes public software. But for individuals interested, I am willing
to help one on one to create the database and provide systems I am
using.
Jean
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-03-08 8:12 ` Jose E. Marchesi
@ 2021-03-10 8:32 ` Jean Louis
0 siblings, 0 replies; 31+ messages in thread
From: Jean Louis @ 2021-03-10 8:32 UTC (permalink / raw)
To: Jose E. Marchesi; +Cc: Alan Schmitt, emacs-orgmode
* Jose E. Marchesi <jemarch@gnu.org> [2021-03-08 11:12]:
>
> >> I am recommending that you start using PostgreSQL database. I can
> >> guide you. My software is not so finished for public, but I can guide
> >> you personally and you will get stable system that lasts for years.
> >
> > Thank you for the suggestion, but for the moment I think I will
> > experiment with text-based solutions.
>
> I use a recfile [1] to manage contacts.
Please send some samples of how it looks like.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2021-02-27 11:08 contact management in emacs Alan Schmitt
` (3 preceding siblings ...)
2021-03-07 22:13 ` Jean Louis
@ 2022-09-09 16:11 ` Sébastien Rey-Coyrehourcq
2022-09-10 5:46 ` Ihor Radchenko
2022-10-09 10:40 ` SQLite for contacts and relations to Org - " Jean Louis
4 siblings, 2 replies; 31+ messages in thread
From: Sébastien Rey-Coyrehourcq @ 2022-09-09 16:11 UTC (permalink / raw)
To: Alan Schmitt, emacs-orgmode
Hi,
After some search today on the web, like Alan i try to compare all
possibility to manage my contact + mail using emacs, mu4e, and org.
Since Alan Schmitt message, i think many people jump into the great
*org-roam* wagon to manage notes, bibliography, links, everything...
I'm into this *crazy* wagon, trying now to manage contact, with this
workflow :
- one file/node by contact,
- stored into the org-roam specific folder "/myorgroamfolder/contact/
with this encrypted org pattern to protect files "*.org.gpg"
- using into mu4e
There are some post exploring part of this use case on the web, but i
first focus to *org-contacts*, because it's well integrated with mu4e
auto-completion :
Moving from org-contrib to https://repo.or.cz/org-contacts.git ,
accessible with melpa, the documentation is mostly into the source-code
actually, i found few example on the web .
What property field are correct :MOBILE:, :PHONE:, :BIRTHDAY: , and ?
I found some information about configuration in Terencio Agozzino
dotfiles (https://github.com/rememberYou/.emacs.d) but when i try to
adapt to this use case,
that don't work, probably because i misunderstand something, about
properties name, or localization into the .org.gpg files.
I config like that (org-contacts-file (file-expand-wildcards
"~/my-org-roam-folder/contact/*.org.gpg))
It's slow because everything need to be unencrypted before (this is
another problem ...) but something i don't understand is how matching
work :
calling "M-x org-contacts", i try multiple patterns, so i'm interested
by a working org/org-roam contact example.
I found some alternatives to test next week :
- org-vcard (on github) compatible with org-contacts, focusing on
import/export of vcard files
- mu4e-contacts (on gitlab) using helm / mu4e, inspired by org-contacts
- org-ql query ?
Best,
Sebastien R.C
Le 27/02/2021 à 12:08, Alan Schmitt a écrit :
> Hello,
>
> This may be slightly off-topic for the list, but as I’m considering
> org-contacts for my question, I hope it will be of interest here.
>
> I would like to migrate my contact management to emacs, as I’m already
> using it for email. My requirements are the following ones:
> - address completion in emacs email clients (I currently use notmuch)
> - support for multiple email addresses and custom fields
> - creation of org links to contacts
> - export to vcard format for synchronization to my mobile phone (using
> vdirsyncer)
> - keep the data under version control
>
> I have looked at two tools, which almost seem fit for the job.
> - ebdb does most of this, with the exception of vcard export (it seems
> to be worked on, https://github.com/girzel/ebdb/issues/60), and I’m not
> sure using version control on an sqlite file is a good idea.
> - org-contacts also seem to have all the required features, including
> vcard export (and if not sufficient there is
> https://github.com/novoid/org-contacts2vcard). I was worried it was
> unmaintained when looking at the copyright line, but I see in
> https://code.orgmode.org/bzg/org-mode/commits/master/contrib/lisp/org-contacts.el
> that there are recent commits to the file.
>
> Do you manage your contacts in emacs? And if so, what tools or workflow
> do you recommend?
>
> Best,
>
> Alan
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: contact management in emacs
2022-09-09 16:11 ` Sébastien Rey-Coyrehourcq
@ 2022-09-10 5:46 ` Ihor Radchenko
2022-10-09 10:40 ` SQLite for contacts and relations to Org - " Jean Louis
1 sibling, 0 replies; 31+ messages in thread
From: Ihor Radchenko @ 2022-09-10 5:46 UTC (permalink / raw)
To: sebastien.rey-coyrehourcq; +Cc: Alan Schmitt, emacs-orgmode
Sébastien Rey-Coyrehourcq <sebastien.rey-coyrehourcq@univ-rouen.fr>
writes:
> Moving from org-contrib to https://repo.or.cz/org-contacts.git ,
> accessible with melpa, the documentation is mostly into the source-code
> actually, i found few example on the web .
>
> What property field are correct :MOBILE:, :PHONE:, :BIRTHDAY: , and ?
First, remember that org-contacts is built on top of generic Org
search.
org-contacts.el considers Org headline to be a contact record when it
contains any of
org-contacts-email-property
org-contacts-alias-property
org-contacts-tel-property
org-contacts-address-property
org-contacts-birthday-property
properties.
All the variables can be changed to your preference.
> I config like that (org-contacts-file (file-expand-wildcards
> "~/my-org-roam-folder/contact/*.org.gpg))
>
> It's slow because everything need to be unencrypted before (this is
> another problem ...) but something i don't understand is how matching
> work :
> calling "M-x org-contacts", i try multiple patterns, so i'm interested
> by a working org/org-roam contact example.
M-x org-contacts does a simple regexp matching across contacts.
If you want integration with org-roam, you may probably want a custom
org-roam matches equivalent to org-contacts-matcher.
There is also M-x org-contacts-completing-read
For the slowness of opening the contacts, you may consider doing
M-x profiler-start .. M-x profiler-report to see what exactly is being
slow.
> I found some alternatives to test next week :
>
> - org-vcard (on github) compatible with org-contacts, focusing on
> import/export of vcard files
> - mu4e-contacts (on gitlab) using helm / mu4e, inspired by org-contacts
> - org-ql query ?
org-ql may be an option though it works best for a single large Org
file. You may have better luck using org-roam built-in search. I think
that the most straightforward way to integrate with org-roam would be
adding a "contact" tag to your contact records and then using the
standard org-roam search.
Hope it helps.
--
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92
^ permalink raw reply [flat|nested] 31+ messages in thread
* SQLite for contacts and relations to Org - Re: contact management in emacs
2022-09-09 16:11 ` Sébastien Rey-Coyrehourcq
2022-09-10 5:46 ` Ihor Radchenko
@ 2022-10-09 10:40 ` Jean Louis
2022-10-09 15:21 ` Quiliro Ordóñez
2022-10-11 5:54 ` Sébastien Rey-Coyrehourcq
1 sibling, 2 replies; 31+ messages in thread
From: Jean Louis @ 2022-10-09 10:40 UTC (permalink / raw)
To: Sébastien Rey-Coyrehourcq; +Cc: Alan Schmitt, emacs-orgmode
* Sébastien Rey-Coyrehourcq <sebastien.rey-coyrehourcq@univ-rouen.fr> [2022-09-09 19:12]:
> Hi,
>
> After some search today on the web, like Alan i try to compare all
> possibility to manage my contact + mail using emacs, mu4e, and org.
I will describe you how to manage contacts with Emacs in the reverse
example reverse of what org-contacts tries to do for you.
Org contacts try to keep people in Org file. Emacs 29 has a built-in
SQLite database which allows every Emacs user to keep information in
ordered, structured manner in the relational database.
For people who do not use latest development Emacs version, there are
SQLite Emacs packages that allow immediate usage of file based
single-user access database, see https://www.sqlite.org
In Emacs 29, here is how I create the SQLite database, or open the existing one:
(setq my-db (sqlite-open "~/my-people"))
This is database handle:
my-db ⇒ #<sqlite db=0x55987eb7d4a0 name=/home/data1/protected/my-org-properties>
This is how to create a table of `people' in the database. The
structure of the table `people' is thus pretty much individual,
one can record any kind of entries and be sure if the the entry
is there or not. It does not allow vague guessing with text files
like in Org or Hyrolo in Hyperbole.
This is example table, one can build upon it. This one contains emails only.
(sqlite-execute my-db "CREATE TABLE people1 (people_id INTEGER PRIMARY KEY,
people_firstname TEXT,
people_middlenames TEXT,
people_name TEXT NOT NULL DEFAULT '>>>UNKNOWN<<<',
people_email TEXT,
people_description TEXT)")
This is how to get all queries from the table:
(sqlite-select my-db "SELECT * FROM people") ⇒ nil
This is how to insert new entry programmatically:
(sqlite-execute my-db "INSERT INTO people (people_firstname, people_name, people_email)
VALUES (?, ?, ?)
RETURNING people_id"
'("Robert" "Weiner" "rsw@gnu.org"))
Get information back from database, programmatically. Do with information what you wish.
(sqlite-select my-db "SELECT * FROM people") ⇒ ((1 "Robert" nil "Weiner" "rsw@gnu.org" nil) (2 "Robert" nil "Weiner" "rsw@gnu.org" nil))
Delete everything in the database.
(sqlite-execute my-db "DELETE FROM people") ⇒ 0
;; Backup?
Backup database by simple copy of the file "~/my-people"
(sqlite-select my-db "SELECT * FROM people") ⇒ nil
Make nicer function to add new people:
(defun my-people-add ()
(interactive)
(let* ((first-name (read-string "First name: "))
(middle-names (read-string "Middles names: "))
(name-or-last-name (let ((result))
(while (not result)
(setq result (apply 'read-string '("Last name: "))))
result))
(email (read-string "Email: "))
(description (read-string "Description: ")))
(sqlite-execute my-db "INSERT INTO people (people_firstname, people_middlenames, people_name, people_email, people_description)
VALUES (?, ?, ?, ?, ?) RETURNING people_id"
(list first-name middle-names name-or-last-name description))))
Run the function by using (my-people-add) or M-x my-people-add
Verify that person was added:
(sqlite-select my-db "SELECT * FROM people") ⇒ ((1 "Joe" "" "Doe" nil nil))
Entries are returned as list, get the first list entry:
(caar (sqlite-select my-db "SELECT people_id FROM people WHERE people_id = 1")) ⇒ 1
My database structure is ALWAYS as so that for TABLE I always
have primary key named TABLE_id. That principle allows to
simplify things.
Then I can make generic function to fetch from database DB, from
TABLE and COLUMN by using ID:
(defun sqlite-db-get-entry (table column id db)
"Return value for the TABLE, COLUMN, ID from the database PG."
(let* ((sql (format "SELECT %s FROM %s WHERE %s_id = %s" column table table id))
(value (caar (sqlite-select db sql))))
value))
(sqlite-db-get-entry "people" "people_id" 1 my-db) ⇒ 1
(sqlite-db-get-entry "people" "people_name" 1 my-db) ⇒ "Doe"
(sqlite-db-get-entry "people" "people_email" 1 my-db) ⇒ "joe@example.com"
Make it exportable to Org:
(defun my-people-to-org-single (id)
(let* ((first-name (sqlite-db-get-entry "people" "people_firstname" id my-db))
(middle-names (sqlite-db-get-entry "people" "people_middlenames" id my-db))
(last-name (sqlite-db-get-entry "people" "people_lastname" id my-db))
(email (sqlite-db-get-entry "people" "people_email" id my-db))
(description (sqlite-db-get-entry "people" "people_description" id my-db))
(heading (list first-name middle-names last-name))
(heading (mapcar (lambda (e) (cond ((seq-empty-p e) nil)
(t e)))
heading))
(heading (delq nil heading))
(heading (concat "* " (string-join heading " ") "\n\n"))
(text (with-temp-buffer
(when (and email (> (length email) 0))
(insert (concat "E-mail: " email "\n\n")))
(when (and description (> (length description) 0))
(insert description))
(buffer-string))))
(concat heading text "\n\n")))
(my-people-to-org-single 1) ⇒ "* Joseph Joe
E-mail: joe@example.com
This is just a sample description
"
What if we have multiple people like "Joe Doe"? Then each will
have its unique ID by which we have to be able to choose them.
One approach is to add on the name a bracketed ID number, like:
"Joe Doe [1]"
"Joe Doe [2]"
Another approach is to add various other attributes to make the
entry distinguishable in completions:
"Joe Doe, Ukraine [1]"
"Joe Doe, Russia [2]"
"Joe Doe, USA [3]"
"Joe Doe, Emacs Users [4]"
To cut the ID from the bracket on the end, following function does it:
(defun rcd-get-bracketed-id-end (s)
"Return the ID number in string S from within first brackets on its
end. For example it would return 123 from `Some string [123]'"
(let* ((match (string-match "\\[\\([[:digit:]]*\\)\\][[:space:]]*$" s)))
(when match
(string-to-number
(substring-no-properties s (match-beginning 1) (match-end 1))))))
Let us make generic function that expects bracketed ID and
completes by SQL. This function could be better of course, this
is example:
(defun my-completing-id-by-sql-end (prompt sql db)
"Return the ID as by finding [ID:123] on the end.
Argument PROMPT will be displayed to user.
Argument SQL is supplied query.
Argument PG is database handle."
(let* ((selection (sqlite-select db sql))
(choice (completing-read prompt selection)))
(rcd-get-bracketed-id-end choice)))
Let us now use that generic function to get a completion list:
(defun my-people-completion-list ()
(let ((sql "SELECT coalesce(CASE WHEN people_firstname IS NOT NULL
AND length(people_firstname) > 0
THEN people_firstname || ', '
END, '') ||
coalesce(CASE WHEN people_middlenames IS NOT NULL
AND length(people_middlenames) > 0
THEN people_middlenames || ', '
END, '') ||
people_name || ' [' || people_id || ']' FROM people"))
(sqlite-select my-db sql)))
And here is how completion list looks like:
(my-people-completion-list) ⇒ (("Joe, Doe [1]"))
Here is the function to choose person among people and return it's ID:
(defun my-people-complete ()
"Return person's ID."
(let ((my-people (my-people-completion-list)))
(cond (my-people (rcd-get-bracketed-id-end (completing-read "Choose person: " my-people)))
(t (error "No people in database")))))
(my-people-complete) ⇒ 1
Let us get list of all columns in SQLite table:
(defun my-sqlite-table-column-list (table)
"From: https://stackoverflow.com/questions/604939/how-can-i-get-the-list-of-a-columns-in-a-table-for-a-sqlite-database"
;; (sqlite-select my-db "SELECT name FROM PRAGMA_TABLE_INFO(?)" (list table)))
(mapcar 'cadr
(sqlite-select my-db "
SELECT
m.name as tableName,
p.name as columnName
FROM
sqlite_master m
LEFT OUTER JOIN pragma_table_info((m.name)) p ON m.name <> p.name
WHERE
m.type IN ('table', 'view')
AND m.name NOT LIKE 'sqlite_%'
AND m.name = ?
ORDER BY
tableName,
columnName" (list table))))
(my-sqlite-table-column-list "people") ⇒ ("people_description" "people_email" "people_firstname" "people_id" "people_middlenames" "people_name")
Let us make function to get full person's name.
- people_firstname can be empty, what if it is empty, it should not be displaed
- people_middlename should be in the middle, but could be empty
- people_name represents either last name or company name or
group name, business name, list of people, etc. It must be
there.
(defun my-people-name (id)
(caar (sqlite-select my-db "SELECT coalesce(CASE WHEN people_firstname IS NOT NULL
AND length(people_firstname) > 0
THEN people_firstname || ' '
END, '') ||
coalesce(CASE WHEN people_middlenames IS NOT NULL
AND length(people_middlenames) > 0
THEN people_middlenames || ' '
END, '') ||
people_name
FROM people
WHERE people_id = ?"
(list id))))
(my-people-name 1) ⇒ "Joseph Joe Doe"
Now function to edit people by their ID programmatically or
interactively by choice:
(defun my-people-edit (&optional id)
(interactive)
(let ((id (or id (my-people-complete)))
(columns (my-sqlite-table-column-list "people")))
(cond (id (let ((column-to-edit (completing-read "Which column to edit? " columns nil t)))
(cond ((member column-to-edit columns) (let* ((initial-input (sqlite-db-get-entry "people" column-to-edit id my-db))
(edited-entry (read-string (format "Edit `%s': " column-to-edit) initial-input nil initial-input)))
(unless (string= initial-input edited-entry)
(sqlite-execute my-db (format "UPDATE people SET %s = ? WHERE people_id = ?" column-to-edit)
(list edited-entry id)))
(my-people-edit id)))
(t (message "No column choosen")))))
(t (message "No person selected for editing")))))
(sqlite-select my-db "SELECT * FROM people") ⇒ ((1 "Joseph" "Joe" "Doe Junior" "joe@example.com" "This is just a sample description"))
;; Delete entry
Now let us make possibility to delete single entries:
(defun my-people-delete (&optional id)
(interactive)
(let* ((id (or id (my-people-complete)))
(name (my-people-name id)))
(when (y-or-n-p (format "Do you wish to delete entry `%s'? " name))
(sqlite-execute my-db "DELETE FROM people WHERE people_id = ?" (list id))
(message "Deleted entry `%s'" name))))
(sqlite-select my-db "SELECT * FROM people") ⇒ nil
Add again:
(my-people-add)
Select from database again:
(sqlite-select my-db "SELECT * FROM people") ⇒ ((1 "Joseph" "joe" "Doe" nil nil))
Edit the entry
(my-people-edit) or M-x my-people-edit
(sqlite-select my-db "SELECT * FROM people") ⇒ ((1 "Joseph" "Joe" "Doe" "joe@example.com" "This is just a sample description"))
now we come to export single person to Org entry:
(my-people-to-org 1) ⇒ "* Joseph Joe
E-mail: joe@example.com
This is just a sample description"
Now we can make full export to Org of all people in the database:
(defun my-people-to-org ()
(let ((people (flatten-list (sqlite-select my-db "SELECT people_id FROM people"))))
(with-temp-buffer
(while people
(insert (my-people-to-org-single (pop people))))
(buffer-string))))
(my-people-to-org) ⇒ "* Joseph Joe
E-mail: joe@example.com
This is just a sample description
* Jane
"
Then we can export everything to Org file:
(defun my-people-export-to-org-file ()
(interactive)
(let ((file (read-file-name "Export people to which Org file? ")))
(with-temp-file file
(insert (my-people-to-org)))))
M-x my-people-export-to-org-file
now when one is aware that people may be managed very easy in the
SQLite database, one shall examine the modes of SQLite:
.mode MODE ?TABLE? Set output mode where MODE is one of:
csv Comma-separated values
column Left-aligned columns. (See .width)
html HTML <table> code
insert SQL insert statements for TABLE
line One value per line
list Values delimited by .separator string
tabs Tab-separated values
tcl TCL list elements
It also means that importing CSV files into SQLite is easy.
Exporting from SQLite to Org file is also easy.
Exporting SQL is easy:
.mode insert
sqlite> select * from people;
INSERT INTO "table" VALUES(1,'Joseph','Joe','Doe','joe@example.com','This is just a sample description');
INSERT INTO "table" VALUES(2,'Jane','','Dine','',NULL);
INSERT INTO "table" VALUES(3,'Robert',NULL,'Weiner','rsw@gnu.org',NULL);
Or one value per line:
.mode line
select * from people;
people_id = 1
people_firstname = Joseph
people_middlenames = Joe
people_name = Doe
people_email = joe@example.com
people_description = This is just a sample description
people_id = 2
people_firstname = Jane
people_middlenames =
people_name = Dine
people_email =
people_description =
people_id = 3
people_firstname = Robert
people_middlenames =
people_name = Weiner
people_email = rsw@gnu.org
people_description =
Now we come to relation of Org to people ID.
How about this:
* My heading
:PROPERTIES:
:PEOPLE-ID-RELATED: 1
:END:
Now you know that ID is in the file my-people.sqlite and that ID
is 1. That is to stay so, immutable.
Let us make the report for person:
(define-derived-mode my-people-view-mode org-mode "My People View Mode"
"This is read only view mode for people")
(defun my-people-org-report (id)
(let* ((name (my-people-name id))
(buffer (get-buffer-create name))
(org (my-people-to-org-single id)))
(pop-to-buffer (get-buffer-create "My people report"))
(read-only-mode 0)
(erase-buffer)
(insert org)
(goto-char (point-min))
(my-people-view-mode)
(keymap-set my-people-view-mode-map "q" #'quit-window)
(keymap-set my-people-view-mode-map "e" `(lambda () (interactive) (my-people-edit ,id)))
(read-only-mode 1)))
The above allows to open the new Org buffer where entry from database is shown:
(my-people-org-report 1)
Then I can see this:
* Joseph Joe
E-mail: joe@example.com
This is just a sample description
now back to heading in your real Org file:
* My heading
:PROPERTIES:
:PEOPLE-ID-RELATED: 1
:END:
If person ID 1 is related to this heading, then I can make
function to quickly see the entry of the person:
(defun my-people-org-set-people-id-name (id)
(let ((name (my-people-name id)))
(org-set-property "PEOPLE-ID-NAME" name)))
(defun my-people-org-related-view ()
(interactive)
(let ((people-id-related (cdr (assoc "PEOPLE-ID-RELATED" (org-entry-properties)))))
(cond (people-id-related (progn (my-people-org-set-people-id-name people-id-related)
(my-people-org-report people-id-related)))
(t (message "No related contact found in this Org heading")))))
When there is related contact one jumps into generated Org file by C-c r
and then with "e" one can already edit the contact in general way by using Emacs minibuffer.
And what if we jump to related contact, maybe we still need contact
name in properties, so it is generated automatically and directly from
the database.
* My heading
:PROPERTIES:
:PEOPLE-ID-RELATED: 1
:PEOPLE-ID-NAME: Joseph Joe Doe
:PEOPLE-ID-EMAIL: joe@example.com
:END:
What if we need email in properties?
(defun my-people-org-set-people-id-email (id)
(let ((email (sqlite-db-get-entry "people" "people_email" id my-db)))
(org-set-property "PEOPLE-ID-EMAIL" email)))
then
(defun my-people-org-related-view ()
(interactive)
(let ((people-id-related (cdr (assoc "PEOPLE-ID-RELATED" (org-entry-properties)))))
(cond (people-id-related (progn (my-people-org-set-people-id-email people-id-related)
(my-people-org-set-people-id-name people-id-related)
(my-people-org-report people-id-related)))
(t (message "No related contact found in this Org heading")))))
And how to add related person straight from database?
(defun my-people-org-related-person (&optional id)
(interactive)
(let ((id (or id (my-people-complete))))
(when id
(org-set-property "PEOPLE-ID-RELATED" (format "%s" id)))))
This all assumes that it is just one person related to heading.
We could make any number of people related to heading, but let
us keep it to this example.
At this moment maybe you are writing Org headline that is related
to SCHOOL ABC:
Here is the flow:
1. Add new entry in people table by using M-x my-people-add
2. Make new headline in Org:
** Cleaning project
3. Run function M-x my-people-org-related-person
** Cleaning project
:PROPERTIES:
:PEOPLE-ID-RELATED: 4
:PEOPLE-ID-EMAIL: myschool@example.com
:PEOPLE-ID-NAME: SCHOOL ABC
:END:
At this point you may examine the entry for the ABC SCHOOL by clicking
C-c r and it will update Org properties.
By using this principle it could update anything in Org but also in
any other type of file.
By using SQLite or PostgreSQL you can use plethora of OTHER PROGRAMS
to manage entries in your database.
For example in sqlitebrowser:
https://gnu.support/images/sqlite/2022/2022-10-09/2022-10-09-13:34:30.png
Now your contacts are separated from Org. Only by using SQLite browser
you may freely enter new contacts in the database and edit them by
your wish. There are many various tools to manage databases.
I am editing contacts by using tabulated list mode in Emacs:
ID 6
Date created "2021-06-25 15:50:35.1712+03"
Date modified "2022-10-06 12:37:31.877754+03"
Prefix nil
First name "Joe"
Middle names nil
Last name (People List Name) "Doe"
Suffix nil
Hyperdocument Set #1 nil
Profile Image nil
ID Document nil
Lead source "thispersondoesnotexist.com/"
Title nil
Department nil
Date of birth or Begin Date nil
End date nil
Don't contact nil
Description nil
Modified by username "maddox"
Created by username "maddox"
Introduced by "Vicente Ramirez"
Other names nil
Tokens "'data':2 'enter':1 'lastnam':5 'people.people':4"
Rank 0
Assigned to nil
People type "Individual Person"
Reports to nil
Communication Language nil
SIC Code nil
Industry nil
Tag #1 nil
Tag #2 nil
Tag #3 nil
Active "Active"
FROM Identity nil
Internal information nil
But I can as well edit my contacts by using external tools and
exchange information with other software.
Do you wish to share your contacts? That is easy, one can simple send
the full file to somebody.
By followed the thought patterns described one shall understand that
contacts may be separated from single mode (Org) and separated from
single software (Emacs) and that it will not minimize or limit you but
rather widen the capacities and usefulness for human.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-09 10:40 ` SQLite for contacts and relations to Org - " Jean Louis
@ 2022-10-09 15:21 ` Quiliro Ordóñez
2022-10-09 16:59 ` Jean Louis
2022-10-11 5:54 ` Sébastien Rey-Coyrehourcq
1 sibling, 1 reply; 31+ messages in thread
From: Quiliro Ordóñez @ 2022-10-09 15:21 UTC (permalink / raw)
To: Sébastien Rey-Coyrehourcq, Alan Schmitt, emacs-orgmode
El 2022-10-09 05:40, Jean Louis escribió:
> But I can as well edit my contacts by using external tools and
> exchange information with other software.
>
> Do you wish to share your contacts? That is easy, one can simple send
> the full file to somebody.
>
> By followed the thought patterns described one shall understand that
> contacts may be separated from single mode (Org) and separated from
> single software (Emacs) and that it will not minimize or limit you but
> rather widen the capacities and usefulness for human.
This is a great summary about the use of database to hold information.
But it requires experience configuring databases for end-users. It
could work if the database was set up by someone else or if the fields
were easy to define by the end-user by some kind of interface.
On the other hand, there is a movement to use plain text for everything.
I know you disagree. But here is some information about accounting
this way: https://plaintextaccounting.org
I learned a lot of elisp by reading your long explanation about how to
construct a contact database directly on Emacs 29 without adding
anything else. Thank you very much!
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-09 15:21 ` Quiliro Ordóñez
@ 2022-10-09 16:59 ` Jean Louis
2022-10-09 19:09 ` Quiliro Ordóñez
0 siblings, 1 reply; 31+ messages in thread
From: Jean Louis @ 2022-10-09 16:59 UTC (permalink / raw)
To: Quiliro Ordóñez
Cc: Sébastien Rey-Coyrehourcq, Alan Schmitt, emacs-orgmode
* Quiliro Ordóñez <quiliro@riseup.net> [2022-10-09 18:22]:
> El 2022-10-09 05:40, Jean Louis escribió:
>
> > But I can as well edit my contacts by using external tools and
> > exchange information with other software.
> >
> > Do you wish to share your contacts? That is easy, one can simple send
> > the full file to somebody.
> >
> > By followed the thought patterns described one shall understand that
> > contacts may be separated from single mode (Org) and separated from
> > single software (Emacs) and that it will not minimize or limit you but
> > rather widen the capacities and usefulness for human.
>
> This is a great summary about the use of database to hold information.
> But it requires experience configuring databases for end-users.
We speak of what? User experience? We are in Emacs environment, that
means you run your application either by using mouse click or by M-x
or key binding.
In the provided example you as user need nothing else but
that. Hypothetically basic actions are just add, modify, delete,
search for contacts. You do that by key binding in Emacs, or by mouse,
or by M-x
In the example provided user need do nothing but that. Even the file
can be automatically stored like in ~/.emacs.d/people.sqlite or
otherwise configured to be somewhere else.
How many options does Org have? The example I have provided may be
option free.
There is nothing to do but to add, modify, delete, search for
contacts, export, and so on; all by using M-x, key binding or mouse.
> It could work if the database was set up by someone else or if the
> fields were easy to define by the end-user by some kind of
> interface.
I have actually shown to you how it works, so you have to imagine that
all that may be part of the package. Especially with SQLite databases
there is nothing to configure.
This is what defines where the database is:
(defcustom rcd-people-sqlite-file (concat (expand-file-name user-emacs-directory) "rcd-people.sqlite")
"SQLite database file location."
:type 'file
:group 'rcd)
We evaluate it:
rcd-people-sqlite-file ⇒ "/home/data1/protected/.emacs.d/rcd-people.sqlite"
The above variable is part of the package. There is nothing for
user to think about it. There is nothing to configure but user
is free to customize it.
Fields or columns in preset database tables are designed by
programmer.
It is not hard to have options to add column, delete column or
rename column. That is exactly what I am doing on the fly during
Emacs sessions.
> On the other hand, there is a movement to use plain text for everything.
> I know you disagree.
There are movements for each and everything. Why should I
disagree with movements, I let them be.
What I do not agree is to claim strongly that it is useful to
keep plain text or clay tables with Cuneiform for every type of
information.
> But here is some information about accounting
> this way: https://plaintextaccounting.org
The huge amount of work necessary to create plain text accounting
can't be compared to database work and efforts. I guess I have
implemented accounting with database about 4 times in my life
and I use it in various contexts. Standard accounting is simple.
Accounting types (pasted straight from Emacs view of database
list):
1 Asset
2 Liability
3 Equity
4 Income
5 Expenses
Sample account defined:
ID 1
Date created "2022-02-27 18:36:28.690616"
Date modified "2022-02-27 18:36:39.372512"
User created "maddox"
User modified "maddox"
Hyperdocument "2022-02-27 Transactions for Joe Doe"
Account Type "Asset"
Person "Jean Louis"
Currency "UGX - Ugandan shilling"
Name "Jean Louis"
Description nil
Code nil
It belongs to Hyperdocument which has type of accounting. There
may be multiple companies, multiple accounting sets or parents
to which accounts belong. No need to open a "new file" for each
new company.
And then there is journal entry:
-[ RECORD 1 ]----------+-------------------------------------------------------------------
journal_id | 4
journal_datecreated | 2019-06-12 00:08:04.409559
journal_datemodified |
journal_usercreated | maddox
journal_usermodified | maddox
journal_cashentrytypes | 1
journal_code |
journal_description | food
journal_debit | 5
journal_credit | 7
journal_amount | 4000
journal_signature |
journal_date | 2019-06-10
The entry debits account ID 5, credits account ID 7.
> I learned a lot of elisp by reading your long explanation about how to
> construct a contact database directly on Emacs 29 without adding
> anything else. Thank you very much!
Well that is really good, thank you.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-09 16:59 ` Jean Louis
@ 2022-10-09 19:09 ` Quiliro Ordóñez
2022-10-10 6:12 ` Jean Louis
0 siblings, 1 reply; 31+ messages in thread
From: Quiliro Ordóñez @ 2022-10-09 19:09 UTC (permalink / raw)
To: Quiliro Ordóñez; +Cc: emacs-orgmode
El 2022-10-09 11:59, Jean Louis escribió:
> * Quiliro Ordóñez <quiliro@riseup.net> [2022-10-09 18:22]:
>> El 2022-10-09 05:40, Jean Louis escribió:
>>
>> > But I can as well edit my contacts by using external tools and
>> > exchange information with other software.
>> >
>> > Do you wish to share your contacts? That is easy, one can simple send
>> > the full file to somebody.
>> >
>> > By followed the thought patterns described one shall understand that
>> > contacts may be separated from single mode (Org) and separated from
>> > single software (Emacs) and that it will not minimize or limit you but
>> > rather widen the capacities and usefulness for human.
>>
>> This is a great summary about the use of database to hold information.
>> But it requires experience configuring databases for end-users.
>
> We speak of what? User experience? We are in Emacs environment, that
> means you run your application either by using mouse click or by M-x
> or key binding.
>
> In the provided example you as user need nothing else but
> that. Hypothetically basic actions are just add, modify, delete,
> search for contacts. You do that by key binding in Emacs, or by mouse,
> or by M-x
>
> In the example provided user need do nothing but that. Even the file
> can be automatically stored like in ~/.emacs.d/people.sqlite or
> otherwise configured to be somewhere else.
I agree. But the end-user did not construct this program. It was you.
I coould learn how to install it. Then, I should teach the end-user to
use it. But the program was not made or installed by the end-user. I
might be able to teach the end-user to modify it. But I doubt it.
What I mean is that end-users must have an easy entry point. Of course
that ease must not hide innner workings because that would disempower
the end-user. How do you propose it could be implemented? (if you agree
it should be done this way, of course)
> I have actually shown to you how it works, so you have to imagine that
> all that may be part of the package. Especially with SQLite databases
> there is nothing to configure.
Not much to do. Just installing SQLite and then the program you
propose.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-09 19:09 ` Quiliro Ordóñez
@ 2022-10-10 6:12 ` Jean Louis
2022-10-10 22:29 ` Robert Weiner
0 siblings, 1 reply; 31+ messages in thread
From: Jean Louis @ 2022-10-10 6:12 UTC (permalink / raw)
To: Quiliro Ordóñez; +Cc: emacs-orgmode
* Quiliro Ordóñez <quiliro@riseup.net> [2022-10-09 22:10]:
> I agree. But the end-user did not construct this program. It was you.
> I coould learn how to install it. Then, I should teach the end-user to
> use it. But the program was not made or installed by the end-user. I
> might be able to teach the end-user to modify it. But I doubt it.
I will make a package so that you just install it and can start
managing people.
> What I mean is that end-users must have an easy entry point. Of course
> that ease must not hide innner workings because that would disempower
> the end-user. How do you propose it could be implemented? (if you agree
> it should be done this way, of course)
Inner workings are pretty much hidden unless user is programmer. Emacs
is difficult, then there is underlying Emacs Lisp, then C language,
then operating system, and stuff.
Maybe you mean somthing else with inner workings?
> > I have actually shown to you how it works, so you have to imagine that
> > all that may be part of the package. Especially with SQLite databases
> > there is nothing to configure.
>
> Not much to do. Just installing SQLite and then the program you
> propose.
I did not try any SQLite package, just used the built-in functions in
Emacs development version. Which packag did you install?
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-10 6:12 ` Jean Louis
@ 2022-10-10 22:29 ` Robert Weiner
2022-10-10 23:32 ` Jean Louis
0 siblings, 1 reply; 31+ messages in thread
From: Robert Weiner @ 2022-10-10 22:29 UTC (permalink / raw)
To: Quiliro Ordóñez, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3032 bytes --]
Hi Jean:
A few thoughts.
1. Although I understand you do a great many things with your
database-backed Hyperscope system and I work with RDBMSes every day, I
don't really see great value in what you have shown in the context of
contact management when compared to the already existing HyRolo or
org-contacts. We can easily add, delete, import and export contacts, we
just follow very simple conventions in creating our contacts. We can
easily email contact files and have people apply text processing tools to
them, so it would help if you just showed examples of something that Emacs
really lacks before suggesting wrapping everything into a database system,
as I know you are a very smart guy.
2. Years ago as part of my stab at an Emacs-based IDE, InfoDock (find it on
Sourceforge), I also wrote an in-memory, file-based but fully relational
database. The main point of which was to demonstrate direct manipulation
querying of relational tables via simple mouse clicks/key presses on
screen. For simple queries, I found this very powerful and dirt simple for
people to do. If that were of interest, someone could take the existing
code under infodock/id-lisp/rdb and interface it to SQLite pretty easily I
would expect and then you would have an interesting Emacs interface without
having to master SQL for basic table analysis.
-- rsw
On Mon, Oct 10, 2022 at 6:12 AM Jean Louis <bugs@gnu.support> wrote:
> * Quiliro Ordóñez <quiliro@riseup.net> [2022-10-09 22:10]:
> > I agree. But the end-user did not construct this program. It was you.
> > I coould learn how to install it. Then, I should teach the end-user to
> > use it. But the program was not made or installed by the end-user. I
> > might be able to teach the end-user to modify it. But I doubt it.
>
> I will make a package so that you just install it and can start
> managing people.
>
> > What I mean is that end-users must have an easy entry point. Of course
> > that ease must not hide innner workings because that would disempower
> > the end-user. How do you propose it could be implemented? (if you agree
> > it should be done this way, of course)
>
> Inner workings are pretty much hidden unless user is programmer. Emacs
> is difficult, then there is underlying Emacs Lisp, then C language,
> then operating system, and stuff.
>
> Maybe you mean somthing else with inner workings?
>
> > > I have actually shown to you how it works, so you have to imagine that
> > > all that may be part of the package. Especially with SQLite databases
> > > there is nothing to configure.
> >
> > Not much to do. Just installing SQLite and then the program you
> > propose.
>
> I did not try any SQLite package, just used the built-in functions in
> Emacs development version. Which packag did you install?
>
> --
> Jean
>
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
>
> In support of Richard M. Stallman
> https://stallmansupport.org/
>
>
[-- Attachment #2: Type: text/html, Size: 4430 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-10 22:29 ` Robert Weiner
@ 2022-10-10 23:32 ` Jean Louis
2022-10-11 3:20 ` Robert Weiner
0 siblings, 1 reply; 31+ messages in thread
From: Jean Louis @ 2022-10-10 23:32 UTC (permalink / raw)
To: rswgnu; +Cc: Quiliro Ordóñez, emacs-orgmode
* Robert Weiner <rsw@gnu.org> [2022-10-11 01:31]:
> 1. Although I understand you do a great many things with your
> database-backed Hyperscope system and I work with RDBMSes every day, I
> don't really see great value in what you have shown in the context of
> contact management when compared to the already existing HyRolo or
> org-contacts. We can easily add, delete, import and export contacts, we
> just follow very simple conventions in creating our contacts. We can
> easily email contact files and have people apply text processing tools to
> them, so it would help if you just showed examples of something that Emacs
> really lacks before suggesting wrapping everything into a database system,
> as I know you are a very smart guy.
For org-contacts, I have nothing to say, as that is as limited as it
can be.
When anyway structured information such as people names, properties,
their communication lines, addresses are in the separate database like
SQLite, that fact liberates information from single software like
HyRolo, and allows users to access, process information freely with
any programming languages and plethora of variety of tools for
inspection, analysis, exports, and sharing of such information.
For HyRolo, that is text. One cannot build upon it.
I am constantly sending SMS from Emacs and importing SMS from mobile
phones to contacts. When I send SMS I want to see which SMS was sent
and received by which contact at what time, by which phone number. It
is something not imaginable with text files. Similar is with
information sent to people, how am I supposed to know what information
I have sent, what not. There is no automated tracking in text files
like HyRolo. It is one example among way too many.
Adding properties to people, objects, it is much easier by using
selection that one can click onto, or use arrows, or just C-p for
previous one. Rather that, then writing with hand each time, error
prone, some skills of people in order to find people by skills.
Skill like "C programmer" I would need to add too many times and then
use find by regexp.
All good and find, but not scalable. Of course that I have use text
files long ago to store contacts, but that was 28 years ago. I have
now 240106 entries of people and their groups.
Unspoken of marketing campaign, imagine when I paid $73 and got in 23
hours 1200+ leads for recruitment in specific sector. How would I
enter them in HyRolo? Automate some web server program to add them in
similar fashion like Org heading. It could work. But then how could I
send to those people in ordered fashion series of 3-10 training emails
that automates the process of recruitment and selection? Would HyRolo
help me track who received what at what time? There is no foundation
for such features in text files.
> 2. Years ago as part of my stab at an Emacs-based IDE, InfoDock (find it on
> Sourceforge),
Is it this one?
https://sourceforge.net/projects/infodock/
I cannot see how to start anything with it. Do you have screenshots?
> I also wrote an in-memory, file-based but fully relational database.
> The main point of which was to demonstrate direct manipulation
> querying of relational tables via simple mouse clicks/key presses on
> screen. For simple queries, I found this very powerful and dirt
> simple for people to do. If that were of interest, someone could
> take the existing code under infodock/id-lisp/rdb and interface it
> to SQLite pretty easily I would expect and then you would have an
> interesting Emacs interface without having to master SQL for basic
> table analysis.
Is it this one?
lib/infodock-4.0.8/i486-pc-sysv5/
lib/infodock-4.0.8/i486-pc-sysv5/make-path
lib/infodock-4.0.8/i486-pc-sysv5/wakeup
lib/infodock-4.0.8/i486-pc-sysv5/profile
lib/infodock-4.0.8/i486-pc-sysv5/make-docfile
lib/infodock-4.0.8/i486-pc-sysv5/digest-doc
lib/infodock-4.0.8/i486-pc-sysv5/sorted-doc
lib/infodock-4.0.8/i486-pc-sysv5/movemail
lib/infodock-4.0.8/i486-pc-sysv5/cvtmail
lib/infodock-4.0.8/i486-pc-sysv5/fakemail
lib/infodock-4.0.8/i486-pc-sysv5/yow
lib/infodock-4.0.8/i486-pc-sysv5/hexl
lib/infodock-4.0.8/i486-pc-sysv5/gnuserv
lib/infodock-4.0.8/i486-pc-sysv5/mmencode
lib/infodock-4.0.8/i486-pc-sysv5/rcs2log
lib/infodock-4.0.8/i486-pc-sysv5/vcdiff
lib/infodock-4.0.8/i486-pc-sysv5/gzip-el.sh
lib/infodock-4.0.8/i486-pc-sysv5/add-big-package.sh
lib/infodock-4.0.8/i486-pc-sysv5/config.values
lib/infodock-4.0.8/i486-pc-sysv5/DOC
bin/i386-intel-sco7/
bin/i386-intel-sco7/etags
bin/i386-intel-sco7/ctags
bin/i386-intel-sco7/b2m
bin/i386-intel-sco7/gnuclient
bin/i386-intel-sco7/ootags
bin/i386-intel-sco7/rcs-checkin
bin/i386-intel-sco7/pstogif
bin/i386-intel-sco7/gnudoit
bin/i386-intel-sco7/gnuattach
bin/i386-intel-sco7/infodock-4.0.8
bin/i386-intel-sco7/infodock --> infodock-4.0.8
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-10 23:32 ` Jean Louis
@ 2022-10-11 3:20 ` Robert Weiner
0 siblings, 0 replies; 31+ messages in thread
From: Robert Weiner @ 2022-10-11 3:20 UTC (permalink / raw)
To: Jean Louis; +Cc: Quiliro Ordóñez, emacs-orgmode
You want a CRM system which to me is a very different creature and much more complex than a contact manager, meant to lookup fairly static information about people. HyRolo was built to allow freeform contact management and to specifically avoid the typical, limiting field-based techniques in common use.
It would be a small extensio to allow you to apply operations to a set of filtered contacts you have found.
-- Bob
> On Oct 10, 2022, at 7:39 PM, Jean Louis <bugs@gnu.support> wrote:
>
>
>
> When anyway structured information such as people names, properties,
> their communication lines
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-09 10:40 ` SQLite for contacts and relations to Org - " Jean Louis
2022-10-09 15:21 ` Quiliro Ordóñez
@ 2022-10-11 5:54 ` Sébastien Rey-Coyrehourcq
2022-10-11 19:59 ` Jean Louis
1 sibling, 1 reply; 31+ messages in thread
From: Sébastien Rey-Coyrehourcq @ 2022-10-11 5:54 UTC (permalink / raw)
To: Jean Louis; +Cc: Alan Schmitt, emacs-orgmode
[-- Attachment #1.1.1: Type: text/plain, Size: 23540 bytes --]
Hi Jean Louis,
First i want to thank you for this very detailled explanation, this is very valuable for someone that start in elisp like me.
Secondly, i found the idea of using sqlite for contacts very interesting, and i think a lot on this solution on my side the last weeks. With the new emacs interface to sql, it was easy i suppose to create a “both-way” syncing tool between org-contact (to easily maintain info, linking to notes, agenda, etc.) and a database that anyone could reuse, move, send also using mobile phone.
I use org-roam that use both of the two world, database and org, in the light of recent discussion, why we cannot do the same things for org-contact ? Linking / syncing properties with unique hash/id also stored in a database. If you have 150000 contact, with 150000 unique ID, and if you want to create an org-contact file/propertie into an org document, that’s probably easy to inject and maintain some sort of syncing (like org-roam do) between the info in database and the info into some properties block no ?
Best regards,
SR
Jean Louis <bugs@gnu.support> writes:
> * Sébastien Rey-Coyrehourcq <sebastien.rey-coyrehourcq@univ-rouen.fr> [2022-09-09 ven. 19:12]:
>> Hi,
>>
>> After some search today on the web, like Alan i try to compare all
>> possibility to manage my contact + mail using emacs, mu4e, and org.
>
> I will describe you how to manage contacts with Emacs in the reverse
> example reverse of what org-contacts tries to do for you.
>
> Org contacts try to keep people in Org file. Emacs 29 has a built-in
> SQLite database which allows every Emacs user to keep information in
> ordered, structured manner in the relational database.
>
> For people who do not use latest development Emacs version, there are
> SQLite Emacs packages that allow immediate usage of file based
> single-user access database, see <https://www.sqlite.org>
>
> In Emacs 29, here is how I create the SQLite database, or open the existing one:
>
> (setq my-db (sqlite-open “~/my-people”))
>
> This is database handle:
>
> my-db ⇒ #<sqlite db=0x55987eb7d4a0 name=/home/data1/protected/my-org-properties>
>
> This is how to create a table of `people’ in the database. The
> structure of the table `people’ is thus pretty much individual,
> one can record any kind of entries and be sure if the the entry
> is there or not. It does not allow vague guessing with text files
> like in Org or Hyrolo in Hyperbole.
>
> This is example table, one can build upon it. This one contains emails only.
>
> (sqlite-execute my-db “CREATE TABLE people1 (people_id INTEGER PRIMARY KEY,
> people_firstname TEXT,
> people_middlenames TEXT,
> people_name TEXT NOT NULL DEFAULT ’>>>UNKNOWN<<<‘,
> people_email TEXT,
> people_description TEXT)”)
>
> This is how to get all queries from the table:
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ nil
>
> This is how to insert new entry programmatically:
>
> (sqlite-execute my-db “INSERT INTO people (people_firstname, people_name, people_email)
> VALUES (?, ?, ?)
> RETURNING people_id”
> ’(“Robert” “Weiner” “rsw@gnu.org”))
>
> Get information back from database, programmatically. Do with information what you wish.
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ ((1 “Robert” nil “Weiner” “rsw@gnu.org” nil) (2 “Robert” nil “Weiner” “rsw@gnu.org” nil))
>
> Delete everything in the database.
>
> (sqlite-execute my-db “DELETE FROM people”) ⇒ 0
>
> ;; Backup?
>
> Backup database by simple copy of the file “~/my-people”
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ nil
>
> Make nicer function to add new people:
>
> (defun my-people-add ()
> (interactive)
> (let* ((first-name (read-string “First name: ”))
> (middle-names (read-string “Middles names: ”))
> (name-or-last-name (let ((result))
> (while (not result)
> (setq result (apply ’read-string ’(“Last name: ”))))
> result))
> (email (read-string “Email: ”))
> (description (read-string “Description: ”)))
> (sqlite-execute my-db “INSERT INTO people (people_firstname, people_middlenames, people_name, people_email, people_description)
> VALUES (?, ?, ?, ?, ?) RETURNING people_id”
> (list first-name middle-names name-or-last-name description))))
>
> Run the function by using (my-people-add) or M-x my-people-add
>
> Verify that person was added:
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ ((1 “Joe” “” “Doe” nil nil))
>
> Entries are returned as list, get the first list entry:
>
> (caar (sqlite-select my-db “SELECT people_id FROM people WHERE people_id = 1”)) ⇒ 1
>
> My database structure is ALWAYS as so that for TABLE I always
> have primary key named TABLE_id. That principle allows to
> simplify things.
>
> Then I can make generic function to fetch from database DB, from
> TABLE and COLUMN by using ID:
>
> (defun sqlite-db-get-entry (table column id db)
> “Return value for the TABLE, COLUMN, ID from the database PG.”
> (let* ((sql (format “SELECT %s FROM %s WHERE %s_id = %s” column table table id))
> (value (caar (sqlite-select db sql))))
> value))
>
> (sqlite-db-get-entry “people” “people_id” 1 my-db) ⇒ 1
>
> (sqlite-db-get-entry “people” “people_name” 1 my-db) ⇒ “Doe”
>
> (sqlite-db-get-entry “people” “people_email” 1 my-db) ⇒ “joe@example.com”
>
> Make it exportable to Org:
>
> (defun my-people-to-org-single (id)
> (let* ((first-name (sqlite-db-get-entry “people” “people_firstname” id my-db))
> (middle-names (sqlite-db-get-entry “people” “people_middlenames” id my-db))
> (last-name (sqlite-db-get-entry “people” “people_lastname” id my-db))
> (email (sqlite-db-get-entry “people” “people_email” id my-db))
> (description (sqlite-db-get-entry “people” “people_description” id my-db))
> (heading (list first-name middle-names last-name))
> (heading (mapcar (lambda (e) (cond ((seq-empty-p e) nil)
> (t e)))
> heading))
> (heading (delq nil heading))
> (heading (concat “* ” (string-join heading “ ”) “\n\n”))
> (text (with-temp-buffer
> (when (and email (> (length email) 0))
> (insert (concat “E-mail: ” email “\n\n”)))
> (when (and description (> (length description) 0))
> (insert description))
> (buffer-string))))
> (concat heading text “\n\n”)))
>
> (my-people-to-org-single 1) ⇒ “* Joseph Joe
>
> E-mail: joe@example.com
>
> This is just a sample description
>
> ”
>
> What if we have multiple people like “Joe Doe”? Then each will
> have its unique ID by which we have to be able to choose them.
>
> One approach is to add on the name a bracketed ID number, like:
>
> “Joe Doe [1]”
> “Joe Doe [2]”
>
> Another approach is to add various other attributes to make the
> entry distinguishable in completions:
>
> “Joe Doe, Ukraine [1]”
> “Joe Doe, Russia [2]”
> “Joe Doe, USA [3]”
> “Joe Doe, Emacs Users [4]”
>
> To cut the ID from the bracket on the end, following function does it:
>
> (defun rcd-get-bracketed-id-end (s)
> “Return the ID number in string S from within first brackets on its
> end. For example it would return 123 from `Some string [123]’”
> (let* ((match (string-match “\\[\\([[:digit:]]*\\)\\][[$” s)))
> (when match
> (string-to-number
> (substring-no-properties s (match-beginning 1) (match-end 1))))))
>
> Let us make generic function that expects bracketed ID and
> completes by SQL. This function could be better of course, this
> is example:
>
> (defun my-completing-id-by-sql-end (prompt sql db)
> “Return the ID as by finding [<ID:123>] on the end.
> Argument PROMPT will be displayed to user.
> Argument SQL is supplied query.
> Argument PG is database handle.”
> (let* ((selection (sqlite-select db sql))
> (choice (completing-read prompt selection)))
> (rcd-get-bracketed-id-end choice)))
>
> Let us now use that generic function to get a completion list:
>
> (defun my-people-completion-list ()
> (let ((sql “SELECT coalesce(CASE WHEN people_firstname IS NOT NULL
> AND length(people_firstname) > 0
> THEN people_firstname || ‘, ’
> END, ‘’) ||
> coalesce(CASE WHEN people_middlenames IS NOT NULL
> AND length(people_middlenames) > 0
> THEN people_middlenames || ‘, ’
> END, ‘’) ||
> people_name || ’ [’ || people_id || ’]’ FROM people”))
> (sqlite-select my-db sql)))
>
> And here is how completion list looks like:
>
> (my-people-completion-list) ⇒ ((“Joe, Doe [1]”))
>
> Here is the function to choose person among people and return it’s ID:
>
> (defun my-people-complete ()
> “Return person’s ID.”
> (let ((my-people (my-people-completion-list)))
> (cond (my-people (rcd-get-bracketed-id-end (completing-read “Choose person: ” my-people)))
> (t (error “No people in database”)))))
>
> (my-people-complete) ⇒ 1
>
> Let us get list of all columns in SQLite table:
>
> (defun my-sqlite-table-column-list (table)
> “From: <https://stackoverflow.com/questions/604939/how-can-i-get-the-list-of-a-columns-in-a-table-for-a-sqlite-database>”
> ;; (sqlite-select my-db “SELECT name FROM PRAGMA_TABLE_INFO(?)” (list table)))
> (mapcar ’cadr
> (sqlite-select my-db “
> SELECT
> m.name as tableName,
> p.name as columnName
> FROM
> sqlite_master m
> LEFT OUTER JOIN pragma_table_info((m.name)) p ON m.name <> p.name
> WHERE
> m.type IN (‘table’, ‘view’)
> AND m.name NOT LIKE ‘sqlite_%’
> AND m.name = ?
> ORDER BY
> tableName,
> columnName” (list table))))
>
> (my-sqlite-table-column-list “people”) ⇒ (“people_description” “people_email” “people_firstname” “people_id” “people_middlenames” “people_name”)
>
> Let us make function to get full person’s name.
>
> - people_firstname can be empty, what if it is empty, it should not be displaed
>
> - people_middlename should be in the middle, but could be empty
>
> - people_name represents either last name or company name or
> group name, business name, list of people, etc. It must be
> there.
>
> (defun my-people-name (id)
> (caar (sqlite-select my-db “SELECT coalesce(CASE WHEN people_firstname IS NOT NULL
> AND length(people_firstname) > 0
> THEN people_firstname || ’ ’
> END, ‘’) ||
> coalesce(CASE WHEN people_middlenames IS NOT NULL
> AND length(people_middlenames) > 0
> THEN people_middlenames || ’ ’
> END, ‘’) ||
> people_name
> FROM people
> WHERE people_id = ?”
> (list id))))
>
> (my-people-name 1) ⇒ “Joseph Joe Doe”
>
> Now function to edit people by their ID programmatically or
> interactively by choice:
>
> (defun my-people-edit (&optional id)
> (interactive)
> (let ((id (or id (my-people-complete)))
> (columns (my-sqlite-table-column-list “people”)))
> (cond (id (let ((column-to-edit (completing-read “Which column to edit? ” columns nil t)))
> (cond ((member column-to-edit columns) (let* ((initial-input (sqlite-db-get-entry “people” column-to-edit id my-db))
> (edited-entry (read-string (format “Edit `%s’: ” column-to-edit) initial-input nil initial-input)))
> (unless (string= initial-input edited-entry)
> (sqlite-execute my-db (format “UPDATE people SET %s = ? WHERE people_id = ?” column-to-edit)
> (list edited-entry id)))
> (my-people-edit id)))
> (t (message “No column choosen”)))))
> (t (message “No person selected for editing”)))))
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ ((1 “Joseph” “Joe” “Doe Junior” “joe@example.com” “This is just a sample description”))
>
> ;; Delete entry
>
> Now let us make possibility to delete single entries:
>
> (defun my-people-delete (&optional id)
> (interactive)
> (let* ((id (or id (my-people-complete)))
> (name (my-people-name id)))
> (when (y-or-n-p (format “Do you wish to delete entry `%s’? ” name))
> (sqlite-execute my-db “DELETE FROM people WHERE people_id = ?” (list id))
> (message “Deleted entry `%s’” name))))
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ nil
>
> Add again:
>
> (my-people-add)
>
> Select from database again:
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ ((1 “Joseph” “joe” “Doe” nil nil))
>
> Edit the entry
> (my-people-edit) or M-x my-people-edit
>
> (sqlite-select my-db “SELECT * FROM people”) ⇒ ((1 “Joseph” “Joe” “Doe” “joe@example.com” “This is just a sample description”))
>
> now we come to export single person to Org entry:
>
> (my-people-to-org 1) ⇒ “* Joseph Joe
> E-mail: joe@example.com
>
> This is just a sample description”
>
> Now we can make full export to Org of all people in the database:
>
> (defun my-people-to-org ()
> (let ((people (flatten-list (sqlite-select my-db “SELECT people_id FROM people”))))
> (with-temp-buffer
> (while people
> (insert (my-people-to-org-single (pop people))))
> (buffer-string))))
>
> (my-people-to-org) ⇒ “* Joseph Joe
>
> E-mail: joe@example.com
>
> This is just a sample description
>
> * Jane
>
>
>
> ”
>
> Then we can export everything to Org file:
>
> (defun my-people-export-to-org-file ()
> (interactive)
> (let ((file (read-file-name “Export people to which Org file? ”)))
> (with-temp-file file
> (insert (my-people-to-org)))))
>
> M-x my-people-export-to-org-file
>
> now when one is aware that people may be managed very easy in the
> SQLite database, one shall examine the modes of SQLite:
>
> .mode MODE ?TABLE? Set output mode where MODE is one of:
> csv Comma-separated values
> column Left-aligned columns. (See .width)
> html HTML <table> code
> insert SQL insert statements for TABLE
> line One value per line
> list Values delimited by .separator string
> tabs Tab-separated values
> tcl TCL list elements
>
> It also means that importing CSV files into SQLite is easy.
> Exporting from SQLite to Org file is also easy.
>
> Exporting SQL is easy:
>
> .mode insert
> sqlite> select * from people;
> INSERT INTO “table” VALUES(1,’Joseph’,’Joe’,’Doe’,’joe@example.com’,’This is just a sample description’);
> INSERT INTO “table” VALUES(2,’Jane’,’’,’Dine’,’’,NULL);
> INSERT INTO “table” VALUES(3,’Robert’,NULL,’Weiner’,’rsw@gnu.org’,NULL);
>
> Or one value per line:
>
> .mode line
> select * from people;
>
> people_id = 1
> people_firstname = Joseph
> people_middlenames = Joe
> people_name = Doe
> people_email = joe@example.com
> people_description = This is just a sample description
>
> people_id = 2
> people_firstname = Jane
> people_middlenames =
> people_name = Dine
> people_email =
> people_description =
>
> people_id = 3
> people_firstname = Robert
> people_middlenames =
> people_name = Weiner
> people_email = rsw@gnu.org
> people_description =
>
> Now we come to relation of Org to people ID.
>
> How about this:
>
> * My heading
> :PROPERTIES:
> :PEOPLE-ID-RELATED: 1
> :END:
>
> Now you know that ID is in the file my-people.sqlite and that ID
> is 1. That is to stay so, immutable.
>
> Let us make the report for person:
>
> (define-derived-mode my-people-view-mode org-mode “My People View Mode”
> “This is read only view mode for people”)
>
> (defun my-people-org-report (id)
> (let* ((name (my-people-name id))
> (buffer (get-buffer-create name))
> (org (my-people-to-org-single id)))
> (pop-to-buffer (get-buffer-create “My people report”))
> (read-only-mode 0)
> (erase-buffer)
> (insert org)
> (goto-char (point-min))
> (my-people-view-mode)
> (keymap-set my-people-view-mode-map “q” #’quit-window)
> (keymap-set my-people-view-mode-map “e” `(lambda () (interactive) (my-people-edit ,id)))
> (read-only-mode 1)))
>
> The above allows to open the new Org buffer where entry from database is shown:
>
> (my-people-org-report 1)
>
> Then I can see this:
>
> * Joseph Joe
>
> E-mail: joe@example.com
>
> This is just a sample description
>
> now back to heading in your real Org file:
>
> * My heading
> :PROPERTIES:
> :PEOPLE-ID-RELATED: 1
> :END:
>
> If person ID 1 is related to this heading, then I can make
> function to quickly see the entry of the person:
>
> (defun my-people-org-set-people-id-name (id)
> (let ((name (my-people-name id)))
> (org-set-property “PEOPLE-ID-NAME” name)))
>
> (defun my-people-org-related-view ()
> (interactive)
> (let ((people-id-related (cdr (assoc “PEOPLE-ID-RELATED” (org-entry-properties)))))
> (cond (people-id-related (progn (my-people-org-set-people-id-name people-id-related)
> (my-people-org-report people-id-related)))
> (t (message “No related contact found in this Org heading”)))))
>
> When there is related contact one jumps into generated Org file by C-c r
>
> and then with “e” one can already edit the contact in general way by using Emacs minibuffer.
>
> And what if we jump to related contact, maybe we still need contact
> name in properties, so it is generated automatically and directly from
> the database.
>
> * My heading
> :PROPERTIES:
> :PEOPLE-ID-RELATED: 1
> :PEOPLE-ID-NAME: Joseph Joe Doe
> :PEOPLE-ID-EMAIL: joe@example.com
> :END:
>
> What if we need email in properties?
>
> (defun my-people-org-set-people-id-email (id)
> (let ((email (sqlite-db-get-entry “people” “people_email” id my-db)))
> (org-set-property “PEOPLE-ID-EMAIL” email)))
>
>
> then
>
> (defun my-people-org-related-view ()
> (interactive)
> (let ((people-id-related (cdr (assoc “PEOPLE-ID-RELATED” (org-entry-properties)))))
> (cond (people-id-related (progn (my-people-org-set-people-id-email people-id-related)
> (my-people-org-set-people-id-name people-id-related)
> (my-people-org-report people-id-related)))
> (t (message “No related contact found in this Org heading”)))))
>
> And how to add related person straight from database?
>
> (defun my-people-org-related-person (&optional id)
> (interactive)
> (let ((id (or id (my-people-complete))))
> (when id
> (org-set-property “PEOPLE-ID-RELATED” (format “%s” id)))))
>
> This all assumes that it is just one person related to heading.
> We could make any number of people related to heading, but let
> us keep it to this example.
>
> At this moment maybe you are writing Org headline that is related
> to SCHOOL ABC:
>
> Here is the flow:
>
> 1. Add new entry in people table by using M-x my-people-add
>
> 2. Make new headline in Org:
>
> ** Cleaning project
>
> 3. Run function M-x my-people-org-related-person
>
> ** Cleaning project
> :PROPERTIES:
> :PEOPLE-ID-RELATED: 4
> :PEOPLE-ID-EMAIL: myschool@example.com
> :PEOPLE-ID-NAME: SCHOOL ABC
> :END:
>
> At this point you may examine the entry for the ABC SCHOOL by clicking
> C-c r and it will update Org properties.
>
> By using this principle it could update anything in Org but also in
> any other type of file.
>
> By using SQLite or PostgreSQL you can use plethora of OTHER PROGRAMS
> to manage entries in your database.
>
> For example in sqlitebrowser:
> <https://gnu.support/images/sqlite/2022/2022-10-09/2022-10-09-13:34:30.png>
>
> Now your contacts are separated from Org. Only by using SQLite browser
> you may freely enter new contacts in the database and edit them by
> your wish. There are many various tools to manage databases.
>
> I am editing contacts by using tabulated list mode in Emacs:
>
> ID 6
> Date created “2021-06-25 15:50:35.1712+03”
> Date modified “2022-10-06 12:37:31.877754+03”
> Prefix nil
> First name “Joe”
> Middle names nil
> Last name (People List Name) “Doe”
> Suffix nil
> Hyperdocument Set #1 nil
> Profile Image nil
> ID Document nil
> Lead source “thispersondoesnotexist.com/”
> Title nil
> Department nil
> Date of birth or Begin Date nil
> End date nil
> Don’t contact nil
> Description nil
> Modified by username “maddox”
> Created by username “maddox”
> Introduced by “Vicente Ramirez”
> Other names nil
> Tokens “‘data’:2 ‘enter’:1 ‘lastnam’:5 ‘people.people’:4”
> Rank 0
> Assigned to nil
> People type “Individual Person”
> Reports to nil
> Communication Language nil
> SIC Code nil
> Industry nil
> Tag #1 nil
> Tag #2 nil
> Tag #3 nil
> Active “Active”
> FROM Identity nil
> Internal information nil
>
> But I can as well edit my contacts by using external tools and
> exchange information with other software.
>
> Do you wish to share your contacts? That is easy, one can simple send
> the full file to somebody.
>
> By followed the thought patterns described one shall understand that
> contacts may be separated from single mode (Org) and separated from
> single software (Emacs) and that it will not minimize or limit you but
> rather widen the capacities and usefulness for human.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 889 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: SQLite for contacts and relations to Org - Re: contact management in emacs
2022-10-11 5:54 ` Sébastien Rey-Coyrehourcq
@ 2022-10-11 19:59 ` Jean Louis
0 siblings, 0 replies; 31+ messages in thread
From: Jean Louis @ 2022-10-11 19:59 UTC (permalink / raw)
To: Sébastien Rey-Coyrehourcq; +Cc: Alan Schmitt, emacs-orgmode
* Sébastien Rey-Coyrehourcq <sebastien.rey-coyrehourcq@univ-rouen.fr> [2022-10-11 08:56]:
> Hi Jean Louis,
>
> First i want to thank you for this very detailled explanation, this is very valuable for someone that start in elisp like me.
>
> Secondly, i found the idea of using sqlite for contacts very interesting, and i think a lot on this solution on my side the last weeks. With the new emacs interface to sql, it was easy i suppose to create a “both-way” syncing tool between org-contact (to easily maintain info, linking to notes, agenda, etc.) and a database that anyone could reuse, move, send also using mobile phone.
>
> I use org-roam that use both of the two world, database and org, in the light of recent discussion, why we cannot do the same things for org-contact ? Linking / syncing properties with unique hash/id also stored in a database. If you have 150000 contact, with 150000 unique ID, and if you want to create an org-contact file/propertie into an org document, that’s probably easy to inject and maintain some sort of syncing (like org-roam do) between the info in database and the info into some properties block no ?
That is exactly the point. Why keep well structured information such
as phone numbers, emails, addresses, in Org file, when structured
information by its type belong into structured forms like databases.
Keeping it in Org or any text files is not scalable, not usable, not
shareable. To tell people to use text files to keep information is
detrimental for people who listen to it. They can't know it
immediately, but one day they will realize that it does not fly.
Why email clients like Thunderbird have contacts features built-in?
For reason that contacts are related to communication and
information. Communication is connection in every relation between
people. Information is written because it fosters communication and
thus relations.
Org contacts try to store contacts into Org file. I don't know the
rest. I have looked inside the Org contacts code and I do not agree
with the design. It is not scalable.
From code:
,----
| To enter new contacts, you can use `org-capture' and a minimal
| template just like..
`----
;; this:
;; ("c" "Contacts" entry (file "~/Org/contacts.org")
;; "* %(org-contacts-template-name)
;; :PROPERTIES:
;; :EMAIL: %(org-contacts-template-email)
;; :END:")))
;;
;; You can also use a complex template, for example:
;;
;; ("c" "Contacts" entry (file "~/Org/contacts.org")
;; "* %(org-contacts-template-name)
;; :PROPERTIES:
;; :EMAIL: %(org-contacts-template-email)
;; :PHONE:
;; :ALIAS:
;; :NICKNAME:
;; :IGNORE:
;; :ICON:
;; :NOTE:
;; :ADDRESS:
;; :BIRTHDAY:
;; :END:")))
;;;; Usage:
;; How to search?
;; - You can use [M-x org-contacts] command to search.
I would not bother using that. Why? Because of experience.
- many people have many various emails, not just one.
- by using email as reference, I quickly jump to list of conversations
with that person
- if email is invalid, I still need the conversation retained
- I must know if email is for work or private, it needs more structure
- phones, I am sending SMS, I must know in structured way, if the
phone belongs to provider ABC or XYZ, as that decides on routing on
how to send SMS messages. Nobody likes spending money by using wrong
providers.
- fax is phone line, mobile phone and fixed lines are not same, I must
know type of phone line;
- aliases and nicknames belong to identities,
- single note about contact is not enough, contact may be related to
many notes.
- address must be structured, otherwise it is really difficult to use
it programmatically:
ID 198333
Date created "2022-10-11 21:28:42.565176"
Date modified nil
User created "maddox"
User modified "maddox"
Person "Joe Doe"
Type "Default address"
Address Name "Address in Germany"
Line #1 ""
Line #2 ""
Line #3 ""
City ""
Region ""
Post code ""
Country "GERMANY"
Date validated nil
Location nil
Description nil
Inactive nil
Default nil
There is no option but to keep structured information in structured
databases. I have working system with PostgreSQL and decentralized
collaboration, but I am now making SQLite minimized version, so when
package is finished I will let you know.
Package preparation:
https://gnu.support/images/2022/10/2022-10-11/Screenshot-2022-10-11-22-50-03-955596051.png
Editing of entry:
https://gnu.support/images/2022/10/2022-10-11/Screenshot-2022-10-11-22-57-51-793932307.png
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2022-10-11 20:29 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-27 11:08 contact management in emacs Alan Schmitt
2021-02-27 11:31 ` Martin Steffen
2021-02-27 13:20 ` andrés ramírez
2021-02-27 14:40 ` Eric S Fraga
2021-02-27 15:12 ` andrés ramírez
2021-02-28 10:21 ` Eric S Fraga
2021-02-27 15:14 ` Martin Steffen
2021-02-27 17:00 ` Dr. Arne Babenhauserheide
2021-02-27 16:53 ` Bob Newell
2021-02-28 9:06 ` Russell Adams
2021-02-28 11:09 ` Alan Schmitt
2021-03-03 14:40 ` TRS-80
2021-03-07 22:57 ` Jean Louis
2021-03-08 20:06 ` John Kitchin
2021-03-10 8:32 ` Jean Louis
2021-03-07 22:13 ` Jean Louis
2021-03-08 7:49 ` Alan Schmitt
2021-03-08 8:12 ` Jose E. Marchesi
2021-03-10 8:32 ` Jean Louis
2022-09-09 16:11 ` Sébastien Rey-Coyrehourcq
2022-09-10 5:46 ` Ihor Radchenko
2022-10-09 10:40 ` SQLite for contacts and relations to Org - " Jean Louis
2022-10-09 15:21 ` Quiliro Ordóñez
2022-10-09 16:59 ` Jean Louis
2022-10-09 19:09 ` Quiliro Ordóñez
2022-10-10 6:12 ` Jean Louis
2022-10-10 22:29 ` Robert Weiner
2022-10-10 23:32 ` Jean Louis
2022-10-11 3:20 ` Robert Weiner
2022-10-11 5:54 ` Sébastien Rey-Coyrehourcq
2022-10-11 19:59 ` Jean Louis
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.