Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug#527301: _xmms2 jump/_values: suboptimal presentation/sorting
- X-seq: zsh-workers 26939
- From: Clint Adams <schizo@xxxxxxxxxx>
- To: martin f krafft <madduck@xxxxxxxxxx>, 527301@xxxxxxxxxxxxxxx
- Subject: Re: Bug#527301: _xmms2 jump/_values: suboptimal presentation/sorting
- Date: Wed, 6 May 2009 17:26:31 +0000
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <20090506162216.GA24031@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: martin f krafft <madduck@xxxxxxxxxx>, 527301@xxxxxxxxxxxxxxx, zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20090506162216.GA24031@xxxxxxxxxxxxxxxxxxxxxxxxxx>
On Wed, May 06, 2009 at 06:22:16PM +0200, martin f krafft wrote:
> `xmms2 jump` completion uses
>
> _values -s ' ' 'playlist items' ${(On)playlistitems}
>
> where $playlistitems is an array with items e.g.
>
> 1[foo]
> 2[bar]
> ...
> 12[baz]
> 13[foo]
>
> Unfortunately, it seems as if _values does something weird:
> Even though ${(On)...} yields a reverse-numerically sorted list of
> those items, the output seems not numerically sorted.
>
> In addition, the way _values merges keys with the same value (1 and
> 13 in the above) is suboptimal for the use case.
>
> This list:
>
> [0/193] Deep Purple - Highway Star (06:43)
> [1/194] Deep Purple - Child in Time (12:17)
> [2/195] Deep Purple - Smoke on the Water (07:36)
> [3/196] Deep Purple - The Mule (09:28)
> [4/197] Deep Purple - Strange Kind of Woman (09:52)
> [5/198] Deep Purple - Lazy (10:27)
> [6/199] Deep Purple - Space Truckin' (19:54)
> [7/200] Deep Purple - Black Night (06:18)
> [8/201] Deep Purple - Speed King (07:24)
> [9/202] Deep Purple - Lucille (08:03)
> [10/203] Deep Purple - Highway Star (06:41)
> [11/204] Deep Purple - Black Night (05:48)
> [12/205] Deep Purple - A Twist in the Tail (04:23)
> [13/206] Deep Purple - Perfect Strangers (06:52)
> [14/207] Deep Purple - Anyone's Daugher (03:52)
> [15/208] Deep Purple - Child in Time (10:42)
> [16/209] Deep Purple - Anya (12:08)
> [17/210] Deep Purple - Speed King (07:33)
> [18/211] Deep Purple - Smoke on the Water (10:09)
>
> Yields this completion output:
>
> playlist items
> 10 -- Deep Purple - Highway Star
> 11 7 -- Deep Purple - Black Night
> 12 -- Deep Purple - A Twist in the Tail
> 13 -- Deep Purple - Perfect Strangers
> 14 -- Deep Purple - Anyone's Daugher
> 15 1 -- Deep Purple - Child in Time
> 16 -- Deep Purple - Anya
> 17 8 -- Deep Purple - Speed King
> 18 2 -- Deep Purple - Smoke on the Water
> 3 -- Deep Purple - The Mule
> 4 -- Deep Purple - Strange Kind of Woman
> 5 -- Deep Purple - Lazy
> 6 -- Deep Purple - Space Truckin'
> 9 -- Deep Purple - Lucille
>
> I am sure you'll agree that that's not really useful. It would be
> better to have proper numeric sorting and disable the merging.
You can try this for yourself:
zstyle :completion::complete:xmms2:\*:values list-grouped false
zstyle :completion::complete:xmms2:\*:values sort false
I have no opinion on how the default behavior should be handled.
Also, setting IFS to "oldIFS" doesn't seem useful, so here's some cleanup.
Index: Completion/Unix/Command/_xmms2
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_xmms2,v
retrieving revision 1.2
diff -u -r1.2 _xmms2
--- Completion/Unix/Command/_xmms2 5 May 2009 08:47:55 -0000 1.2
+++ Completion/Unix/Command/_xmms2 6 May 2009 17:22:18 -0000
@@ -55,14 +55,11 @@
}
_xmms2_jump() {
- oldIFS=$IFS
- IFS=$'\n'
- songlist=($(xmms2 list))
- IFS=oldIFS
- playlistitems=""
+ songlist=(${"$(xmms2 list)"})
+ playlistitems=()
for song ($songlist); do
if [[ $song = (#b)' '\[(<->)/(<->)\]' '(*)' '\((*)\) ]]; then
- playlistitems=($playlistitems "$match[1][$match[3]]")
+ playlistitems+=("$match[1][$match[3]]")
fi
done
Messages sorted by:
Reverse Date,
Date,
Thread,
Author