GNU bug report logs - #69935
[PATCH] (help-fns-function-description-header): Print functions' type

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Stefan Monnier <monnier@HIDDEN>; Keywords: patch; dated Fri, 22 Mar 2024 01:24:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 69935 <at> debbugs.gnu.org:


Received: (at 69935) by debbugs.gnu.org; 22 Mar 2024 21:15:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 22 17:15:32 2024
Received: from localhost ([127.0.0.1]:49735 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rnmEe-0001Hj-AU
	for submit <at> debbugs.gnu.org; Fri, 22 Mar 2024 17:15:32 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:2524)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rnmEc-0001HN-Nt
 for 69935 <at> debbugs.gnu.org; Fri, 22 Mar 2024 17:15:31 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 22469812F7;
 Fri, 22 Mar 2024 17:14:43 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1711142081;
 bh=Agm6YXYttfi9HKo1axN2iDk5f+pZqZbE5AIOXytsneo=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=Kw3v/ggPgzpxrLwWUSo8kvJQCensCs2E2JP9sVZTAI6l21CtcyyvcnNso+aghcQxC
 9JPkhdrM6BJ8QWiFErGzh1IGtz1g3cSX8bNO1CkKn/vSPPiizX1a24SBwsYHpXtHcb
 OWriSITt4PoiZ0dXk8UjZA23l7GtXdosELL1YpD5HskP58rQocUL9OsWV712cj30kV
 4sFFW9OlsLZU+RA69RXz8YQpvLS/W2jxlhYqCohi3wRhDImKCdhA5dKLvDjFeWGTgz
 RxMsUaOn1uMFVUA7sdp+aw8F0NdBDNreJivEPWOpH7fQ6nDSGatYhkNjMNLmeaXdF4
 zftSdHT0AMepQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id AFA14800D0;
 Fri, 22 Mar 2024 17:14:41 -0400 (EDT)
Received: from pastel (unknown [104.247.238.200])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 891F6120708;
 Fri, 22 Mar 2024 17:14:41 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#69935: [PATCH] (help-fns-function-description-header):
 Print functions' type
In-Reply-To: <86edc220e1.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 22 Mar
 2024 09:25:58 +0200")
Message-ID: <jwvle6a7zdy.fsf-monnier+emacs@HIDDEN>
References: <jwvedc39ine.fsf-monnier+@gnu.org> <86edc220e1.fsf@HIDDEN>
Date: Fri, 22 Mar 2024 17:14:40 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.215 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69935
Cc: 69935 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> No objections, but IMO this should be in NEWS,

Good point, just added, thanks.

> and the button and its purpose should be described in the user manual
> (where we document "C-h f").

Hmm.. not sure where/how to add it there.  The current text doesn't
discuss/mention the other buttons (like the button to jump to the
source) and auxiliary information, so I'm not sure what you
were expecting.  My proposal would be something like the text below.
Is that the kind of thing you were thinking about?

[ Side note: I already pushed my proposed patch (without doc changes,
  obviously) accidentally when I pushed another change.
  Sorry 'bout that.  ]


        Stefan


diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index 05457a3f34f..a6136ad6554 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -310,6 +310,12 @@ Name Help
 @kbd{C-h f} command if you don't really want to view the
 documentation.
 
+  The function's documentation displayed by @code{describe-function}
+includes more than just the documentation string and the signature of
+the function.  It also shows auxiliary information such as its type,
+the file where it was defined, whether it has been declared obsolete,
+etc...
+
 @vindex help-enable-symbol-autoload
   If you request help for an autoloaded function whose @code{autoload}
 form (@pxref{Autoload,,, elisp, The Emacs Lisp Reference Manual})





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69935; Package emacs. Full text available.

Message received at 69935 <at> debbugs.gnu.org:


Received: (at 69935) by debbugs.gnu.org; 22 Mar 2024 16:24:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 22 12:24:48 2024
Received: from localhost ([127.0.0.1]:34486 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rnhhI-0007th-65
	for submit <at> debbugs.gnu.org; Fri, 22 Mar 2024 12:24:48 -0400
Received: from eggs.gnu.org ([209.51.188.92]:59860)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acorallo@HIDDEN>) id 1rnhhF-0007tT-Oh
 for 69935 <at> debbugs.gnu.org; Fri, 22 Mar 2024 12:24:47 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <acorallo@HIDDEN>)
 id 1rngzu-00011B-93; Fri, 22 Mar 2024 11:39:58 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=CBqz1X/Kl2rG/muNTcEMAskAmTWoMCf9Lt/WtRyhSPk=; b=gvcEDMhLwrS0zuJM1YUW
 f9KjEvi9LNJKpwOzIs9JOEpFfEIhslsksBvvqn5bdDMPLnIAz5OOlsD8QrPgrd3ao6QLEy4PMt9xP
 Jc66lLz4GubWo83j6byjVfXKwV9i7otBPQ/yk0TlqIJ5WowUwZKI2w80OppYfz3HZ6nQ4q04/Pbu1
 uRK5kopqOR5MVTzGMCcKo7bO+amtw0rj977tsKp9Ay4Z2ECKvTruiksF8n0LPcHvojVs8t8ROTJnK
 qZclNga8SZ8wzXYBnBE/+kDl6CtiFLEwQokXc66Uml6P7tKXkdPUufVuN04hZ3xBGylIJoTVq035G
 HFoGMIZJ8M3TCg==;
Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <acorallo@HIDDEN>)
 id 1rngzt-0004Yx-AH; Fri, 22 Mar 2024 11:39:57 -0400
From: Andrea Corallo <acorallo@HIDDEN>
To: 69935 <at> debbugs.gnu.org
Subject: Re: bug#69935: [PATCH] (help-fns-function-description-header):
 Print functions' type
In-Reply-To: <jwvedc39ine.fsf-monnier+@gnu.org> (Stefan Monnier via's message
 of "Thu, 21 Mar 2024 21:22:39 -0400")
References: <jwvedc39ine.fsf-monnier+@gnu.org>
Date: Fri, 22 Mar 2024 11:39:57 -0400
Message-ID: <yp1frwis2b6.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69935
Cc: Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@HIDDEN> writes:

> Tags: patch
>
> The patch below changes the first line of `C-h f` from something like:
>
>     car is a built-in function in =E2=80=98C source code=E2=80=99.
>
> to
>
>     car is a primitive-function in =E2=80=98C source code=E2=80=99.
>
> i.e. print the actual type rather than an English description.
> The type is buttonized so users can click on it to see a description of
> the type (and its super/subtypes).
>
> Beside exposing those types (and their related information), another
> advantage is that it simplifies the code since we don't need to
> enumerate all the different kinds of functions we may have (well, we
> still do for those "function-like objects" which don't have a dedicated
> type such as macros, keymaps, aliases, keyboard macros, yadda yadda, but
> a single case covers all of special forms, primitive functions,
> byte-code functions, module functions, and native-compiled functions).
>
> Any comment/objection?

Hi Stefan,

I like it thanks!  I think we might want to highlight the
inferred/declared argument/ret types as well WDYT?

I might implement something along this line once your patch is.

Thanks

  Andrea




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69935; Package emacs. Full text available.

Message received at 69935 <at> debbugs.gnu.org:


Received: (at 69935) by debbugs.gnu.org; 22 Mar 2024 08:13:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 22 04:13:24 2024
Received: from localhost ([127.0.0.1]:58972 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rna1k-00076L-5u
	for submit <at> debbugs.gnu.org; Fri, 22 Mar 2024 04:13:24 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58454)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rna1i-00075v-6a
 for 69935 <at> debbugs.gnu.org; Fri, 22 Mar 2024 04:13:23 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rnZI8-0007xX-7P; Fri, 22 Mar 2024 03:26:16 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=vVMIx3uTUyfAHhwXK/QKJOy9GIwf0BNr/G1uwYwTAU4=; b=avAFnty/GbkwxdlETpYD
 ysAFf0s6xnHvEh7qffQgGWFI7/ILO+/m1cl1t70HFPkNXuaibvYs3PLhVmGLyzsg1w57iTqgfXq2Q
 k6CzspvPy+DTPeNbARRfodf0ecI5rb6GA9wlwPmL6iEF5fn04UyOjtSzg3CM5gku726xh3t5VZftK
 sI+YEHp7h8qwy0YAPKc/oB70XuYmzQXT9PxDsyL/curwbALKgatkMaVvkD3agkmBDNSUtLYRDBvI8
 dOfrQlI8h/QL/95GYvH1fH5TOEb14ViPDT4O/BL8pq02dCQYGLD+uJsTVQM7uD2QVL+y00on74vek
 gUs7igAZ3O5qJA==;
Date: Fri, 22 Mar 2024 09:25:58 +0200
Message-Id: <86edc220e1.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvedc39ine.fsf-monnier+@gnu.org> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#69935: [PATCH] (help-fns-function-description-header): Print
 functions' type
References: <jwvedc39ine.fsf-monnier+@gnu.org>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69935
Cc: 69935 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Thu, 21 Mar 2024 21:22:39 -0400
> From:  Stefan Monnier via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> The patch below changes the first line of `C-h f` from something like:
> 
>     car is a built-in function in ‘C source code’.
> 
> to
> 
>     car is a primitive-function in ‘C source code’.
> 
> i.e. print the actual type rather than an English description.
> The type is buttonized so users can click on it to see a description of
> the type (and its super/subtypes).
> 
> Beside exposing those types (and their related information), another
> advantage is that it simplifies the code since we don't need to
> enumerate all the different kinds of functions we may have (well, we
> still do for those "function-like objects" which don't have a dedicated
> type such as macros, keymaps, aliases, keyboard macros, yadda yadda, but
> a single case covers all of special forms, primitive functions,
> byte-code functions, module functions, and native-compiled functions).
> 
> Any comment/objection?

No objections, but IMO this should be in NEWS, and the button and
its purpose should be described in the user manual (where we document
"C-h f").

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69935; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Mar 2024 01:23:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 21 21:23:34 2024
Received: from localhost ([127.0.0.1]:54070 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rnTd7-0001yA-J5
	for submit <at> debbugs.gnu.org; Thu, 21 Mar 2024 21:23:34 -0400
Received: from lists.gnu.org ([209.51.188.17]:35954)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rnTd4-0001xp-Ff
 for submit <at> debbugs.gnu.org; Thu, 21 Mar 2024 21:23:31 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <monnier@HIDDEN>)
 id 1rnTcP-0001N0-Q9
 for bug-gnu-emacs@HIDDEN; Thu, 21 Mar 2024 21:22:49 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <monnier@HIDDEN>)
 id 1rnTcN-0007hO-Fw
 for bug-gnu-emacs@HIDDEN; Thu, 21 Mar 2024 21:22:49 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E899980577;
 Thu, 21 Mar 2024 21:22:44 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1711070560;
 bh=YWc6DY91MPgSTcDauewa3rA3WMdNQpNiUq18gqQAIcA=;
 h=From:To:Subject:Date:From;
 b=pZxK0Cd9oS2LWmQasQPXTJHwLCdmf1svfKb6FL0lmPpd8lJsKPhsnqzhmMbcIv8JB
 NcwA5AXPYeMUQ4EADRtgjUAV+zpQOT40qRKmN0EEykNmrKDTph4cyGJ091jVKHMJiD
 2bC7OyI7/4P7SysNfW2pGhdb2QnhfT77fGcIZwPxKprzYVUC8v/eBnEkSFoHC5SIZa
 G1P2iLe1Y6l11969ZObdO5nFZajwZsxv4gizin/h276Zc3Pt3MvfV4WNGVHEgYDPrK
 QD8eNFI1tPmX6N2Ymgga2jIIhi0FwpTGMgSLfv8w/GTRQ2hpbHfgWOEKPW20mgHIVr
 BqGdSXUY5BRcA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A7F8680A95;
 Thu, 21 Mar 2024 21:22:40 -0400 (EDT)
Received: from pastel (unknown [104.247.238.200])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8ADC4120828;
 Thu, 21 Mar 2024 21:22:40 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] (help-fns-function-description-header): Print functions' type
Message-ID: <jwvedc39ine.fsf-monnier+@gnu.org>
Date: Thu, 21 Mar 2024 21:22:39 -0400
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.225 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
Received-SPF: pass client-ip=132.204.25.50;
 envelope-from=monnier@HIDDEN; helo=mailscanner.iro.umontreal.ca
X-Spam_score_int: -42
X-Spam_score: -4.3
X-Spam_bar: ----
X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Tags: patch

The patch below changes the first line of `C-h f` from something like:

    car is a built-in function in =E2=80=98C source code=E2=80=99.

to

    car is a primitive-function in =E2=80=98C source code=E2=80=99.

i.e. print the actual type rather than an English description.
The type is buttonized so users can click on it to see a description of
the type (and its super/subtypes).

Beside exposing those types (and their related information), another
advantage is that it simplifies the code since we don't need to
enumerate all the different kinds of functions we may have (well, we
still do for those "function-like objects" which don't have a dedicated
type such as macros, keymaps, aliases, keyboard macros, yadda yadda, but
a single case covers all of special forms, primitive functions,
byte-code functions, module functions, and native-compiled functions).

Any comment/objection?


        Stefan

 In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.16.0) of 2024-02-23 built on pastel
Repository revision: 831e094a09f70a15e4b4b83c5158dbeb8d9daede
Repository branch: work
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure -C --enable-checking --enable-check-lisp-object-type --with-mod=
ules --with-cairo --with-tiff=3Difavailable
 'CFLAGS=3D-Wall -g3 -Og -Wno-pointer-sign' --without-native-compilation
 PKG_CONFIG_PATH=3D/home/monnier/lib/pkgconfig'


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-help-fns-function-description-header-Print-functions.patch

From 8169ad959bfca252fa4ef824f7ee10005f922431 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@HIDDEN>
Date: Thu, 21 Mar 2024 21:08:58 -0400
Subject: [PATCH] (help-fns-function-description-header): Print functions' type

Instead of choosing English words to describe the kind of function,
use the actual type of the function object (from `cl-type-of`)
directly, and make it a button to display info about that type.

* lisp/help-fns.el (help-fns-function-description-header): Use the
function's type name in the description instead of "prose".
Use `insert` instead of `princ`, so as to preserve the text-properties
of the button.

* lisp/emacs-lisp/cl-extra.el (cl-help-type): Move to `help-mode.el`
and rename to `help-type`.
(cl--describe-class): Adjust accordingly.

* lisp/help-mode.el (help-type): New type, moved and renamed from
`cl-extra.el`.
---
 lisp/emacs-lisp/cl-extra.el | 11 +++--------
 lisp/help-fns.el            | 31 ++++++++++++++-----------------
 lisp/help-mode.el           |  5 +++++
 3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index d43c21d3eb9..437dea2d6a9 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -720,11 +720,6 @@ cl--typedef-regexp
   (add-to-list 'find-function-regexp-alist
                '(define-type . cl--typedef-regexp)))
 
-(define-button-type 'cl-help-type
-  :supertype 'help-function-def
-  'help-function #'cl-describe-type
-  'help-echo (purecopy "mouse-2, RET: describe this type"))
-
 (define-button-type 'cl-type-definition
   :supertype 'help-function-def
   'help-echo (purecopy "mouse-2, RET: find type definition"))
@@ -777,7 +772,7 @@ cl--describe-class
     (insert (symbol-name type)
             (substitute-command-keys " is a type (of kind `"))
     (help-insert-xref-button (symbol-name metatype)
-                             'cl-help-type metatype)
+                             'help-type metatype)
     (insert (substitute-command-keys "')"))
     (when location
       (insert (substitute-command-keys " in `"))
@@ -796,7 +791,7 @@ cl--describe-class
           (setq cur (cl--class-name cur))
           (insert (substitute-quotes "`"))
           (help-insert-xref-button (symbol-name cur)
-                                   'cl-help-type cur)
+                                   'help-type cur)
           (insert (substitute-command-keys (if pl "', " "'"))))
         (insert ".\n")))
 
@@ -808,7 +803,7 @@ cl--describe-class
         (while (setq cur (pop ch))
           (insert (substitute-quotes "`"))
           (help-insert-xref-button (symbol-name cur)
-                                   'cl-help-type cur)
+                                   'help-type cur)
           (insert (substitute-command-keys (if ch "', " "'"))))
         (insert ".\n")))
 
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 422f6e9dddf..79a39c3d639 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1061,10 +1061,10 @@ help-fns-function-description-header
                         (concat
                          "an autoloaded " (if (commandp def)
                                               "interactive "))
-                      (if (commandp def) "an interactive " "a "))))
-
-    ;; Print what kind of function-like object FUNCTION is.
-    (princ (cond ((or (stringp def) (vectorp def))
+                      (if (commandp def) "an interactive " "a ")))
+               ;; Print what kind of function-like object FUNCTION is.
+               (description
+		(cond ((or (stringp def) (vectorp def))
 		  "a keyboard macro")
 		 ((and (symbolp function)
                        (get function 'reader-construct))
@@ -1073,12 +1073,6 @@ help-fns-function-description-header
 		 ;; aliases before functions.
 		 (aliased
 		  (format-message "an alias for `%s'" real-def))
-                 ((subr-native-elisp-p def)
-                  (concat beg "native-compiled Lisp function"))
-		 ((subrp def)
-		  (concat beg (if (eq 'unevalled (cdr (subr-arity def)))
-		                  "special form"
-                                "built-in function")))
 		 ((autoloadp def)
 		  (format "an autoloaded %s"
                           (cond
@@ -1092,12 +1086,13 @@ help-fns-function-description-header
 		      ;; need to check macros before functions.
 		      (macrop function))
 		  (concat beg "Lisp macro"))
-		 ((byte-code-function-p def)
-		  (concat beg "byte-compiled Lisp function"))
-                 ((module-function-p def)
-                  (concat beg "module function"))
-		 ((memq (car-safe def) '(lambda closure))
-		  (concat beg "Lisp function"))
+		 ((atom def)
+		  (let ((type (or (oclosure-type def) (cl-type-of def))))
+		    (concat beg (format "%s"
+		                        (make-text-button
+		                         (symbol-name type) nil
+		                         'type 'help-type
+		                         'help-args (list type))))))
 		 ((keymapp def)
 		  (let ((is-full nil)
 			(elts (cdr-safe def)))
@@ -1107,7 +1102,9 @@ help-fns-function-description-header
 				elts nil))
 		      (setq elts (cdr-safe elts)))
 		    (concat beg (if is-full "keymap" "sparse keymap"))))
-		 (t "")))
+		 (t ""))))
+    (with-current-buffer standard-output
+      (insert description))
 
     (if (and aliased (not (fboundp real-def)))
 	(princ ",\nwhich is not defined.")
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index dd78342ace7..48433d899ab 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -177,6 +177,11 @@ 'help-variable
   'help-function 'describe-variable
   'help-echo (purecopy "mouse-2, RET: describe this variable"))
 
+(define-button-type 'help-type
+  :supertype 'help-xref
+  'help-function #'cl-describe-type
+  'help-echo (purecopy "mouse-2, RET: describe this type"))
+
 (define-button-type 'help-face
   :supertype 'help-xref
   'help-function 'describe-face
-- 
2.43.0


--=-=-=--





Acknowledgement sent to Stefan Monnier <monnier@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#69935; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 22 Mar 2024 21:30:03 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.