From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11891 invoked from network); 4 Jan 2000 13:46:43 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Jan 2000 13:46:43 -0000 Received: (qmail 8934 invoked by alias); 4 Jan 2000 13:46:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9199 Received: (qmail 8927 invoked from network); 4 Jan 2000 13:46:37 -0000 Date: Tue, 4 Jan 2000 14:45:25 +0100 (MET) Message-Id: <200001041345.OAA07713@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk CC: Eric Smith In-reply-to: Eric Smith's message of Tue, 28 Dec 1999 00:27:43 +0200 Subject: Re: compctl tab order by modification date [ List changed to zsh-workers and CC'ed to Eric. ] Eric Smith wrote: > Hi > > I would like to tab through files in order of their modification date, most > recent first. How could I set completion control to do this? Currently there is no way to do that. However, the patch to allow this in the new completion system is quite simple -- see below. It adds the style `sort' for the `files' tag, so that: zstyle ':completion:*:files' sort time gives what you wanted. With `compctl' I don't see a nice-enough solution (a completion function calling `ls -t' is not `nice', I think). I don't know if this patch is interesting enough to be included in the distribution, though. Bye Sven diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files --- ../z.old/Completion/Core/_path_files Tue Jan 4 14:06:00 2000 +++ Completion/Core/_path_files Tue Jan 4 14:42:03 2000 @@ -6,7 +6,7 @@ local linepath realpath donepath prepath testpath exppath local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre local pats haspats=no ignore group expl addpfx addsfx remsfx -local nm=$compstate[nmatches] menu match matcher mopts atmp +local nm=$compstate[nmatches] menu match matcher mopts atmp sort typeset -U prepaths exppaths @@ -99,6 +99,37 @@ pats=('*') else unset sopt + fi +fi + +if zstyle -s ":completion${curcontext}:files" sort tmp1; then + case "$tmp1" in + *size*) sort=oL;; + *links*) sort=ol;; + *(time|date|modi)*) sort=om;; + *access*) sort=oa;; + *(inode|change)*) sort=oc;; + *) sort=on;; + esac + [[ "$tmp1" = *rev* ]] && sort[1]=O + + if [[ "$sort" = on ]]; then + sort='' + else + group=( "${(@)group/#-J/-V}" ) + expl=( "${(@)expl/#-J/-V}" ) + + tmp2=() + for tmp1 in "$pats[@]"; do + if [[ "$tmp1" = ?*\(\([^\|~]##\)\) ]]; then + tmp2=( "$tmp2[@]" "${tmp1[1,-3]}${sort}))" ) + elif [[ "$tmp1" = ?*\([^\|~]##\) ]]; then + tmp2=( "$tmp2[@]" "${tmp1[1,-2]}${sort})" ) + else + tmp2=( "$tmp2[@]" "${tmp1}(${sort})" ) + fi + done + pats=( "$tmp2[@]" ) fi fi diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo --- ../z.old/Doc/Zsh/compsys.yo Tue Jan 4 10:15:50 2000 +++ Doc/Zsh/compsys.yo Tue Jan 4 14:38:25 2000 @@ -1093,6 +1093,18 @@ keeping them in the order in which they appear in the history (from youngest to oldest). +The completion function that generates filenames as possible matches +uses this style with the tt(files) tag to determine in which order the +names should be listed and completed when using menucompletion. The +value may be one of tt(size) to sort them by the size of the file, +tt(links) to sort them by the number of links to the file, +tt(modification) (or tt(time) or tt(date)) to sort them by the last +modification time, tt(access) to sort them by the last access time, or +tt(inode) (or tt(change)) to sort them by the last inode change +time. Any other value (or not setting this style at all) makes them be +sorted alphabetically by name. If the value contains the string +tt(reverse), sorting is done in decreasing order. + This is also used by the tt(_expand) completer. Here, if it is set to `true', the expansions generated will always be sorted. If it is set to tt(menu), then the expansions are only sorted when they are offered -- Sven Wischnowsky wischnow@informatik.hu-berlin.de