From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#54227: 29.0.50; [PATCH] Inconsistencies with Eshell variable interpolation Date: Thu, 03 Mar 2022 20:43:14 +0200 Message-ID: <83r17ij2rh.fsf@gnu.org> References: <831qzjj7dd.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9679"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 54227@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 03 19:44:43 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 1nPqRO-0002Pa-Gg for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Mar 2022 19:44:42 +0100 Original-Received: from localhost ([::1]:44228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqRN-0003D3-M8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Mar 2022 13:44:41 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqQl-0003AM-6D for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2022 13:44:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqQk-0000q0-Kg for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2022 13:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nPqQk-0006lT-DQ for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2022 13:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Mar 2022 18:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54227 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 54227-submit@debbugs.gnu.org id=B54227.164633300825956 (code B ref 54227); Thu, 03 Mar 2022 18:44:02 +0000 Original-Received: (at 54227) by debbugs.gnu.org; 3 Mar 2022 18:43:28 +0000 Original-Received: from localhost ([127.0.0.1]:43761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nPqQC-0006kZ-3j for submit@debbugs.gnu.org; Thu, 03 Mar 2022 13:43:28 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nPqQB-0006kN-75 for 54227@debbugs.gnu.org; Thu, 03 Mar 2022 13:43:27 -0500 Original-Received: from [2001:470:142:3::e] (port=55906 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqQ3-0000kf-72; Thu, 03 Mar 2022 13:43:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=xAWVjs/QuGML4V3PTyzRvrfbWZrFcgHxvnDQFsqSDyI=; b=fjd7v9a7PirL 96ARPFXn62r66vdobeAmkZS51HdN0mZ7Za+pYCpdq97YW/P1+kFitlzBQLPxeZAHNFV9mb0P7ALu1 SeQCeSmM4I2jPG60p+r3CN9Y465Ah4JcSJ8gmXGZyqgH+tW5Y5JlXLx6jlqSrDrgzbMhLAIW6mDyl vAPCx2x7ZICGDnTy06zF4ZSRqHXxcSAjz48A8J2Wd9+W3H9fUqrSowRufD1z5yIXf6WMwB8meP/iX TBYwSsl5GZyf6+KOXgacrb46ZS5y6x6MI+RoRxz58VSrx4J2HNezCSO+/fP8oeWwrz3rGUGWRRnmC d83JtEzqavYnEn+g853fdA==; Original-Received: from [87.69.77.57] (port=3583 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqPz-0008QY-UL; Thu, 03 Mar 2022 13:43:17 -0500 In-Reply-To: (message from Jim Porter on Thu, 3 Mar 2022 09:56:14 -0800) 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:227969 Archived-At: > Cc: 54227@debbugs.gnu.org > From: Jim Porter > Date: Thu, 3 Mar 2022 09:56:14 -0800 > > >> +(defmacro eshell-with-temp-command (command &rest body) > >> + "Narrow the buffer to COMMAND and execute the forms in BODY. > > > > What does it mean to "narrow the buffer to COMMAND"? > > > > Imagine that the user only sees this one line of the doc string -- > > that actually happens in apropos commands. How can such a user > > understand what this macro does? > > The macro's job is to take an Eshell command (or some fragment thereof) > and narrow the buffer so that it's just looking at that part. This is to > make sure that whatever is called in the body knows where to start and > stop looking. > > I agree that this isn't very clear, but I had trouble coming up with a > concise explanation. It's essentially a workaround for how Eshell > expects things; a lot of the Eshell command parsing functions operate on > a range of text in the buffer. Normally, if you wanted to use those > functions with a temporary string, you'd use `with-temp-buffer' and > insert the string there. That doesn't work here though, since Eshell > uses lots of buffer-local state. This function tries to abstract that > out in a way that's useful for a few different places in Eshell. > > If you have any ideas about how to improve the wording, I'm happy to > update it though. I'll try to keep thinking as well. Something like the below: (defmacro eshell-with-temp-command (region &rest body) "Narrow the buffer to REGION and execute the forms in BODY. REGION is a cons cell (START . END) that specifies the region to which to narrow the buffer. REGION can also be a string, in which case the macro temporarily inserts it into the buffer at point, and narrows the buffer to the inserted string. Before executing BODY, point is set to the beginning of the narrowed REGION. > diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi > index 5581e5cd9e..47f8902d5a 100644 > --- a/doc/misc/eshell.texi > +++ b/doc/misc/eshell.texi > @@ -1043,15 +1043,16 @@ Dollars Expansion > index. If @var{expr}'s value is a string, it will first be split at > whitespace to make it a list. If @var{expr}'s value is an alist > (@pxref{Association List Type, Association Lists, , elisp, The Emacs > -Lisp Reference Manual}), this will call @code{assoc} on the result of > -@var{expr}, returning the @code{cdr} of the element of the result > -whose car is equal to @code{"i"}. Raises an error if the value is not > -a sequence (@pxref{Sequences Arrays Vectors, Sequences, , elisp, The > -Emacs Lisp Reference Manual}). > +Lisp Reference Manual}), this will return the value associated with > +the key @code{"i"}. > > -Multiple sets of indices can also be specified. For example, if > -@var{var} is a list of lists, @samp{$@var{var}[0][0]} is equivalent to > -@samp{(caar @var{var})}. > +Multiple sets of indices can also be specified. For example, if > +@var{var} is @samp{((1 2) (3 4))}, then @samp{$@var{var}[0][1]} will > +expand to @code{2}. I would add to the last sentence: ", i.e.@: the second element of the first list member (all indices are zero-based)." Also, it sounds like you just dropped the ball on the alist use case? > -(defun eshell-parse-inner-double-quote (bound) > - "Parse the inner part of a double quoted string. > +(defun eshell-unescape-inner-double-quote (bound) > + "Unescape the inner part of a double quoted string. "Unescape escaped characters of a double-quoted string." Thanks.