[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "fall-through" generic function args plus &context
From: |
Eric Abrahamsen |
Subject: |
Re: "fall-through" generic function args plus &context |
Date: |
Mon, 26 Dec 2016 14:48:08 -0800 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/26.0.50 (gnu/linux) |
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> I have a few defmethods that use the &context construct to dispatch on
> the value of major mode:
>
> (cl-defmethod my-make-buffer-name (&context (major-mode gnus-summary-mode))
> ;; etc...
> )
>
> I need a catch-all method, for default behavior when we're in other
> modes that aren't targeted by an existing method.
>
> I've tried things like:
>
> (&context _major-mode)
> (&context (major-mode t))
> (&context (major-mode nil))
> (&context (major-mode (eql _nuthin))
>
> And a few other things. Everything raises cl-no-applicable-method.
>
> What's the correct way to do this? Or do I need to override
> `cl-no-applicable-method' and catch the error?
Come to think of it, how does one override `cl-no-applicable-method' for
a specific generic? The defgeneric looks like:
(cl-defgeneric cl-no-applicable-method (generic &rest args)
"Function called when a method call finds no applicable method."
(signal 'cl-no-applicable-method `(,(cl--generic-name generic) ,@args)))
How do I specialize on "generic"?
Thanks,
Eric
- "fall-through" generic function args plus &context, Eric Abrahamsen, 2016/12/26
- Re: "fall-through" generic function args plus &context,
Eric Abrahamsen <=
- Re: "fall-through" generic function args plus &context, Stefan Monnier, 2016/12/27
- Re: "fall-through" generic function args plus &context, Eric Abrahamsen, 2016/12/27
- Re: "fall-through" generic function args plus &context, Stefan Monnier, 2016/12/28
- Re: "fall-through" generic function args plus &context, Eric Abrahamsen, 2016/12/29
- Re: "fall-through" generic function args plus &context, Stefan Monnier, 2016/12/29
- Re: "fall-through" generic function args plus &context, Eric Abrahamsen, 2016/12/30
- Re: "fall-through" generic function args plus &context, Stefan Monnier, 2016/12/30
Re: "fall-through" generic function args plus &context, Stefan Monnier, 2016/12/26