From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] Proposed package: vcard Date: Sun, 02 Feb 2020 09:50:42 -0800 Message-ID: <87tv48q3nx.fsf@ericabrahamsen.net> References: <878slnq6nu.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="125351"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 02 18:51:24 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iyJP1-000WTh-U2 for ged-emacs-devel@m.gmane-mx.org; Sun, 02 Feb 2020 18:51:23 +0100 Original-Received: from localhost ([::1]:58374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyJP1-0007pz-0F for ged-emacs-devel@m.gmane-mx.org; Sun, 02 Feb 2020 12:51:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42150) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyJOW-0007C5-C3 for emacs-devel@gnu.org; Sun, 02 Feb 2020 12:50:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyJOV-0008UM-2U for emacs-devel@gnu.org; Sun, 02 Feb 2020 12:50:52 -0500 Original-Received: from ericabrahamsen.net ([52.70.2.18]:34156 helo=mail.ericabrahamsen.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iyJOU-0008HY-V0 for emacs-devel@gnu.org; Sun, 02 Feb 2020 12:50:51 -0500 Original-Received: from localhost (c-73-254-86-141.hsd1.wa.comcast.net [73.254.86.141]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 425FDFBF03; Sun, 2 Feb 2020 17:50:43 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Sat, 01 Feb 2020 09:22:04 -0500") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 52.70.2.18 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244821 Archived-At: Stefan Monnier 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:_$!!$_ item4.URL:http\://www.example.com/Joe/foaf.df item4.X-ABLabel:FOAF item5.X-ABRELATEDNAMES;type=pref:Jane Doe item5.X-ABLabel:_$!!$_ 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