unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [ELPA] Proposed package: vcard
Date: Sun, 02 Feb 2020 09:50:42 -0800	[thread overview]
Message-ID: <87tv48q3nx.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <jwvy2tm9z2i.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 01 Feb 2020 09:22:04 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I wanted to add full vCard support to EBDB, including parsing vCard
>> files. There are some vCard-related packages in the repos already, but
>> they're all tied to some other specific library (BBDB, Org, etc), and I
>> thought it would be good to have a library that does a sort of
>> vCard-to-vanilla-data-structure process, so I wrote a new one. Yes, I am
>> aware of the relevant XKCD comic.
>
> The solution to the XKCD's objection is to rewrite at least one of the
> existing solutions on top of your library.  Bonus points if your new one
> is obtained by extracting code from that existing other solution rather
> than by writing it all from scratch.

Okay, not a bad idea. I'll see if any of them are amenable.

>>    Note: It is possible for very simple implementations to generate
>>    improperly folded lines in the middle of a UTF-8 multi-octet
>>    sequence.  For this reason, implementations SHOULD unfold lines in
>>    such a way as to properly restore the original sequence.
>>
>>    The dumb solution is to find *.vcf files literally, and delete all
>>    runs of \015\012\040 or \015\012\011. But then the file should be
>>    _revisited_ and decoded using whatever coding system and other
>>    parameters that Emacs had originally guessed heuristically for the
>>    file.
>
> Hmm... so you have to make sure it's first opened as binary, then
> do the unfolding, then do the normal decoding?  

Right, sort of interrupt then resume the normal process somehow.

>> I haven't come up with a clean way of doing that (apart from
>>    maybe saving a temporary intermediate file).
>
> I think the right answer likely involves `after-insert-file-set-coding`,
> and `set-auto-coding`, but there's probably more to it.

Okay, I've started looking at this stuff. It might take me a while.

>> 3. The vcard-mode font-locking doesn't work correctly. The value of
>>    `font-lock-defaults' is set to:
>>
>>    (defvar vcard-font-lock-keywords
>>     '("BEGIN:VCARD" "END:VCARD"
>>      ("^[^;:]+" . 'vcard-property-face)
>>      (";\\([^=]+\\)=" (1 'vcard-parameter-key-face))
>>      ("=\\([^;:]+\\)[;:]" (1 'vcard-parameter-value-face))))
>>
>>    But this _sometimes_ doesn't highlight the parameter keys correctly,
>>    and I don't know why. I've never messed with font locking before, and
>>    would appreciate pointers. I think it might have to do with
>>    overlapping matches.
>
> Give us an example,

Here's the full example vCard:

BEGIN:VCARD
VERSION:3.0
N:Doe;John;;;
FN:John Doe
ORG:Example.com Inc.;
TITLE:Imaginary test person
EMAIL;type=INTERNET;type=WORK;type=pref:johnDoe@example.org
TEL;type=WORK;type=pref:+1 617 555 1212
TEL;type=WORK:+1 (617) 555-1234
TEL;type=CELL:+1 781 555 1212
TEL;type=HOME:+1 202 555 1212
item1.ADR;type=WORK:;;2 Enterprise Avenue;Worktown;NY;01111;USA
item1.X-ABADR:us
item2.ADR;type=HOME;type=pref:;;3 Acacia Avenue;Hometown;MA;02222;USA
item2.X-ABADR:us
NOTE:John Doe has a long and varied history\, being documented on more police files that anyone else. Reports of his death are alas numerous.
item3.URL;type=pref:http\://www.example/com/doe
item3.X-ABLabel:_$!<HomePage>!$_
item4.URL:http\://www.example.com/Joe/foaf.df
item4.X-ABLabel:FOAF
item5.X-ABRELATEDNAMES;type=pref:Jane Doe
item5.X-ABLabel:_$!<Friend>!$_
CATEGORIES:Work,Test group
X-ABUID:5AD380FD-B2DE-4261-BA99-DE1D1DB52FBE\:ABPerson
END:VCARD

When I put that into vcard-mode, the first "type" parameter key on the
EMAIL property and the item2.ADR property aren't given a face (but
subsequent "type" keys are).

Thanks,
Eric



  reply	other threads:[~2020-02-02 17:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-01  4:21 [ELPA] Proposed package: vcard Eric Abrahamsen
2020-02-01 14:22 ` Stefan Monnier
2020-02-02 17:50   ` Eric Abrahamsen [this message]
2020-02-03 20:05     ` Eric Abrahamsen
2020-02-03 20:52       ` Stefan Monnier
2020-02-03 21:26         ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tv48q3nx.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).