* 'No applicable method' error when calling 'gnus-icalendar-save-part'
@ 2024-10-08 16:31 Fabio Natali
2024-10-09 19:54 ` Emanuel Berg
2024-10-13 0:11 ` James Thomas via Emacs development discussions.
0 siblings, 2 replies; 5+ messages in thread
From: Fabio Natali @ 2024-10-08 16:31 UTC (permalink / raw)
To: emacs-devel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 'No applicable method' error when calling 'gnus-icalendar-save-part'
2024-10-08 16:31 'No applicable method' error when calling 'gnus-icalendar-save-part' Fabio Natali
@ 2024-10-09 19:54 ` Emanuel Berg
2024-10-13 0:11 ` James Thomas via Emacs development discussions.
1 sibling, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2024-10-09 19:54 UTC (permalink / raw)
To: emacs-devel
Fabio Natali wrote:
> 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.
To no really answer your question, I get that error message,
sometimes - 'No applicable method' - with EIEIO (eieio.el),
with `cl-defmethod' where it is setup on multiple places for
different types or combinations thereof. But for this one in
particular, there isn't such a one setup.
So [at least in my context] I interpret the message as saying
"They could be that possibility, to do precisely that - but
there isn't".
Maybe it would be more clear if it had just said
"No <method name> specified for arguments [TYPE [* TYPE ...]]"
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 'No applicable method' error when calling 'gnus-icalendar-save-part'
2024-10-08 16:31 'No applicable method' error when calling 'gnus-icalendar-save-part' Fabio Natali
2024-10-09 19:54 ` Emanuel Berg
@ 2024-10-13 0:11 ` James Thomas via Emacs development discussions.
2024-10-13 19:11 ` Fabio Natali
1 sibling, 1 reply; 5+ messages in thread
From: James Thomas via Emacs development discussions. @ 2024-10-13 0:11 UTC (permalink / raw)
To: emacs-devel
Fabio Natali wrote:
> 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:
>
> (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))
>
>
> Calling 'notmuch-show-import-icalendar-part' when on top of an iCalendar
> attachment results in this error:
(I don't use this, yet, so this is all speculative)
Have you tried using gnus-icalendar-sync-event-to-org? Something like:
(defun notmuch-show-import-icalendar-part ()
"Import the iCalendar part at point to Org Agenda."
(interactive)
(let (gnus-icalendar-reply-status)
(notmuch-show-apply-to-current-part-handle
#'gnus-icalendar-sync-event-to-org)))
Because gnus-icalendar-save-part is not interactive. That honor falls to
gnus-icalendar-save-event and seems to be integrated with Gnus.
Regards,
James
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 'No applicable method' error when calling 'gnus-icalendar-save-part'
2024-10-13 0:11 ` James Thomas via Emacs development discussions.
@ 2024-10-13 19:11 ` Fabio Natali
2024-10-13 22:50 ` James Thomas
0 siblings, 1 reply; 5+ messages in thread
From: Fabio Natali @ 2024-10-13 19:11 UTC (permalink / raw)
To: James Thomas, emacs-devel
Hi James,
Thanks for getting back to me!
On 2024-10-13, 05:41 +0530, James Thomas via "Emacs development discussions." <emacs-devel@gnu.org> wrote:
> Have you tried using gnus-icalendar-sync-event-to-org?
>
> Something like:
>
> (defun notmuch-show-import-icalendar-part ()
> "Import the iCalendar part at point to Org Agenda."
> (interactive)
> (let (gnus-icalendar-reply-status)
> (notmuch-show-apply-to-current-part-handle
> #'gnus-icalendar-sync-event-to-org)))
This also gives a 'No applicable method' error:
--8<---------------cut here---------------start------------->8---
cl-no-applicable-method: No applicable method:
gnus-icalendar-event:sync-to-org, (#<killed buffer> ("text/calendar")
nil nil (attachment (filename . "file.ics")) nil nil nil), nil
--8<---------------cut here---------------end--------------->8---
I think the reason is that 'gnus-icalendar-sync-event-to-org' expects an
'event' as input but a 'handle' is instead passed.
'gnus-icalendar-save-part' does expect and does correctly receive a
'handle' but it then fails for the reasons explained in my previous
email. Considering the signature, it'd seem that
'gnus-icalendar-save-part' is the appropriate method?
I'd be tempted to send a patch along the lines of option 2 from my other
email and then see what reviewers think. Unless you've any other idea
around 'gnus-icalendar-sync-event-to-org' or if I've
missed/misinterpreted any of the steps.
Thanks, cheers, Fabio.
--
Fabio Natali
https://fabionatali.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: 'No applicable method' error when calling 'gnus-icalendar-save-part'
2024-10-13 19:11 ` Fabio Natali
@ 2024-10-13 22:50 ` James Thomas
0 siblings, 0 replies; 5+ messages in thread
From: James Thomas @ 2024-10-13 22:50 UTC (permalink / raw)
To: Fabio Natali; +Cc: emacs-devel
Fabio Natali wrote:
> On 2024-10-13, 05:41 +0530, James Thomas via "Emacs development
> discussions." <emacs-devel@gnu.org> wrote:
>> Have you tried using gnus-icalendar-sync-event-to-org?
>>
>> Something like:
>>
>> (defun notmuch-show-import-icalendar-part ()
>> "Import the iCalendar part at point to Org Agenda."
>> (interactive)
>> (let (gnus-icalendar-reply-status)
>> (notmuch-show-apply-to-current-part-handle
>> #'gnus-icalendar-sync-event-to-org)))
>
> This also gives a 'No applicable method' error:
>
> cl-no-applicable-method: No applicable method:
> gnus-icalendar-event:sync-to-org, (#<killed buffer> ("text/calendar")
> nil nil (attachment (filename . "file.ics")) nil nil nil), nil
>
> I think the reason is that 'gnus-icalendar-sync-event-to-org' expects an
> 'event' as input but a 'handle' is instead passed.
OK, that's one thing; another is that it'll be the same REPLY event.
> 'gnus-icalendar-save-part' does expect and does correctly receive a
> 'handle' but it then fails for the reasons explained in my previous
> email. Considering the signature, it'd seem that
> 'gnus-icalendar-save-part' is the appropriate method?
> I'd be tempted to send a patch along the lines of option 2 from my other
> email and then see what reviewers think. Unless you've any other idea
> around 'gnus-icalendar-sync-event-to-org' or if I've
> missed/misinterpreted any of the steps.
I don't recommend your patch because the original reasoning might've
been that a REPLY event isn't significant enough to be 'saved' anywhere.
It might be better to use your _adaptation_ instead.
Otherwise the 'right' way to do this would be another method for the
REPLY event.
(cl-defmethod gnus-icalendar-event:sync-to-org ((event
gnus-icalendar-event-reply) _reply-status) ...)
Regards,
James
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-13 22:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 16:31 'No applicable method' error when calling 'gnus-icalendar-save-part' Fabio Natali
2024-10-09 19:54 ` Emanuel Berg
2024-10-13 0:11 ` James Thomas via Emacs development discussions.
2024-10-13 19:11 ` Fabio Natali
2024-10-13 22:50 ` James Thomas
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.