From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: stub for dynamic directory name completion
Date: Mon, 29 Sep 2008 18:38:20 +0100 [thread overview]
Message-ID: <11767.1222709900@csr.com> (raw)
This provides a hook for you to complete dynamic directory names by
redefining _dynamic_directory_name. As it's entirely up to you there's
no point in providing any code, although we could agree a useful format:
I'm using colon-separated name parts where the context for later parts
depends on earlier parts. It's still quite hard to define completion
generically, even with styles, because of the tree structure. Maybe
someone from computer-science-land has some bright ideas.
Index: Completion/Zsh/Context/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/.distfiles,v
retrieving revision 1.4
diff -u -r1.4 .distfiles
--- Completion/Zsh/Context/.distfiles 13 Jun 2008 13:57:04 -0000 1.4
+++ Completion/Zsh/Context/.distfiles 29 Sep 2008 17:32:27 -0000
@@ -5,6 +5,7 @@
_brace_parameter
_condition
_default
+_dynamic_directory_name
_equal
_first
_in_vared
Index: Completion/Zsh/Context/_dynamic_directory_name
===================================================================
RCS file: Completion/Zsh/Context/_dynamic_directory_name
diff -N Completion/Zsh/Context/_dynamic_directory_name
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Completion/Zsh/Context/_dynamic_directory_name 29 Sep 2008 17:32:27 -0000
@@ -0,0 +1,7 @@
+#autoload
+
+# The core libraries don't check for dynamic directory name expansion;
+# this gets called from _subscript. This is a placeholder for
+# people to overload.
+
+_message 'dynamic directory name: redefine _dynamic_directory_name to use'
Index: Completion/Zsh/Context/_subscript
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_subscript,v
retrieving revision 1.14
diff -u -r1.14 _subscript
--- Completion/Zsh/Context/_subscript 9 Apr 2008 13:06:55 -0000 1.14
+++ Completion/Zsh/Context/_subscript 29 Sep 2008 17:32:27 -0000
@@ -10,7 +10,16 @@
compset -P '\(([^\(\)]|\(*\))##\)' # remove subscript flags
-if [[ "$PREFIX" = :* ]]; then
+# Look for a dynamic name expansion. Completion only gives us
+# the stuff inside the square brackets; we need to find out what's
+# outside. We ought to check for quoting, really, but given we've
+# got to the subscript code " ~[" is pretty likely to be a dynamic
+# name expansion.
+integer pos=$((CURSOR+1))
+while [[ pos > 1 && $BUFFER[pos-1] != '[' ]]; do (( pos-- )); done
+if [[ $BUFFER[1,pos] = *[[:space:]]##\~\[ ]]; then
+ _dynamic_directory_name
+elif [[ "$PREFIX" = :* ]]; then
_wanted characters expl 'character class' \
compadd -p: -S ':]' alnum alpha ascii blank cntrl digit graph \
lower print punct space upper xdigit
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
reply other threads:[~2008-09-29 17:38 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=11767.1222709900@csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.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).