* Re: completion after //
@ 2000-01-19 16:42 Sven Wischnowsky
2000-01-20 9:12 ` Alexandre Duret-Lutz
0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2000-01-19 16:42 UTC (permalink / raw)
To: zsh-workers
Alexandre Duret-Lutz wrote:
> >>> "Tanaka" == Tanaka Akira <akr@jaist.ac.jp> writes:
>
> Tanaka> Sometimes completion after ../ frustrates me.
>
> [...]
>
> Along with the same lines, something I don't like is
> that the path `a///////b' is not understand as 'a/b' by _path_files
> (when I cut and past path names that contains doubled
> slashes, it's annoying to not be able to complete after these).
>
> I wanted to add :
>
> # Squeeze sequences of slashes
> PREFIX="${PREFIX//(\\/)#//}"
> SUFFIX="${SUFFIX//(\\/)#//}"
> [[ $PREFIX = */ ]] && SUFFIX=${SUFFIX#/}
>
> at the beginning of _path_files, but then realized that
> people may want to use `//' to do partial path completion.
>
> Should this be tunable ?
I fear it will mess up completion inside braces (only if both multiple
slashes and braces are used at the same time), but: try it. Using a
style for it, of course ;-)
When I wrote _path_files I was tempted to disallow in-path completion
inside `//' at least when that appears at the beginning, because, if
I'm not completely mistaken, there is or once was a Unix version where
this had special meaning.
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completion after //
2000-01-19 16:42 completion after // Sven Wischnowsky
@ 2000-01-20 9:12 ` Alexandre Duret-Lutz
0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-20 9:12 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
>>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
[...]
Sven> I fear it will mess up completion inside braces (only if both multiple
Sven> slashes and braces are used at the same time), but: try it. Using a
Sven> style for it, of course ;-)
[...]
Here is the patch that add a squeeze-slashes style for that.
I couldn't find any problem with braces completion, but maybe I wasn't
looking the right direction.
Index: Doc/Zsh/compsys.yo
--- Doc/Zsh/compsys.yo Wed, 19 Jan 2000 21:50:19 +0100 Alexandre
+++ Doc/Zsh/compsys.yo Thu, 20 Jan 2000 10:09:48 +0100 Alexandre
@@ -1160,6 +1160,36 @@
as single strings (not in the string containing all possible
expansions).
)
+item(tt(special-dirs))(
+Normally, the completion code will not produce the directory names
+tt(.) and tt(..) as possible completions. If this style is set to
+`true', it will add both `tt(.)' and `tt(..)' as possible completions,
+if it is set to tt(..), only `tt(..)' will be added.
+)
+item(tt(squeeze-slashes))(
+If set to `true', sequences of slashes (such as tt(foo//bar)) will
+be rewritten with a single slash (tt(foo/bar)) when completing
+directory names.
+)
+item(tt(stop))(
+If set to `true', the tt(_history_complete_word) bindable
+command will always insert matches as if menucompletion were started
+and it will stop when the last match is inserted. If this style is set
+to tt(verbose) a message will be displayed when the last match is reached.
+)
+item(tt(substitute))(
+If this is unset or set to the empty string, the tt(_expand) completer
+will first try to expand all substitutions in the string (such as
+`tt($LPAR()...RPAR())' and `tt(${...})'). If this is set to an
+non-empty string it should be an expression usable inside a `tt($((...)))'
+arithmetical expression. In this case, expansion of substitutions will
+be done if the expression evaluates to `tt(1)'. For example, with
+
+example(zstyle ':completion:expand' substitute '${NUMERIC:-1} != 1')
+
+substitution will be performed only if given an explicit numeric
+argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'.
+)
item(tt(tag-order))(
This provides a mechanism for sorting how the tags available in a
particular context will be used.
@@ -1195,31 +1225,6 @@
of how such functions can be implemented.
If no style has been defined for a context, all tags will be used.
-)
-item(tt(special-dirs))(
-Normally, the completion code will not produce the directory names
-tt(.) and tt(..) as possible completions. If this style is set to
-`true', it will add both `tt(.)' and `tt(..)' as possible completions,
-if it is set to tt(..), only `tt(..)' will be added.
-)
-item(tt(stop))(
-If set to `true', the tt(_history_complete_word) bindable
-command will always insert matches as if menucompletion were started
-and it will stop when the last match is inserted. If this style is set
-to tt(verbose) a message will be displayed when the last match is reached.
-)
-item(tt(substitute))(
-If this is unset or set to the empty string, the tt(_expand) completer
-will first try to expand all substitutions in the string (such as
-`tt($LPAR()...RPAR())' and `tt(${...})'). If this is set to an
-non-empty string it should be an expression usable inside a `tt($((...)))'
-arithmetical expression. In this case, expansion of substitutions will
-be done if the expression evaluates to `tt(1)'. For example, with
-
-example(zstyle ':completion:expand' substitute '${NUMERIC:-1} != 1')
-
-substitution will be performed only if given an explicit numeric
-argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'.
)
item(tt(users))(
This may be set to a list of names that should be completed whenever
Index: Completion/Core/_path_files
--- Completion/Core/_path_files Wed, 19 Jan 2000 21:50:19 +0100 Alexandre
+++ Completion/Core/_path_files Thu, 20 Jan 2000 09:47:19 +0100 Alexandre
@@ -157,6 +157,14 @@
fi
fi
+# Squeeze sequences of slashes
+if zstyle -t ":completion${curcontext}:paths" squeeze-slashes
+then
+ PREFIX="${PREFIX//(\\/)#//}"
+ SUFFIX="${SUFFIX//(\\/)#//}"
+ [[ $PREFIX = */ ]] && SUFFIX=${SUFFIX#/}
+fi
+
# We get the prefix and the suffix from the line and save the whole
# original string. Then we see if we will do menucompletion.
Index: Completion/Builtins/_zstyle
--- Completion/Builtins/_zstyle Fri, 14 Jan 2000 10:25:34 +0100 Alexandre
+++ Completion/Builtins/_zstyle Thu, 20 Jan 2000 10:10:04 +0100 Alexandre
@@ -18,6 +18,7 @@
cursor c:bool
disable-stat c:bool
expand c:
+ file-patterns c:
format c:
glob c:
group-name c:
@@ -49,6 +50,7 @@
sort c:bool
tag-order c:tag
special-dirs c:sdirs
+ squeeze-slashes c:bool
stop c:stop
substitute c:
users c:_users
--
Alexandre Duret-Lutz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completion after //
@ 2000-01-21 13:55 Sven Wischnowsky
0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2000-01-21 13:55 UTC (permalink / raw)
To: zsh-workers
Alexandre Duret-Lutz wrote:
> I will try later not to rewrite PREFIX and SUFFIX but only the copies
> of these used by _path_files. Then,_path_files should complete
> as if there no sequence of slashes, but since the line won't be modified,
> I suppose the braces won't move.
May I suggest this simple solution?
`squeeze-slashes' may be a bit of a misnomer with it, though.
Bye
Sven
diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files Fri Jan 21 14:40:49 2000
+++ Completion/Core/_path_files Fri Jan 21 14:50:20 2000
@@ -3,7 +3,7 @@
# Utility function for in-path completion. This allows `/u/l/b<TAB>'
# to complete to `/usr/local/bin'.
-local linepath realpath donepath prepath testpath exppath
+local linepath realpath donepath prepath testpath exppath skips
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 rem remt
local nm=$compstate[nmatches] menu mspec matcher mopts atmp sort match
@@ -157,13 +157,9 @@
fi
fi
-# Squeeze sequences of slashes
-if zstyle -t ":completion${curcontext}:paths" squeeze-slashes
-then
- PREFIX="${PREFIX//(\\/)#//}"
- SUFFIX="${SUFFIX//(\\/)#//}"
- [[ $PREFIX = */ ]] && SUFFIX=${SUFFIX#/}
-fi
+# Skip over sequences of slashes.
+
+zstyle -t ":completion${curcontext}:paths" squeeze-slashes && skips=yes
# We get the prefix and the suffix from the line and save the whole
# original string. Then we see if we will do menucompletion.
@@ -269,6 +265,14 @@
if [[ "$tpre" = (.|..)/* ]]; then
tmp1=( ${^tmp1}${tpre%%/*}/ )
tpre="${tpre#*/}"
+ continue
+ fi
+
+ # Skip over multiple slashes?
+
+ if [[ -n "$skips" && "$tpre" = /* ]]; then
+ tmp1=( ${^tmp1}/ )
+ tpre="${tpre#/}"
continue
fi
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo Fri Jan 21 14:40:25 2000
+++ Doc/Zsh/compsys.yo Fri Jan 21 14:53:31 2000
@@ -1199,9 +1199,7 @@
)
item(tt(squeeze-slashes))(
If set to `true', sequences of slashes (like in `tt(foo//bar)') will be
-rewritten with a single slash (`tt(foo/bar)') when completing directory
-names. Using this style can confuse tt(zsh) if slashes get squeezed
-before braces completion (e.g. when trying to complete `tt(//{etc)').
+treated as if they were only one slash when completing pathnames.
)
item(tt(stop))(
If set to `true', the tt(_history_complete_word) bindable
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completion after //
2000-01-20 9:23 Sven Wischnowsky
@ 2000-01-20 10:21 ` Alexandre Duret-Lutz
0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-20 10:21 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
>>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
[...]
Sven>> ls ./////f{o/b/b/p<TAB>
Sven> gives:
Sven>> ls ./foo/bar/{baz/plop/
Sven> I don't see a solution. But maybe it's seldom enough. Maybe we should
Sven> add a comment about this in the docs.
[...]
I will try later not to rewrite PREFIX and SUFFIX but only the copies
of these used by _path_files. Then,_path_files should complete
as if there no sequence of slashes, but since the line won't be modified,
I suppose the braces won't move.
Index: Doc/Zsh/compsys.yo
--- Doc/Zsh/compsys.yo Thu, 20 Jan 2000 10:18:01 +0100 Alexandre
+++ Doc/Zsh/compsys.yo Thu, 20 Jan 2000 11:10:30 +0100 Alexandre
@@ -1167,9 +1167,10 @@
if it is set to tt(..), only `tt(..)' will be added.
)
item(tt(squeeze-slashes))(
-If set to `true', sequences of slashes (such as tt(foo//bar)) will
-be rewritten with a single slash (tt(foo/bar)) when completing
-directory names.
+If set to `true', sequences of slashes (like in `tt(foo//bar)') will be
+rewritten with a single slash (`tt(foo/bar)') when completing directory
+names. Using this style can confuse tt(zsh) if slashes get squeezed
+before braces completion (e.g. when trying to complete `tt(//{etc)').
)
item(tt(stop))(
If set to `true', the tt(_history_complete_word) bindable
--
Alexandre Duret-Lutz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completion after //
@ 2000-01-20 9:23 Sven Wischnowsky
2000-01-20 10:21 ` Alexandre Duret-Lutz
0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2000-01-20 9:23 UTC (permalink / raw)
To: zsh-workers
Alexandre Duret-Lutz wrote:
> >>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
>
> [...]
>
> Sven> I fear it will mess up completion inside braces (only if both multiple
> Sven> slashes and braces are used at the same time), but: try it. Using a
> Sven> style for it, of course ;-)
>
> [...]
>
> Here is the patch that add a squeeze-slashes style for that.
> I couldn't find any problem with braces completion, but maybe I wasn't
> looking the right direction.
This:
> zstyle '*' squeeze-slashes yes
> mkdir foo{,/bar{,/baz{,/plop}}}
> ls ./////f{o/b/b/p<TAB>
gives:
> ls ./foo/bar/{baz/plop/
I don't see a solution. But maybe it's seldom enough. Maybe we should
add a comment about this in the docs.
> + file-patterns c:
Uh, oh. Thanks :-}
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* completion after //
2000-01-19 9:51 completion after ../ Tanaka Akira
@ 2000-01-19 11:17 ` Alexandre Duret-Lutz
0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-19 11:17 UTC (permalink / raw)
To: zsh-workers
>>> "Tanaka" == Tanaka Akira <akr@jaist.ac.jp> writes:
Tanaka> Sometimes completion after ../ frustrates me.
[...]
Along with the same lines, something I don't like is
that the path `a///////b' is not understand as 'a/b' by _path_files
(when I cut and past path names that contains doubled
slashes, it's annoying to not be able to complete after these).
I wanted to add :
# Squeeze sequences of slashes
PREFIX="${PREFIX//(\\/)#//}"
SUFFIX="${SUFFIX//(\\/)#//}"
[[ $PREFIX = */ ]] && SUFFIX=${SUFFIX#/}
at the beginning of _path_files, but then realized that
people may want to use `//' to do partial path completion.
Should this be tunable ?
--
Alexandre Duret-Lutz
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2000-01-21 13:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-19 16:42 completion after // Sven Wischnowsky
2000-01-20 9:12 ` Alexandre Duret-Lutz
-- strict thread matches above, loose matches on Subject: below --
2000-01-21 13:55 Sven Wischnowsky
2000-01-20 9:23 Sven Wischnowsky
2000-01-20 10:21 ` Alexandre Duret-Lutz
2000-01-19 9:51 completion after ../ Tanaka Akira
2000-01-19 11:17 ` completion after // Alexandre Duret-Lutz
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).