all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: npostavs@users.sourceforge.net
Cc: 25294@debbugs.gnu.org
Subject: bug#25294: 26.0.50; Allow more catch-all values for cl-defmethod's &context plus major-mode specializer
Date: Mon, 11 Dec 2017 15:57:15 -0800	[thread overview]
Message-ID: <87374gstr8.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <877f6i826e.fsf@users.sourceforge.net> (npostavs's message of "Thu, 29 Dec 2016 23:35:05 -0500")

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.





  reply	other threads:[~2017-12-11 23:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29 19:13 bug#25294: 26.0.50; Allow more catch-all values for cl-defmethod's &context plus major-mode specializer Eric Abrahamsen
2016-12-30  4:35 ` npostavs
2017-12-11 23:57   ` Eric Abrahamsen [this message]
2017-12-12  0:08     ` Noam Postavsky
2017-12-12  1:39 ` Noam Postavsky
2017-12-12  1:43   ` Noam Postavsky
2017-12-12  5:42   ` Eric Abrahamsen
2017-12-12 23:58     ` Noam Postavsky
2017-12-14  0:06       ` Eric Abrahamsen
2017-12-14 21:01       ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87374gstr8.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=25294@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.