From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.devel Subject: Re: Improving Emacs' iCalendar support Date: Mon, 21 Oct 2024 11:52:22 +0530 Message-ID: <87a5eyug9t.fsf@gmail.com> References: <87ed4dss2x.fsf@ohm.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39055"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Richard Lawrence Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 21 08:23:24 2024 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 1t2lp6-000A0H-Ae for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Oct 2024 08:23:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2loJ-00018w-AS; Mon, 21 Oct 2024 02:22:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2loG-00018e-20 for emacs-devel@gnu.org; Mon, 21 Oct 2024 02:22:32 -0400 Original-Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t2loC-0007hg-9C for emacs-devel@gnu.org; Mon, 21 Oct 2024 02:22:31 -0400 Original-Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-71e67d12d04so3195201b3a.1 for ; Sun, 20 Oct 2024 23:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729491746; x=1730096546; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ElTdjBEv2cfpk9pan1gzxPCV0FRgnPhkO4IfHNqAeW4=; b=TDYCr3ENbSbB/vgJeE7SifFTrxv+mlBKDhQF7gpvn9E2VkLmrgbhnp6bDgfxe9PRAb 70X0mRn9bIGS4aVQ/najhDLl+DJBc2w1IGlHYTUOZcUFBozwCzzSc/W1p4fnMAcDYvsU Q65uLUx6s+680pAFkL8e2OVCbdsRKsF7ASfZ6iWOpate4F1uP4TP/SSyYmvrXBPv1r3M qwYvZYxiKoYCR6qAgmGLYSyMjtGfmEWmnrkRZ8cMPVQVM0tquUEjv1Y02ZUn+wVoLrsV uT8koAzPk4T8lLctoMLDgU/7F25/Ro8zfYlKS/ctgZvU3EyyiEL/giulzy8wbTzCb9VP lVZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729491746; x=1730096546; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ElTdjBEv2cfpk9pan1gzxPCV0FRgnPhkO4IfHNqAeW4=; b=MMh+wRm9hdY68nNqWHKPkE6j4GSSTGT7YB6G2YMW5CdfaL7LsRqlYbWVjMW2kC5b6P uW0IDNufW/NrV+IS1LXEK3x2cQraQoMbhVNvHYWcQDAnawUKtHS6CciTJSfiUPUkhZfx L4WGvXVIyQrVgTOBmg9b46NjN56INZDJKi9TjMHuWBcbcsUSNoKul+oshOBnnZsU17NR /5D3RmvkIZ0PISgMXdAJtAHG1Fr5OtCGQZJyTJ2gUvfvXAjU7BYD0F9TpQUxq6yAEc93 nT9VtvETU9hJC4Aos6cnT6Br7wKo+Yv1cmph+o8irY+QOBDSEOw/j1B3nU7eVtHJky0X tf9A== X-Gm-Message-State: AOJu0YwLfERegYK20HaFvaJuILi0Ai+2zMdY6BJ4O/7MGXoU6KAKbECI Hyn1+bis6LiPQX1iINp3uzvJ6/0U2bAWtTg9CFKQCs8TCcXlrVWm6/1Aj37D X-Google-Smtp-Source: AGHT+IGKeCHyLCXlkuUeEm6NXDorW5SUGXQKt4szNuX8YZUihNSIqL+WwpncPI++6YJdJlUgp0fYFw== X-Received: by 2002:a05:6a00:cc4:b0:71e:3b8:666b with SMTP id d2e1a72fcca58-71ea325b489mr15088153b3a.15.1729491746113; Sun, 20 Oct 2024 23:22:26 -0700 (PDT) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7eaeab1e79bsm2242941a12.32.2024.10.20.23.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 23:22:25 -0700 (PDT) In-Reply-To: <87ed4dss2x.fsf@ohm.mail-host-address-is-not-set> (Richard Lawrence's message of "Fri, 18 Oct 2024 11:01:10 +0200") Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=visuweshm@gmail.com; helo=mail-pf1-x443.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324698 Archived-At: [=E0=AE=B5=E0=AF=86=E0=AE=B3=E0=AF=8D=E0=AE=B3=E0=AE=BF =E0=AE=85=E0=AE=95= =E0=AF=8D=E0=AE=9F=E0=AF=8B=E0=AE=AA=E0=AE=B0=E0=AF=8D 18, 2024] Richard La= wrence wrote: > Dear emacs-devel, > > Hello! I've been a happy Emacs user for almost twenty years now(!), but > this is my first time subscribing to this list, so please help me follow > the local conventions. > > I would like to start a discussion about improving Emacs' iCalendar > support, beyond what is already available in icalendar.el. I personally > would like to see Emacs gain a more full-fledged RFC5545 implementation > that is primarily designed as a library for other applications to use. > > This is an itch that's been bugging me for a while, and so for the past > couple of weeks I've been working on scratching it, and I now have a > reasonable chunk of work to share: I've drafted a new implementation of > the iCalendar grammar, and a major mode which uses this grammar to > provide syntax highlighting. I wrote up what I've done and why here: > > https://recursewithless.net/emacs/icalendar-parser-and-mode.org > > That's a literate Org mode file containing the code and my commentary. > If you just want to read the code itself, see: > > https://recursewithless.net/emacs/icalendar/icalendar-parser.el > https://recursewithless.net/emacs/icalendar/icalendar-mode.el > > I could release this work as a package, but as I describe in more > detail in the write-up, I think there's a good case that an improved > iCalendar library belongs in Emacs' core. There are currently at least > *three* partial iCalendar implementations in Emacs (icalendar.el, > gnus-icalendar.el, and ox-icalendar.el), which are each focused on a > particular major mode (diary, Gnus, and Org). I think it would be good > to consolidate this work in one place and generalize it so that all > three of these applications, as well as third party packages, can > benefit. > > So, some questions for the list: > > 1) Is there interest in getting this code, and/or a future version of > such a library, into Emacs? I don't use much of the icalendar stuff except this one function that I use to extract holidays from govt. supplied ical file: (defun vz/get-indian-holidays () "Parse the icalendar file provided by the Indian government. This returns a list that can be used in calendar's holiday." (unless (file-exists-p (expand-file-name "~/lib/indianical/")) (make-directory (expand-file-name "~/lib/indianical/") t)) (let* ((year (decoded-time-year (decode-time))) (file (expand-file-name (format "~/lib/indianical/%d" year)))) (unless (file-exists-p file) (url-copy-file (format "http://www.india.gov.in/calendar/%d/export.ics" year) file)) (with-temp-buffer (require 'icalendar) (insert-file-contents file) ;; (set-buffer-file-coding-system 'unix) (goto-char (point-min)) (seq-keep (lambda (x) (when-let* ((description (icalendar--get-event-property x 'DES= CRIPTION)) ((seq-find (lambda (h) (let (case-fold-search) (string-match-p h descr= iption))) vz/indian-holidays))) (let ((time (icalendar--decode-isodatetime (icalendar--get-e= vent-property x 'DTSTART)))) (list 'holiday-fixed (decoded-time-month time) (decoded-ti= me-day time) (string-trim-right description " +([GR])"))))) (icalendar--all-events (icalendar--read-element nil nil)))))) It has been at least a couple years since I wrote this function so I don't remember the hurdles I faced when I wrote it very well but it perplexed me that there were no "public" functions that were geared towards parsing an ical file. In retrospect, it would have been less confusing if these functions were "public" functions. AFAIR, and this very well might not be true, the structure returned icalendar--read-element is not really documented anywhere which further added to the confusion. That said, this function has been rock solid ever since I wrote it. Going by the ical files I have, it is working just fine since 2021.