From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Cc: Eric Smith <eric@fruitcom.com>
Subject: Re: compctl tab order by modification date
Date: Tue, 4 Jan 2000 14:45:25 +0100 (MET) [thread overview]
Message-ID: <200001041345.OAA07713@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Eric Smith's message of Tue, 28 Dec 1999 00:27:43 +0200
[ 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
reply other threads:[~2000-01-04 13:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200001041345.OAA07713@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=eric@fruitcom.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).