From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Integrate my package into Emacs Date: Mon, 25 Apr 2022 12:40:04 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19774"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Mariano Montone Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 25 18:41:25 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nj1m9-0004x2-D1 for ged-emacs-devel@m.gmane-mx.org; Mon, 25 Apr 2022 18:41:25 +0200 Original-Received: from localhost ([::1]:58982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nj1m8-0004VY-AT for ged-emacs-devel@m.gmane-mx.org; Mon, 25 Apr 2022 12:41:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nj1kz-0003bp-W8 for emacs-devel@gnu.org; Mon, 25 Apr 2022 12:40:18 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nj1kv-0002J2-E2 for emacs-devel@gnu.org; Mon, 25 Apr 2022 12:40:12 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 78CBA80675; Mon, 25 Apr 2022 12:40:07 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 62A5E805B9; Mon, 25 Apr 2022 12:40:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1650904805; bh=tHlXVpHZk5SI1hHiwXwA9wXIEy0egpiOvn53TPjadnY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=beYW7jUcgRTmn93GmP18Nd3brLCeObbs45ORor/zq57JfydCpDXe3x1m1Ygmjyq6y ZMKnbIHgikLBmm6MCG0q0iSlSai6/mx3rgbDkC2kPTl3eNL5+NlWPh7GgeB1AJnJ4v 0TmU0VmOSRIh0SkCZ6Bo3jn5WOebFA5DEYtpdLtO2HXNpFrPsckGMH6R5MDR1eM55s sZxeknkpl7QqeawDEbHp0kVvs3+2KT0RgO28XiAwlQfL6rq8PH4WAF6HGGYJkQBcIY ecO2E7bKRr1jpVF9C6wmj6uaqBHhpzTqghU4kmRNs6BLh5FVSpAaMkgOIGSbCTo4Ws PgjRi6QMYpYXA== Original-Received: from alfajor (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3D22E1203E4; Mon, 25 Apr 2022 12:40:05 -0400 (EDT) In-Reply-To: (Mariano Montone's message of "Fri, 22 Apr 2022 12:36:16 -0300") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:288864 Archived-At: --=-=-= Content-Type: text/plain Mariano Montone [2022-04-22 12:36:16] wrote: > I've implemented an inspector tool for elisp, and I think it could be nice > to integrate into Emacs distro. > > https://github.com/mmontone/emacs-inspector > > What do you think? As a first step, I'd be happy to add it to GNU ELPA. > What are the steps I'd need to follow for that? The main thing is to sign the copyright paperwork, without which your code can't be integrated in Emacs (nor in GNU ELPA). To do that, please fill the form below and email it to the FSF as instructed so they can send you the relevant paperwork to sign. I also attached a patch resulting from my quick reading of your code. Meant as much for reading as for applying (e.g. includes some FIXMEs). Stefan Please email the following information to assign@gnu.org, and we will send you the assignment form for your past and future changes. Please use your full legal name (in ASCII characters) as the subject line of the message. ---------------------------------------------------------------------- REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES [What is the name of the program or package you're contributing to?] Emacs [Did you copy any files or text written by someone else in these changes? Even if that material is free software, we need to know about it.] [Do you have an employer who might have a basis to claim to own your changes? Do you attend a school which might make such a claim?] [For the copyright registration, what country are you a citizen of?] [What year were you born?] [Please write your email address here.] [Please write your postal address here.] [Which files have you changed so far, and which new files have you written so far?] --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=inspector.diff diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..9416f1e9c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/inspector-autoloads.el +/inspector-pkg.el +*.elc diff --git a/inspector.el b/inspector.el index 9c36611556..02d980479b 100644 --- a/inspector.el +++ b/inspector.el @@ -159,18 +159,20 @@ (defun inspector--insert-inspect-button (object &optional label) "Insert button for inspecting OBJECT. -If LABEL has a value, then it is used as button label. Otherwise, button label is the printed representation of OBJECT." +If LABEL has a value, then it is used as button label. +Otherwise, button label is the printed representation of OBJECT." (insert-button (or (and label (inspector--princ-to-string label)) (inspector--print-truncated object)) - 'action (lambda (btn) - (ignore btn) + 'action (lambda (_btn) (inspector-inspect object t)) 'follow-link t)) (defun inspector--do-with-slicer (slicer function) "Use SLICER and call FUNCTION on the resulting slice. SLICE should be a function that returns a slice of some data. -FUNCTION is passed the resulting slice and a continuation function that when called continues the consumption of slices of data, until there are no more slices (the returned slice is NIL)." +FUNCTION is passed the resulting slice and a continuation function that when +called continues the consumption of slices of data, until there are no more +slices (the returned slice is nil)." (let ((slice (funcall slicer))) (when slice (funcall function slice @@ -178,7 +180,8 @@ FUNCTION is passed the resulting slice and a continuation function that when cal (defun inspector--do-with-slicer-and-more-button (slicer function) "Apply the SLICER function and apply FUNCTION to the resulting slice. -When FUNCTION returns not NIL, adds a [More] button that inserts the next slice in buffer." +When FUNCTION returns non-nil, adds a [More] button that inserts the next +slice in buffer." (inspector--do-with-slicer slicer (lambda (slice cont) @@ -186,8 +189,7 @@ When FUNCTION returns not NIL, adds a [More] button that inserts the next slice (when more-p (insert-button "[more]" 'action (let ((pos (point))) - (lambda (btn) - (ignore btn) + (lambda (_btn) (setq buffer-read-only nil) (goto-char pos) (delete-char (length "[More]")) @@ -219,15 +221,13 @@ When FUNCTION returns not NIL, adds a [More] button that inserts the next slice (eieio-class-name subclass) (eieio-class-name subclass)) (insert " "))) -(cl-defmethod inspect-object ((object (eql t))) +(cl-defmethod inspect-object ((_object (eql t))) "Render inspector buffer for boolean T." - (ignore object) (inspector--insert-title "boolean") (insert "value: t")) -(cl-defmethod inspect-object ((object (eql nil))) - "Render inspector buffer for NIL object." - (ignore object) +(cl-defmethod inspect-object ((_object (eql nil))) + "Render inspector buffer for nil object." (inspector--insert-title "nil") (insert "value: nil")) @@ -325,8 +325,7 @@ When FUNCTION returns not NIL, adds a [More] button that inserts the next slice (when (< i (length cons)) (cl-subseq cons i (min (cl-incf i inspector-slice-size) (length cons))))) - (lambda (slice cont) - (ignore cont) + (lambda (slice _cont) (dolist (cons slice) (insert "(") (inspector--insert-inspect-button (car cons)) @@ -348,8 +347,7 @@ When FUNCTION returns not NIL, adds a [More] button that inserts the next slice (when (< i (length cons)) (cl-subseq cons i (min (cl-incf i inspector-slice-size) (length cons))))) - (lambda (slice cont) - (ignore cont) + (lambda (slice _cont) (dolist (elem slice) (insert (format "%d: " j)) (cl-incf j) @@ -384,8 +382,7 @@ When FUNCTION returns not NIL, adds a [More] button that inserts the next slice (when (< i length) (cons i (1- (min (cl-incf i inspector-slice-size) length))))) - (lambda (slice cont) - (ignore cont) + (lambda (slice _cont) (cl-loop for k from (car slice) to (cdr slice) do (insert (format "%d: " k)) @@ -489,8 +486,7 @@ When FUNCTION returns not NIL, adds a [More] button that inserts the next slice (when (< i (length keys)) (cl-subseq keys i (min (cl-incf i inspector-slice-size) (length keys))))) - (lambda (slice cont) - (ignore cont) + (lambda (slice _cont) (dolist (key slice) (inspector--insert-inspect-button key) (insert ": ") @@ -522,9 +518,10 @@ When FUNCTION returns not NIL, adds a [More] button that inserts the next slice "Evaluate and inspect EXP expression." (interactive (list (read--expression "Eval and inspect: "))) - (inspector-inspect (eval exp))) + (inspector-inspect (eval exp t))) (defun inspector--basic-inspect (object) + (defvar *) (let ((buffer (inspector-make-inspector-buffer))) (with-current-buffer buffer (setq inspector-inspected-object object) @@ -601,15 +598,15 @@ When PRESERVE-HISTORY is T, inspector history is not cleared." ;;--------- Inspector mode --------------------------------- ;; Press letter 'i' in debugger backtrace to inspect locals. -(define-key debugger-mode-map (kbd "i") 'debugger-inspect-frame-and-locals) +(define-key debugger-mode-map (kbd "i") #'debugger-inspect-frame-and-locals) (defvar inspector-mode-map (let ((map (make-keymap))) - (define-key map "q" 'inspector-quit) - (define-key map "l" 'inspector-pop) - (define-key map "e" 'eval-expression) - (define-key map "n" 'forward-button) - (define-key map "p" 'backward-button) + (define-key map "q" #'inspector-quit) + (define-key map "l" #'inspector-pop) + (define-key map "e" #'eval-expression) + (define-key map "n" #'forward-button) + (define-key map "p" #'backward-button) map)) (easy-menu-define diff --git a/test.el b/test.el index 1b48b7b54d..0d0aa309c9 100644 --- a/test.el +++ b/test.el @@ -1,6 +1,11 @@ -;; Test inspector on all data types +;; Test inspector on all data types -*- lexical-binding: t; -*- ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Programming-Types.html +;; FIXME: Add copyright&license blurbs. +;; FIXME: Loading an ELisp file should not have any "visible" side effect. +;; The best may to fix this here is likely to use `ert-deftest'. +;; FIXME: Change the file's name to avoid clashes with other packages. + (require 'inspector) (inspector-inspect 22) @@ -74,5 +79,5 @@ (inspector-inspect (cl-loop for i from 1 to 101 collect (cons i (1+ i)))) (inspector-inspect (cl-loop for i from 1 to 101 collect (gensym) collect i)) -(inspector-inspect (apply 'vector (cl-loop for i from 1 to 1000 collect i))) +(inspector-inspect (apply #'vector (cl-loop for i from 1 to 1000 collect i))) --=-=-=--