[Top][All Lists]

[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: npostavs
Subject: bug#25294: 26.0.50; Allow more catch-all values for cl-defmethod's &context plus major-mode specializer
Date: Thu, 29 Dec 2016 23:35:05 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Eric Abrahamsen <address@hidden> 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 ())

reply via email to

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