GNU bug report logs - #60999
30.0.50; [PATCH] Add support for negative indices and index ranges in Eshell

Previous Next

Package: emacs;

Reported by: Jim Porter <jporterbugs <at> gmail.com>

Date: Sun, 22 Jan 2023 03:48:02 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Done: Jim Porter <jporterbugs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jim Porter <jporterbugs <at> gmail.com>
Subject: bug#60999: closed (Re: bug#60999: 30.0.50; [PATCH] Add support
 for negative indices and index ranges in Eshell)
Date: Sat, 28 Jan 2023 02:16:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#60999: 30.0.50; [PATCH] Add support for negative indices and index ranges in Eshell

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 60999 <at> debbugs.gnu.org.

-- 
60999: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60999
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Jim Porter <jporterbugs <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60999-done <at> debbugs.gnu.org
Subject: Re: bug#60999: 30.0.50; [PATCH] Add support for negative indices and
 index ranges in Eshell
Date: Fri, 27 Jan 2023 18:15:28 -0800
On 1/27/2023 10:57 AM, Eli Zaretskii wrote:
> Feel free.

Thanks. Merged as 5642bf0b97. I'll send a message to emacs-devel over 
the weekend.

Closing this now.

[Message part 3 (message/rfc822, inline)]
From: Jim Porter <jporterbugs <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; [PATCH] Add support for negative indices and index ranges in
 Eshell
Date: Sat, 21 Jan 2023 19:47:47 -0800
[Message part 4 (text/plain, inline)]
There are two suggestions in the "Bugs and ideas" section of the Eshell 
manual:

  Allow "$_[-1]", which would indicate the last element of the array

  Make "$x[*]" equal to listing out the full contents of "x"

I think these would be pretty useful, especially for the "$_" variable, 
which gets the last argument of the last command, but if you give it an 
index like "$_[N]", gets the Nth argument of the last command. However, 
it's not as easy to get the second-to-last argument of the last command, 
or to get *all* arguments of the last command. So the above two 
suggestions would be pretty helpful.

Attached is a patch to do this. For the second suggestion, I took some 
liberties and added range syntax, so that "$x[2..5]" returns elements 2, 
3, and 4 (zero-indexed) of x.

I have just one question though: this implementation treats ranges as 
half-open, i.e. "M..N" is [M, N). I think that's the best way of doing 
things (and it matches how 'seq-subseq' works). However, "M..N" is the 
Bash syntax, which uses a closed range, [M, N]. Maybe this would be too 
confusing for users? I'm open to using other tokens aside from ".." if 
that would help. Maybe "M:N" would work? That's the Python syntax, which 
behaves the same way as this patch. Any thoughts?
[0001-Add-support-for-negative-indices-and-index-ranges-in.patch (text/plain, attachment)]

This bug report was last modified 2 years and 116 days ago.

Previous Next


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