From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs 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 21:42:43 -0800 Message-ID: <87d13kqz70.fsf@ericabrahamsen.net> References: <874m1mo8ez.fsf@ericabrahamsen.net> <87efo0encf.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1513057389 1258 195.159.176.226 (12 Dec 2017 05:43:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 12 Dec 2017 05:43:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 25294@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 12 06:43:05 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOdLM-0008Uk-N3 for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Dec 2017 06:43:05 +0100 Original-Received: from localhost ([::1]:56776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOdLU-0008VQ-0h for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Dec 2017 00:43:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOdLN-0008V8-N2 for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2017 00:43:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOdLK-0006XY-JC for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2017 00:43:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eOdLK-0006Wq-Cq for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2017 00:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eOdLK-0007IX-6A for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2017 00:43:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Dec 2017 05:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25294 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 25294-submit@debbugs.gnu.org id=B25294.151305736928031 (code B ref 25294); Tue, 12 Dec 2017 05:43:02 +0000 Original-Received: (at 25294) by debbugs.gnu.org; 12 Dec 2017 05:42:49 +0000 Original-Received: from localhost ([127.0.0.1]:57600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOdL7-0007I0-9b for submit@debbugs.gnu.org; Tue, 12 Dec 2017 00:42:49 -0500 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:59905) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOdL4-0007Hr-Pl for 25294@debbugs.gnu.org; Tue, 12 Dec 2017 00:42:47 -0500 Original-Received: from localhost (71-212-75-109.tukw.qwest.net [71.212.75.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id B2CC9C05DA; Tue, 12 Dec 2017 05:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1513057365; bh=cizLKv/r8nG1+irQ9gENfzMj95sDPIJylv4DK0MgW5w=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=I2Qaar+MwBkpq50uRDbw14iD6TM4NUpv11XkIG/JmD+msKXBtB3WScYlRJB7/Yb1/ vEuYLVdxSQ7oSKCXum5D/Ez6J/+lt6urOSla5w1l3OktyFZDDtmBgrhZ5jG6D98iI8 k9fhn8lLCH77O7cMretpnga8VZ3/Yb+CQRHlZa8g= In-Reply-To: <87efo0encf.fsf@users.sourceforge.net> (Noam Postavsky's message of "Mon, 11 Dec 2017 20:39:28 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140969 Archived-At: --=-=-= Content-Type: text/plain Noam Postavsky writes: > [forwarding to list] Whoops, sorry. [...] >> A year later, older and wiser, I agree that maybe all that's needed is >> more documentation. I just noticed that, at some point in the interim, >> the documentation for generic functions has been greatly expanded, which >> is nice! >> >> I'd like to add the following to the docs: >> >> 1. The &context thing has to come after the required arguments, but >> before any &optional or &rest things. >> 2. You can have an arbitrary number of forms following &context. >> 3. The &context arguments don't have to match the declared arguments in >> `cl-defgeneric'. >> 4. Ergo they can be left off altogether without needing to be >> specifically declared as nil or what have you, ie, my original bug >> report isn't really a bug. >> >> If this looks okay, I'll have at the docs. > Sounds good to me. Here's my diff. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=context-spec-docs.diff diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 466a12f7a4..6b98a3d639 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -1252,15 +1252,21 @@ Generic Functions Extensions for GNU Emacs Lisp}), or of one of its parent classes. @end table -Alternatively, the argument specializer can be of the form -@code{&context (@var{expr} @var{spec})}, in which case the value of -@var{expr} must be compatible with the specializer provided by -@var{spec}; @var{spec} can be any of the forms described above. In -other words, this form of specializer uses the value of @var{expr} -instead of arguments for the decision whether the method is -applicable. For example, @code{&context (overwrite-mode (eql t))} -will make the method compatible only when @code{overwrite-mode} is -turned on. +Generic functions provide a new argument-list keyword, +@code{&context}, which can be used to introduce extra specializers +that test the general environment in which the method is run. This +keyword should appear after the list of required arguments, but before +any @code{&rest} or @code{&optional} keywords. The @code{&context} +specializers look much like regular argument +specializers---(@var{expr} @var{spec})---except that @var{expr} is an +expression to be evaluated in the current context, and the @var{spec} +is a value to compare against. For example, @code{&context +(overwrite-mode (eql t))} will make the method applicable only when +@code{overwrite-mode} is turned on. The @code{&context} keyword can +be followed by any number of context specializers. Because the +context specializers are not part of the generic function's required +argument signature, they may be omitted in methods that don't require +them. The type specializer, @code{(@var{arg} @var{type})}, can specify one of the @dfn{system types} in the following list. When a parent type --=-=-=--