From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 07 11:56:06 2023 Received: (at submit) by debbugs.gnu.org; 7 Oct 2023 15:56:06 +0000 Received: from localhost ([127.0.0.1]:55709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp9ew-0002MF-8a for submit@debbugs.gnu.org; Sat, 07 Oct 2023 11:56:06 -0400 Received: from lists.gnu.org ([2001:470:142::17]:60082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp9eu-0002Lm-Cb for submit@debbugs.gnu.org; Sat, 07 Oct 2023 11:56:05 -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 ) id 1qp9eV-0007Np-1u for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 11:55:39 -0400 Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qp9eS-0000Ed-VP for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 11:55:38 -0400 Received: (qmail 34610 invoked by uid 3782); 7 Oct 2023 17:55:24 +0200 Received: from acm.muc.de (p4fe1586e.dip0.t-ipconnect.de [79.225.88.110]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 07 Oct 2023 17:55:23 +0200 Received: (qmail 13274 invoked by uid 1000); 7 Oct 2023 15:55:22 -0000 Date: Sat, 7 Oct 2023 15:55:22 +0000 To: bug-gnu-emacs@gnu.org Subject: Add raw printing for byte compiled functions to cl-prin1, etc. Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: acm@muc.de, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Hello, Emacs. When using cl-prin1 to print byte compiled functions, there is currently no way to get a raw, uncensored output. To get this, a user must use prin1 instead. This is awkward for use in backtraces, such as might be output by a failing build process. I propose amending this, adding the value `raw' to nil, `static', and `disassemble' as possibilities for the variable cl-print-compiled. The necessary patch is just 6 changed lines, although it appears more involved because of reindentation. Here it is: diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el index aa495b161d6..3a04a34a81d 100644 --- a/lisp/emacs-lisp/cl-print.el +++ b/lisp/emacs-lisp/cl-print.el @@ -165,6 +165,7 @@ 'help-byte-code (defvar cl-print-compiled nil "Control how to print byte-compiled functions. Acceptable values include: +- `raw' to print out the full contents of the function using `prin1'. - `static' to print the vector of constants. - `disassemble' to print the disassembly of the code. - nil to skip printing any details about the code.") @@ -187,42 +188,46 @@ cl-print-compiled-button (if args (prin1 args stream) (princ "()" stream))) - (pcase (help-split-fundoc (documentation object 'raw) object) - ;; Drop args which `help-function-arglist' already printed. - (`(,_usage . ,(and doc (guard (stringp doc)))) - (princ " " stream) - (prin1 doc stream))) - (let ((inter (interactive-form object))) - (when inter - (princ " " stream) - (cl-print-object - (if (eq 'byte-code (car-safe (cadr inter))) - `(interactive ,(make-byte-code nil (nth 1 (cadr inter)) - (nth 2 (cadr inter)) - (nth 3 (cadr inter)))) - inter) - stream))) - (if (eq cl-print-compiled 'disassemble) - (princ - (with-temp-buffer - (insert "\n") - (disassemble-1 object 0) - (buffer-string)) - stream) - (princ " " stream) - (let ((button-start (and cl-print-compiled-button - (bufferp stream) - (with-current-buffer stream (point))))) - (princ (format "#" (sxhash object)) stream) - (when (eq cl-print-compiled 'static) + (if (eq cl-print-compiled 'raw) + (progn + (princ " " stream) + (prin1 object stream)) + (pcase (help-split-fundoc (documentation object 'raw) object) + ;; Drop args which `help-function-arglist' already printed. + (`(,_usage . ,(and doc (guard (stringp doc)))) + (princ " " stream) + (prin1 doc stream))) + (let ((inter (interactive-form object))) + (when inter (princ " " stream) - (cl-print-object (aref object 2) stream)) - (when button-start - (with-current-buffer stream - (make-text-button button-start (point) - :type 'help-byte-code - 'byte-code-function object))))) - (princ ")" stream)) + (cl-print-object + (if (eq 'byte-code (car-safe (cadr inter))) + `(interactive ,(make-byte-code nil (nth 1 (cadr inter)) + (nth 2 (cadr inter)) + (nth 3 (cadr inter)))) + inter) + stream))) + (if (eq cl-print-compiled 'disassemble) + (princ + (with-temp-buffer + (insert "\n") + (disassemble-1 object 0) + (buffer-string)) + stream) + (princ " " stream) + (let ((button-start (and cl-print-compiled-button + (bufferp stream) + (with-current-buffer stream (point))))) + (princ (format "#" (sxhash object)) stream) + (when (eq cl-print-compiled 'static) + (princ " " stream) + (cl-print-object (aref object 2) stream)) + (when button-start + (with-current-buffer stream + (make-text-button button-start (point) + :type 'help-byte-code + 'byte-code-function object))))) + (princ ")" stream))) ;; This belongs in oclosure.el, of course, but some load-ordering issues make it ;; complicated. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 07 14:29:56 2023 Received: (at 66392) by debbugs.gnu.org; 7 Oct 2023 18:29:56 +0000 Received: from localhost ([127.0.0.1]:55898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qpC3o-0001en-AY for submit@debbugs.gnu.org; Sat, 07 Oct 2023 14:29:56 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:5925) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qpC3l-0001eN-M2 for 66392@debbugs.gnu.org; Sat, 07 Oct 2023 14:29:54 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 04742441406; Sat, 7 Oct 2023 14:29:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1696703362; bh=gywueya2ZDdONm5bTCi4MZPDcAEV0j7Jc8W2ob4h5FY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=aPtO8CtyNhgapBmONcpsooez8xdOTxOrwQLj3qjyBsMYXqH3BISnErXews5n7LxFr x/5co0rkSqthuwAAqY1MPPJRp5Rvk2agapNet9hn2ECLzx+4e3+8Fc3g+SJEsvqm1a mATDovfQxygEWv5nV5qtCC53CxwpZd/6947o81RgO8kkJ2Wv3b7O5R3GNeiLUW7TYc aT6qxzJ8ZGzCb51nSqu9ZdpAY7sxGZMdZNcrh8gUiQopoLoDk6ImUHtVMeP2cdMLro ZUmZYBWjYGyuX1ayrVSCidyxw/2wrCkpD6+PWHNRP59gELZAcQlCEBktDJOrTKcmt2 RJlPNhkWnKEgA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 835B5441400; Sat, 7 Oct 2023 14:29:22 -0400 (EDT) Received: from alfajor (unknown [45.72.225.62]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 560DD12041F; Sat, 7 Oct 2023 14:29:22 -0400 (EDT) From: Stefan Monnier To: Alan Mackenzie Subject: Re: Add raw printing for byte compiled functions to cl-prin1, etc. In-Reply-To: (Alan Mackenzie's message of "Sat, 7 Oct 2023 15:55:22 +0000") Message-ID: References: Date: Sat, 07 Oct 2023 14:29:16 -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.018 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: 66392 Cc: 66392@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I propose amending this, adding the value `raw' to nil, `static', and > `disassemble' as possibilities for the variable cl-print-compiled. > The necessary patch is just 6 changed lines, although it appears more > involved because of reindentation. No objection from me :-) Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 11 09:33:51 2023 Received: (at 66392-done) by debbugs.gnu.org; 11 Oct 2023 13:33:51 +0000 Received: from localhost ([127.0.0.1]:37794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqZLF-00064S-2R for submit@debbugs.gnu.org; Wed, 11 Oct 2023 09:33:51 -0400 Received: from mail.muc.de ([193.149.48.3]:24694) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqZLA-00062f-GF for 66392-done@debbugs.gnu.org; Wed, 11 Oct 2023 09:33:36 -0400 Received: (qmail 83209 invoked by uid 3782); 11 Oct 2023 15:33:03 +0200 Received: from acm.muc.de (pd953a848.dip0.t-ipconnect.de [217.83.168.72]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 11 Oct 2023 15:33:02 +0200 Received: (qmail 28639 invoked by uid 1000); 11 Oct 2023 13:33:01 -0000 Date: Wed, 11 Oct 2023 13:33:01 +0000 To: 66392-done@debbugs.gnu.org Subject: Re: bug#66392: Add raw printing for byte compiled functions to cl-prin1, etc. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 66392-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Emacs. The bug has been fixed (by making the enhancement). -- Alan Mackenzie (Nuremberg, Germany). From unknown Tue Aug 19 02:56:44 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 09 Nov 2023 12:24:13 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator