zsh-workers
 help / color / mirror / code / Atom feed
* Re: Bug#527301: _xmms2 jump/_values: suboptimal presentation/sorting
       [not found] <20090506162216.GA24031@piper.oerlikon.madduck.net>
@ 2009-05-06 17:26 ` Clint Adams
  2009-05-06 19:36   ` martin f krafft
  0 siblings, 1 reply; 2+ messages in thread
From: Clint Adams @ 2009-05-06 17:26 UTC (permalink / raw)
  To: martin f krafft, 527301; +Cc: zsh-workers

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
      


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug#527301: _xmms2 jump/_values: suboptimal presentation/sorting
  2009-05-06 17:26 ` Bug#527301: _xmms2 jump/_values: suboptimal presentation/sorting Clint Adams
@ 2009-05-06 19:36   ` martin f krafft
  0 siblings, 0 replies; 2+ messages in thread
From: martin f krafft @ 2009-05-06 19:36 UTC (permalink / raw)
  To: 527301, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2095 bytes --]

also sprach Clint Adams <schizo@debian.org> [2009.05.06.1926 +0200]:
> zstyle :completion::complete:xmms2:\*:values list-grouped false
> zstyle :completion::complete:xmms2:\*:values sort false

Ooooh!

Which documentation did I not read? I tried
http://zsh.dotsrc.org/Doc/Release/zsh_19.html#SEC124 and the source
code, but I couldn't deduce this gem.

> I have no opinion on how the default behavior should be handled.

I'd say for playlists, grouping makes no sense, and since the
playlist is already passed sorted, sorting should be disabled,
especially since it doesn't do numeric sorting anyway.

My vote's for making your suggestion quoted above default.

On a side note: why is the playlist sorted in reverse order?

  18    -- Deep Purple - Smoke on the Water
  17    -- Deep Purple - Speed King
  16    -- Deep Purple - Anya
  15    -- Deep Purple - Child in Time
  14    -- Deep Purple - Anyone's Daugher
  13    -- Deep Purple - Perfect Strangers
  12    -- Deep Purple - A Twist in the Tail
  11    -- Deep Purple - Black Night
  10    -- Deep Purple - Highway Star
  9     -- Deep Purple - Lucille
  8     -- Deep Purple - Speed King
  7     -- Deep Purple - Black Night
  6     -- Deep Purple - Space Truckin'
  5     -- Deep Purple - Lazy
  4     -- Deep Purple - Strange Kind of Woman
  3     -- Deep Purple - The Mule
  2     -- Deep Purple - Smoke on the Water
  1     -- Deep Purple - Child in Time

I'd suggest

--- /tmp/_xmms2 2009-05-06 21:32:06.000000000 +0200
+++ /usr/share/zsh-beta/functions/Completion/Unix/_xmms2        2009-05-06 21:32:23.000000000 +0200
@@ -66,7 +66,7 @@
   fi
      done
      
-     _values -s ' ' 'playlist items' ${(On)playlistitems}
+     _values -s ' ' 'playlist items' ${(on)playlistitems}
 
 }

In addition.

-- 
 .''`.   martin f. krafft <madduck@d.o>      Related projects:
: :'  :  proud Debian developer               http://debiansystem.info
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-06 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20090506162216.GA24031@piper.oerlikon.madduck.net>
2009-05-06 17:26 ` Bug#527301: _xmms2 jump/_values: suboptimal presentation/sorting Clint Adams
2009-05-06 19:36   ` martin f krafft

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).