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: New Package: sticky-shell Date: Tue, 13 Dec 2022 09:22:16 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17530"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Andrew De Angelis Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 13 15:24:36 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 1p56Cy-0004He-37 for ged-emacs-devel@m.gmane-mx.org; Tue, 13 Dec 2022 15:24:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p56BL-00020a-B6; Tue, 13 Dec 2022 09:22:57 -0500 Original-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 1p56Ar-0001p2-FY for emacs-devel@gnu.org; Tue, 13 Dec 2022 09:22:33 -0500 Original-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 ) id 1p56Ao-0003Hg-Sl for emacs-devel@gnu.org; Tue, 13 Dec 2022 09:22:25 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E4E0A44223A; Tue, 13 Dec 2022 09:22:19 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 267324407B0; Tue, 13 Dec 2022 09:22:18 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1670941338; bh=2Tm9qFKbZ5ulSGZ/lP69oA8nGZHcQDbQXn46bP41RsA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nfPLiYq39q/SF+ztZbbPp2159x+mh1T7j4e2pe9w0qELv5iDX+A3tmkDlocTyJ5wk EXlF8OlIHf40ayIrvkbz+PMiI/EMzwa1XQuvTg0qzmG3OYscnuAmL/OMdll4HBHidt l4rLaD5mzKvkWhPEi8mM2oWUsI9Z+veJIlM1Kec6eqylo0SjB37p04gjthmN5OFDIC pbZCwIWC28Ea7QpLu0lYu+BUHMkTjTLZLeQ+vh/ie7OjgjuEIhfehYFYlwDmZ9v09K t8tpKh9NS1btvt7qvqI+PXc3ae6l6kQBjs68gLxdFBIoviy3RWoEuYuEMDEpsbu0S9 zPXurfsj/UtXg== Original-Received: from pastel (unknown [45.72.193.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F34B7120205; Tue, 13 Dec 2022 09:22:17 -0500 (EST) In-Reply-To: (Andrew De Angelis's message of "Mon, 12 Dec 2022 23:07:13 -0500") 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 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301315 Archived-At: >> Any chance we could simply add it to `shell.el`? > I wouldn't mind adding it to `shell.el`. Let me know what the process would > be in that case. Step 1 (same as for GNU ELPA): get the copyright paperwork in order. I don't see your name in the FSF's copyright assigners list, so either it's still in process or you haven't started yet. Let me know if you need help with that. Step 2: Turn your file into a patch to `shell.el`. [ Feel free to also make changes in `shell.el` and/or `eshell.el` to make the result cleaner. ] > @@ -129,23 +134,25 @@ macro-expands to: > (upcase > (funcall sticky-shell-get-prompt)) > \\='face \\='minibuffer-prompt)" > + ;; The case distinction appears unnecessary (thread-first (foo)) is > + ;; the same as (foo). > (if sticky-shell-prompt-modifiers > `(thread-first > (funcall sticky-shell-get-prompt) > ,@sticky-shell-prompt-modifiers) > + ;; Perhaps it would be better/cleaner if > + ;; `sticky-shell-prompt-modifiers' were a list of function that > + ;; all get applied on the result of (funcall > + ;; sticky-shell-get-prompt) in order? > (funcall sticky-shell-get-prompt))) > Not sure what you mean by the first comment. > Regarding the second comment: this is essentially what thread-first does, > with the added advantage that `sticky-shell-prompt-modifiers' can consist > not only of functions, but also of forms with multiple arguments, and whose > first argument will be the result of (funcall sticky-shell-get-prompt) at > runtime. For example, if users wanted to `propertize' the header with > particular properties, they wouldn't be able to do it if > `sticky-shell-prompt-modifiers' was simply a list of functions operating on > a single argument, because `propertize' requires multiple arguments. The > solution would have to be to create a new function: > (defun propertize-my-way (string) > (propertize string 'face 'minibuffer)) > And add propertize-my-way to the list of prompt modifiers. > Using thread-first saves users time by allowing them to simply add > '(propertize 'face 'minibuffer) to `sticky-shell-prompt-modifiers'. I can see the upside, yes, but the downside is that the format of `sticky-shell-prompt-modifiers` is "new" in the sense that it's different from existing customization variables used for similar purposes (which are either `-function` (modified with `add-function`) or `-functions` (modified with `add-hook`)). Another downside of that code is that `sticky-shell-modified-prompt` is a macro that's expanded every time we refresh the header line, which can be very frequent in some cases, thus generating excess garbage. [ Oh, BTW, I suspect your code needs a (require 'subr-x) to be sure `thread-first` is actually available. ] Stefan