GNU bug report logs -
#25294
26.0.50; Allow more catch-all values for cl-defmethod's &context plus major-mode specializer
Previous Next
Reported by: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Date: Thu, 29 Dec 2016 19:14:02 UTC
Severity: wishlist
Tags: moreinfo
Found in version 26.0.50
Done: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Ahem, I only just noticed (a year later) that there was a response to
this when I searched for bug reports I'd opened -- sorry about that.
> Is this about the undocumented specializer mentioned in cl-generic.el?
>
> ;;; Dispatch on major mode.
>
> ;; Two parts:
> ;; - first define a specializer (derived-mode <mode>) to match symbols
> ;; representing major modes, while obeying the major mode hierarchy.
> ;; - then define a context-rewriter so you can write
> ;; "&context (major-mode c-mode)" rather than
> ;; "&context (major-mode (derived-mode c-mode))".
Yes, that's it.
>> there should be more acceptable options for
>> catch-all or fall-through methods. Ie, we want to create a method that
>> fires regardless of the major mode.
>
> If you want to ignore the major mode, why do you want to use the
> major-mode specializer?
It's the equivalent of the "t" branch in a `cond' statement. You write
methods to handle specific major modes, and write another method to
handle the catch-all case of "all other modes".
>> These signatures don't work, but
>> should:
>>
>> (cl-defmethod example-method ((&context (major-mode fundamental-mode))))
>>
>
> Should that be
>
> (cl-defmethod example-method (&context (major-mode fundamental-mode)))
>
> The reason this doesn't work is because fundamental isn't actually the
> parent mode of text-mode or prog-mode, i.e., (get 'text-mode
> 'derived-mode-parent) => nil.
Right -- I still think either t or nil should do it.
This bug report was last modified 7 years and 211 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.