[Top][All Lists]

[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 <> 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"?


reply via email to

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