[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25294: 26.0.50; Allow more catch-all values for cl-defmethod's &cont
From: |
Noam Postavsky |
Subject: |
bug#25294: 26.0.50; Allow more catch-all values for cl-defmethod's &context plus major-mode specializer |
Date: |
Tue, 12 Dec 2017 18:58:32 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) |
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> +Generic functions provide a new argument-list keyword,
The way you phrased this might lead me to think that the &context
keyword should go in the cl-defgeneric form (maybe it's not so bad when
seeing in context under cl-defmethod, in patch form it's a bit
disconnected).
> +@code{&context}, which can be used to introduce extra specializers
> +that test the general environment in which the method is run. This
> +keyword should appear after the list of required arguments, but before
> +any @code{&rest} or @code{&optional} keywords.
I wonder if it would be clearer to add this to the @defmac header?
@defmac cl-defmethod name [qualifier] arguments [&context (expr
spec)@dots{}] &rest [docstring] body
Hmm, maybe that ends up being too long.
> The @code{&context}
> +specializers look much like regular argument
> +specializers---(@var{expr} @var{spec})---except that @var{expr} is an
> +expression to be evaluated in the current context, and the @var{spec}
> +is a value to compare against. For example, @code{&context
> +(overwrite-mode (eql t))} will make the method applicable only when
> +@code{overwrite-mode} is turned on. The @code{&context} keyword can
> +be followed by any number of context specializers. Because the
> +context specializers are not part of the generic function's required
> +argument signature, they may be omitted in methods that don't require
> +them.
Otherwise looks fine.