emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ELPA] Proposed package: vcard


From: Eric Abrahamsen
Subject: Re: [ELPA] Proposed package: vcard
Date: Sun, 02 Feb 2020 09:50:42 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier <address@hidden> 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:address@hidden
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 via email to

[Prev in Thread] Current Thread [Next in Thread]