unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: "fall-through" generic function args plus &context
Date: Mon, 26 Dec 2016 12:34:46 -0800	[thread overview]
Message-ID: <87r34u8m55.fsf@ericabrahamsen.net> (raw)

I have a few defmethods that use the &context construct to dispatch on
the value of major mode:

(cl-defmethod my-make-buffer-name (&context (major-mode gnus-summary-mode))
  ;; etc...
  )

I need a catch-all method, for default behavior when we're in other
modes that aren't targeted by an existing method.

I've tried things like:

(&context _major-mode)
(&context (major-mode t))
(&context (major-mode nil))
(&context (major-mode (eql _nuthin))

And a few other things. Everything raises cl-no-applicable-method.

What's the correct way to do this? Or do I need to override
`cl-no-applicable-method' and catch the error?

Thanks,
Eric




             reply	other threads:[~2016-12-26 20:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-26 20:34 Eric Abrahamsen [this message]
2016-12-26 22:48 ` "fall-through" generic function args plus &context Eric Abrahamsen
2016-12-27  3:36   ` Stefan Monnier
2016-12-27 17:23     ` Eric Abrahamsen
2016-12-27 21:30       ` Stefan Monnier
2016-12-29  2:30         ` Eric Abrahamsen
2016-12-29 14:42           ` Stefan Monnier
2016-12-29 19:04             ` Eric Abrahamsen
2016-12-30 14:26               ` Stefan Monnier
2016-12-27  1:27 ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87r34u8m55.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).