From: Peter Stephenson <pws@cambridgesiliconradio.com>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: Re: PATCH: Re: complete (real C) tags
Date: Tue, 23 May 2000 16:13:20 +0100 [thread overview]
Message-ID: <0FV000KH2QA8D7@la-la.cambridgesiliconradio.com> (raw)
In-Reply-To: "Your message of Tue, 23 May 2000 16:19:19 +0200." <200005231419.QAA27360@beta.informatik.hu-berlin.de>
> This adds -a to make the words be used as names of arrays
> (actually I used get_user_var(), so '(foo bar)' is possible, should we
> document this?) and complete their values. It also adds -k to make the
> words be taken as names of assocs and complete their keys.
That's a huge improvement. Here is _complete_tag.
Index: Completion/Commands/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/.distfiles,v
retrieving revision 1.2
diff -u -r1.2 .distfiles
--- Completion/Commands/.distfiles 2000/04/30 21:04:54 1.2
+++ Completion/Commands/.distfiles 2000/05/23 15:11:24
@@ -2,5 +2,5 @@
.distfiles
_bash_completions _complete_debug _correct_filename _correct_word
_expand_word _history_complete_word _read_comp _most_recent_file
- _complete_help _next_tags
+ _complete_help _next_tags _complete_tag
'
Index: Completion/Commands/_complete_tag
===================================================================
RCS file: _complete_tag
diff -N _complete_tag
--- /dev/null Tue May 5 13:32:27 1998
+++ _complete_tag Tue May 23 08:11:24 2000
@@ -0,0 +1,57 @@
+#compdef -k complete-word \C-xt
+
+# Complete tags using either TAGS or tags. Looks up your directory
+# hierarchy to find one. If both exist, uses TAGS.
+#
+# You can override the choice of tags file with $TAGSFILE (for TAGS)
+# or $tagsfile (for tags).
+#
+# Could be rewritten by some sed expert to use sed instead of perl.
+
+emulate -L zsh
+
+# Tags file to look for
+local c_Tagsfile=${TAGSFILE:-TAGS} c_tagsfile=${tagsfile:-tags} expl
+# Max no. of directories to scan up through
+integer c_maxdir=10
+# Context.
+local curcontext="$curcontext"
+local -a c_tags_array
+
+if [[ -z "$curcontext" ]]; then
+ curcontext="complete-tag:::"
+else
+ curcontext="complete-tag:${curcontext#*:}"
+fi
+
+local c_path=
+integer c_idir
+while [[ ! -f $c_path$c_Tagsfile &&
+ ! -f $c_path$c_tagsfile && $c_idir -lt $c_maxdir ]]; do
+ (( c_idir++ ))
+ c_path=../$c_path
+done
+
+if [[ -f $c_path$c_Tagsfile ]]; then
+ # prefer the more comprehensive TAGS, which unfortunately is a
+ # little harder to parse.
+ # could do this with sed, just can't be bothered to work out how,
+ # after quarter of an hour of trying, except for
+ # rm -f =sed; ln -s /usr/local/bin/perl /usr/bin/sed
+ # but that's widely regarded as cheating.
+ c_tags_array=($(sed -n \
+ -e 's/^\(.*[a-zA-Z_0-9]\)[[ '$'\t'':;,()]*'$'\177''.*$/\1/' \
+ -e 's/^.*[^a-zA-Z_0-9]//' \
+ -e '/^[a-zA-Z_].*/p' $c_path$c_Tagsfile))
+# c_tags_array=($(perl -ne '/([a-zA-Z_0-9]+)[ \t:;,\(]*\x7f/ &&
+# print "$1\n"' $c_path$c_Tagsfile))
+ _main_complete - '' _wanted etags expl 'emacs tags' \
+ compadd -a c_tags_array
+elif [[ -f $c_tagspath ]]; then
+ # tags doesn't have as much in, but the tag is easy to find.
+ # we can use awk here.
+ c_tags_array=($(awk '{ print $1 }' $c_path$c_Tagsfile))
+ _main_complete - '' _wanted vtags expl 'vi tags' compadd -a c_tags_array
+else
+ return 1
+fi
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.53
diff -u -r1.53 compsys.yo
--- Doc/Zsh/compsys.yo 2000/05/22 09:28:35 1.53
+++ Doc/Zsh/compsys.yo 2000/05/23 15:11:24
@@ -2460,6 +2460,18 @@
completion attempt gets its own file. A command to view each of these
files is pushed onto the editor buffer stack.
)
+findex(_complete_tag (^Xt))
+item(tt(_complete_tag (^Xt)))(
+This widget completes symbol tags created by the tt(etags) or tt(ctags)
+programmes (note there is no connection with the completion system's tags)
+stored in a file tt(TAGS), in the format used by tt(etags), or tt(tags), in the
+format created by tt(ctags). It will look back up the path hierarchy for
+the first occurrence of either file; if both exist, the file tt(TAGS) is
+preferred. You can specify the full path to a tt(TAGS) or tt(tags) file by
+setting the parameter tt($TAGSFILE) or tt($tagsfile) respectively.
+The corresponding completion tags used are tt(etags) and tt(vtags), after
+emacs and vi respectively.
+)
enditem()
texinode(Completion Functions)(Completion Directories)(Bindable Commands)(Completion System)
--
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
next prev parent reply other threads:[~2000-05-23 15:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-23 14:19 Sven Wischnowsky
2000-05-23 15:13 ` Peter Stephenson [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-05-31 9:36 Sven Wischnowsky
2000-05-31 10:07 ` Peter Stephenson
2000-05-25 12:18 Sven Wischnowsky
2000-05-25 13:02 ` Thomas Köhler
2000-05-25 14:41 ` Bart Schaefer
2000-05-24 8:00 Sven Wischnowsky
2000-05-24 9:00 ` Peter Stephenson
2000-05-24 9:09 ` Thomas Köhler
2000-05-18 10:46 Sven Wischnowsky
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=0FV000KH2QA8D7@la-la.cambridgesiliconradio.com \
--to=pws@cambridgesiliconradio.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).