From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58602: 29.0.50; Please document (:documentation FORM) spec for closures Date: Mon, 17 Oct 2022 22:05:06 -0400 Message-ID: References: <87r0z69cxj.fsf@web.de> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40251"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 58602@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 18 04:06:37 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okc05-000AHk-D1 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Oct 2022 04:06:37 +0200 Original-Received: from localhost ([::1]:42432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okc04-0006AK-5W for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Oct 2022 22:06:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okbzW-0006AB-PD for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 22:06:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okbzV-0004vo-UN for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 22:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1okbzV-0004W6-L1 for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 22:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Oct 2022 02:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58602 X-GNU-PR-Package: emacs Original-Received: via spool by 58602-submit@debbugs.gnu.org id=B58602.166605871917311 (code B ref 58602); Tue, 18 Oct 2022 02:06:01 +0000 Original-Received: (at 58602) by debbugs.gnu.org; 18 Oct 2022 02:05:19 +0000 Original-Received: from localhost ([127.0.0.1]:50651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okbyo-0004V8-Uw for submit@debbugs.gnu.org; Mon, 17 Oct 2022 22:05:19 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:6319) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okbym-0004Up-7d for 58602@debbugs.gnu.org; Mon, 17 Oct 2022 22:05:17 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E210580976; Mon, 17 Oct 2022 22:05:09 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0060880325; Mon, 17 Oct 2022 22:05:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1666058708; bh=GxXj3L8UiBUahoIeN+WOQAEObWgVWPv+0VbUDUg4Ozk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=H05L76COoDCUEatPHU8TUshZgJaS1wB5Jv4b/aICkB23OpKTIrOjmLyQQzE4qSV+2 VyqZPexlCMcwj/FBzerYy4YE6Q0c6LG1UJthidnhzRjSIOArbRNcXXMH2d40VS+NaF kAVmMigVdYH0FT5pF2oj+D/LeRU+YAUuA7G9QqscVPFz/kVfvjlvnaoJA06IRxCjvW KN+5WZeJhFaPvUEkdiK+jlq2MY4zLU0Ddsa0uInx1KStG5dYJ4IpiQeB0uZrYCowOC hfMIrNiuphs/H0Y38CgUEjeqEcZhXs9ZkmT8pVoeKfI1AFXcoBXwKA4qGPmLlYYRa8 6jesqrfe9pIbA== Original-Received: from pastel (65-110-220-202.cpe.pppoe.ca [65.110.220.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 913E812020D; Mon, 17 Oct 2022 22:05:07 -0400 (EDT) In-Reply-To: <87r0z69cxj.fsf@web.de> (Michael Heerdegen's message of "Tue, 18 Oct 2022 02:46:00 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245772 Archived-At: Michael Heerdegen [2022-10-18 02:46:00] wrote: > I think we need to document this new feature described in etc/NEWS.25: > > | ** Lexical closures can use '(:documentation FORM)' to build their docstring. > | It should be placed right where the docstring would be, and FORM is then > | evaluated (and should return a string) when the closure is built. > > at least in the ELisp reference manual (dunno, maybe also in the > docstring of `lambda' and `defun'?). [ Our emails crossed: I just sent the following to emacs-devel, but it's probably better to discuss it here. ] Someone pointed out that I forgot to document the `:documentation` thingy for functions. I came up with the text below, but I find it too terse. I'm wondering whether maybe it should be expanded to a subsubsection maybe, where I could more easily put some examples. Tho, maybe there's a way to make it understandable without an example. I don't know. I need help. Stefan diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 8b858e0aa01..f85e0498851 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -533,6 +533,20 @@ Function Documentation compiler emit a warning message when it compiles Lisp programs which use the deprecated calling convention. +@cindex Computed documentation string +@kindex{:documentation} +Documentation strings are usually completely static, but occasionally +it can be necessary to generate them dynamically. In some cases this +can be done by writing a macro which will generate at compile time the +code of the function, including the desired documentation string. +But you can also generate the docstring at run-time when the function +is defined by writing @code{(:documentation @var{form})} instead of +the documentation string@footnote{This only works in code using +@code{lexical-binding}.}. Furthermore, you can also compute the +documentation string on the fly when it is requested by setting +the @code{function-documentation} property of the function's symbol to +a Lisp form that should evaluate to a string. + @node Function Names @section Naming a Function @cindex function definition