emacs-devel
[Top][All Lists]
Advanced

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

'No applicable method' error when calling 'gnus-icalendar-save-part'


From: Fabio Natali
Subject: 'No applicable method' error when calling 'gnus-icalendar-save-part'
Date: Tue, 08 Oct 2024 17:31:58 +0100

Hi All,

This is to bring up an issue I found while using gnus-icalendar. It's
the first time I use this library, not sure whether this is a bug or
simply incorrect usage on my part.

My setup is Emacs 29.4 + Notmuch 0.38.2.

My Emacs configuration includes:

--8<---------------cut here---------------start------------->8---
(require 'org-agenda)
(require 'gnus-icalendar)
(setq gnus-icalendar-org-capture-file "~/calendar.org")
(setq gnus-icalendar-org-capture-headline '("Calendar"))
(gnus-icalendar-org-setup)

(defun notmuch-show-import-icalendar-part ()
  "Import the iCalendar part at point to Org Agenda."
  (interactive)
  (notmuch-show-apply-to-current-part-handle #'gnus-icalendar-save-part))
--8<---------------cut here---------------end--------------->8---

Calling 'notmuch-show-import-icalendar-part' when on top of an iCalendar
attachment results in this error:

'cl-no-applicable-method: No applicable method: 
gnus-icalendar-event:sync-to-org, ...'.

Thanks to help received in the Emacs IRC channel, it was possible to
narrow things down to 'gnus-icalendar-event:sync-to-org' and its
signature, see [0]. Indeed the function expects either a
'gnus-icalendar-event-request' or a 'gnus-icalendar-event-cancel' in
input. My 'notmuch-show-import-icalendar-part' sends a 'event
gnus-icalendar-event-reply' though.

Emacs is therefore right in raising a 'No applicable method'... go
figure! :)

There seem to be at least two ways of fixing this.

I can define a custom 'my/gnus-icalendar-save-part' that wraps around
'gnus-icalendar:org-event-save' instead of 'gnus-icalendar:sync-to-org',
as follows:

--8<---------------cut here---------------start------------->8---
;; Like 'gnus-icalendar-save-part' but invoke 'gnus-icalendar:org-event-save'.
(defun my/gnus-icalendar-save-part (handle)
  (let (event)
    (when (and (equal (car (mm-handle-type handle)) "text/calendar")
               (setq event (gnus-icalendar-event-from-handle
                            handle (gnus-icalendar-identities))))
      (gnus-icalendar:org-event-save event nil))))

(defun notmuch-show-import-icalendar-part ()
  "Import the iCalendar part at point to Org Agenda."
  (interactive)
  (notmuch-show-apply-to-current-part-handle #'my/gnus-icalendar-save-part))
--8<---------------cut here---------------end--------------->8---

A second way of going about this, however, would be to change
'gnus-icalendar-event:sync-to-org' upstream:

--8<---------------cut here---------------start------------->8---
;; Like the original except expect a 'gnus-icalendar-event' event instead of a
;; 'gnus-icalendar-event-request'. The 'reply-status' argument is also marked as
;; optional now.
(cl-defmethod gnus-icalendar-event:sync-to-org
  ((event gnus-icalendar-event) &optional reply-status)
  (if (gnus-icalendar-find-org-event-file event)
      (gnus-icalendar--update-org-event event reply-status)
    (progn
      (gnus-icalendar:org-event-save event reply-status))))
--8<---------------cut here---------------end--------------->8---

If you think this is a bug, then I guess the second option above is the
preferred one. Glad to send a quick patch in case. What do you think?
Does the tentative fix above look like the way to go?

Thanks, best wishes, Fabio.


- [0] 
https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/gnus/gnus-icalendar.el#n751



reply via email to

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