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
Message #8 received at 25294 <at> debbugs.gnu.org (full text, mbox):
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
> When defining a method using cl-defmethod with the &context and
> major-mode specializer,
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))".
> 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?
> 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.
> (cl-defmethod example-method ((&context (major-mode nil)))
>
> (cl-defmethod example-method ((&context (major-mode t))))
>
> Right now the only thing that works is:
>
> (cl-defmethod example-method ())
This bug report was last modified 7 years and 210 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.