GNU bug report logs -
#33170
27.0.50; interactive spec with cl-defgeneric/method
Previous Next
Reported by: Alex Branham <alex.branham <at> gmail.com>
Date: Fri, 26 Oct 2018 22:20:03 UTC
Severity: normal
Found in version 27.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33170 in the body.
You can then email your comments to 33170 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Fri, 26 Oct 2018 22:20:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alex Branham <alex.branham <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 26 Oct 2018 22:20:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I'm struggling to understand how to make functions defined with
cl-defgeneric interactive:
(require 'cl-lib)
(cl-defgeneric my/test ()
(interactive)
(message "generic"))
If you evaluate that you can do M-x my/test, as expected. However, as
soon as you evaluate this:
(cl-defgeneric my/test (&context (major-mode emacs-lisp-mode))
(interactive)
(message "method"))
M-x my/test no longer works.
Is this a bug or am I misunderstanding how this works?
Thanks,
Alex
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Sat, 27 Oct 2018 06:55:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 33170 <at> debbugs.gnu.org (full text, mbox):
> From: Alex Branham <alex.branham <at> gmail.com>
> Date: Fri, 26 Oct 2018 17:19:44 -0500
>
> I'm struggling to understand how to make functions defined with
> cl-defgeneric interactive:
>
> (require 'cl-lib)
>
> (cl-defgeneric my/test ()
> (interactive)
> (message "generic"))
>
> If you evaluate that you can do M-x my/test, as expected. However, as
> soon as you evaluate this:
>
> (cl-defgeneric my/test (&context (major-mode emacs-lisp-mode))
> (interactive)
> (message "method"))
>
> M-x my/test no longer works.
'&context' is documented only as part of cl-defmethod, so why are you
trying to use it with cl-defgeneric?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Sat, 27 Oct 2018 12:41:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 33170 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sat 27 Oct 2018 at 01:54, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Alex Branham <alex.branham <at> gmail.com>
>> Date: Fri, 26 Oct 2018 17:19:44 -0500
>>
>> I'm struggling to understand how to make functions defined with
>> cl-defgeneric interactive:
>>
>> (require 'cl-lib)
>>
>> (cl-defgeneric my/test ()
>> (interactive)
>> (message "generic"))
>>
>> If you evaluate that you can do M-x my/test, as expected. However, as
>> soon as you evaluate this:
>>
>> (cl-defgeneric my/test (&context (major-mode emacs-lisp-mode))
>> (interactive)
>> (message "method"))
>>
>> M-x my/test no longer works.
>
> '&context' is documented only as part of cl-defmethod, so why are you
> trying to use it with cl-defgeneric?
Sorry, that was a typo. The same thing happens if you use defmethod:
(require 'cl-lib)
(cl-defgeneric my/test ()
(interactive)
(message "generic"))
here, M-x my/test works
(cl-defmethod my/test (&context (major-mode emacs-lisp-mode))
(interactive)
(message "method"))
Here, M-x my/test does not work.
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Sat, 27 Oct 2018 14:48:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 33170 <at> debbugs.gnu.org (full text, mbox):
> From: Alex Branham <alex.branham <at> gmail.com>
> Cc: 33170 <at> debbugs.gnu.org
> Date: Sat, 27 Oct 2018 07:40:11 -0500
>
> (require 'cl-lib)
>
> (cl-defgeneric my/test ()
> (interactive)
> (message "generic"))
>
> here, M-x my/test works
>
> (cl-defmethod my/test (&context (major-mode emacs-lisp-mode))
> (interactive)
> (message "method"))
>
> Here, M-x my/test does not work.
But "M-: (my/test) RET" does.
I don't think generic functions can be interactive. At least it is
not documented anywhere that they can be.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Sat, 27 Oct 2018 14:51:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 33170 <at> debbugs.gnu.org (full text, mbox):
On Sat 27 Oct 2018 at 09:47, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> (require 'cl-lib)
>>
>> (cl-defgeneric my/test ()
>> (interactive)
>> (message "generic"))
>>
>> here, M-x my/test works
>>
>> (cl-defmethod my/test (&context (major-mode emacs-lisp-mode))
>> (interactive)
>> (message "method"))
>>
>> Here, M-x my/test does not work.
>
> But "M-: (my/test) RET" does.
Right. I'd like them to be interactive though so I can e.g. use them
from a keymap.
> I don't think generic functions can be interactive. At least it is
> not documented anywhere that they can be.
Ah, that's unfortunate. Perhaps this limitation should be documented
somewhere?
Thanks,
Alex
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Sat, 27 Oct 2018 16:12:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 33170 <at> debbugs.gnu.org (full text, mbox):
> From: Alex Branham <alex.branham <at> gmail.com>
> Cc: 33170 <at> debbugs.gnu.org
> Date: Sat, 27 Oct 2018 09:50:26 -0500
>
> >> Here, M-x my/test does not work.
> >
> > But "M-: (my/test) RET" does.
>
> Right. I'd like them to be interactive though so I can e.g. use them
> from a keymap.
You could have a single command that invoked my/test, I think that
would do what you want.
> > I don't think generic functions can be interactive. At least it is
> > not documented anywhere that they can be.
>
> Ah, that's unfortunate. Perhaps this limitation should be documented
> somewhere?
If Stefan (CC'ed) says it's a limitation and not a bug, I will
document it.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Sat, 27 Oct 2018 16:15:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 33170 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sat 27 Oct 2018 at 11:11, Eli Zaretskii <eliz <at> gnu.org> wrote:
> You could have a single command that invoked my/test, I think that
> would do what you want.
Ah, good idea. That does work, thanks!
Alex
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Sat, 27 Oct 2018 21:50:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 33170 <at> debbugs.gnu.org (full text, mbox):
>> > I don't think generic functions can be interactive. At least it is
>> > not documented anywhere that they can be.
>> Ah, that's unfortunate. Perhaps this limitation should be documented
>> somewhere?
> If Stefan (CC'ed) says it's a limitation and not a bug, I will
> document it.
AFAIC it's a limitation. We could support interactive specs, but I'm
really not convinced it's worth the trouble. If using 2 functions (one
generic and one interactive, which calls the generic one) is really
annoying for some reason, I guess you could use
(put '<GENERIC> 'interactive-form <FORM>)
but I think this property should be deprecated, so don't tell anyone
(especially don't tell me) that I even mentioned it to you,
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Mon, 29 Oct 2018 14:20:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 33170 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sat 27 Oct 2018 at 16:49, Stefan Monnier <monnier <at> IRO.UMontreal.CA> wrote:
> AFAIC it's a limitation. We could support interactive specs, but I'm
> really not convinced it's worth the trouble. If using 2 functions (one
> generic and one interactive, which calls the generic one) is really
> annoying for some reason, I guess you could use
>
> (put '<GENERIC> 'interactive-form <FORM>)
>
> but I think this property should be deprecated, so don't tell anyone
> (especially don't tell me) that I even mentioned it to you,
Thanks for the response. Seems like the two-function solution is the way
to go I guess. I do think this should be documented as a limitation
somewhere though. Perhaps a note at the end of that section in the
manual along the lines:
Note that a current limitation of generic functions is that they may not
be interactive. The recommended way of working around this is to define
an interactive function that simply calls the generic function.
That's not strictly true of course since (cl-defgeneric foo ()
(interactive) (message "foo")) works just fine. It's adding methods that
seems to mess it up.
Alex
[signature.asc (application/pgp-signature, inline)]
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Tue, 30 Oct 2018 10:16:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Alex Branham <alex.branham <at> gmail.com>
:
bug acknowledged by developer.
(Tue, 30 Oct 2018 10:16:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 33170-done <at> debbugs.gnu.org (full text, mbox):
> From: Alex Branham <alex.branham <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 33170 <at> debbugs.gnu.org
> Date: Mon, 29 Oct 2018 09:18:53 -0500
>
> On Sat 27 Oct 2018 at 16:49, Stefan Monnier <monnier <at> IRO.UMontreal.CA> wrote:
>
> > AFAIC it's a limitation. We could support interactive specs, but I'm
> > really not convinced it's worth the trouble. If using 2 functions (one
> > generic and one interactive, which calls the generic one) is really
> > annoying for some reason, I guess you could use
> >
> > (put '<GENERIC> 'interactive-form <FORM>)
> >
> > but I think this property should be deprecated, so don't tell anyone
> > (especially don't tell me) that I even mentioned it to you,
>
> Thanks for the response. Seems like the two-function solution is the way
> to go I guess. I do think this should be documented as a limitation
> somewhere though.
Done.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Tue, 30 Oct 2018 12:49:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 33170-done <at> debbugs.gnu.org (full text, mbox):
>> Thanks for the response. Seems like the two-function solution is the way
>> to go I guess. I do think this should be documented as a limitation
>> somewhere though.
> Done.
Should we add a warning for it?
Stefan
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index fb4f3ab680..025653de70 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -355,6 +355,9 @@ cl-generic-define-context-rewriter
. ,(lambda () spec-args))
macroexpand-all-environment)))
(require 'cl-lib) ;Needed to expand `cl-flet' and `cl-function'.
+ (when (interactive-form (cadr fun))
+ (message "Interactive forms unsupported in generic functions: %S"
+ (interactive-form (cadr fun))))
;; First macroexpand away the cl-function stuff (e.g. &key and
;; destructuring args, `declare' and whatnot).
(pcase (macroexpand fun macroenv)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Tue, 30 Oct 2018 13:10:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 33170-done <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Cc: Alex Branham <alex.branham <at> gmail.com>, 33170-done <at> debbugs.gnu.org
> Date: Tue, 30 Oct 2018 08:48:49 -0400
>
> >> Thanks for the response. Seems like the two-function solution is the way
> >> to go I guess. I do think this should be documented as a limitation
> >> somewhere though.
> > Done.
>
> Should we add a warning for it?
No objections from me.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33170
; Package
emacs
.
(Wed, 31 Oct 2018 14:50:02 GMT)
Full text and
rfc822 format available.
Message #43 received at 33170-done <at> debbugs.gnu.org (full text, mbox):
>> Should we add a warning for it?
> No objections from me.
Done in `master`.
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 29 Nov 2018 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 260 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.