zsh-workers
 help / color / mirror / code / Atom feed
* Re: two completion questions
@ 1999-12-13 13:39 Sven Wischnowsky
  1999-12-13 16:56 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 1999-12-13 13:39 UTC (permalink / raw)
  To: zsh-workers


[ Moved to zsh-workers ]

Zefram wrote:

> Bart Schaefer wrote:
> >If you're using the new function-based completion in 3.1.6, it's going to
> >require some editing of the _path_files completer.  Hey, Sven, do you (or
> >any other zsh-workers) remember the rationale for this handling of ".."?
> 
> Globbing and completion never generate "." or ".." components; they are
> filtered out in zreaddir().  The reason for this is that they are pretty
> much never what you want.  If you have files named ".foo" and ".bar",
> then type "." and press tab, are "." and ".." really what you want to
> complete to?  Maybe there should be an option to complete to "." and
> ".." just like normal filenames, but I think the default should very
> definitely stay as being the current behaviour.

Right. This makes it configurable with the special-dirs style. Can
anyone think of a better name?

Bye
 Sven

diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files	Mon Dec 13 14:22:15 1999
+++ Completion/Core/_path_files	Mon Dec 13 14:37:14 1999
@@ -224,12 +224,19 @@
 
     if [[ "$tpre$tsuf" = */* ]]; then
       tmp2=( ${^tmp1}*(-/) )
-      [[ ! -o globdots && "$PREFIX" = .* ]] &&
-          tmp2=( "$tmp2[@]" ${^tmp1}.*(-/) . .. )
+      if [[ ! -o globdots && "$PREFIX" = .* ]]; then
+        tmp2=( "$tmp2[@]" ${^tmp1}.*(-/) )
+	zstyle -t ":completion${curcontext}:paths" special-dirs &&
+	    tmp2=( "$tmp2[@]" . .. )
+      fi
     else
       tmp2=( ${^tmp1}${^~pats} )
-      [[ ! -o globdots && "$PREFIX" = .* ]] &&
-          tmp2=( "$tmp2[@]" ${^tmp1}.${^~pats} . .. )
+      if [[ ! -o globdots && "$PREFIX" = .* ]]; then
+        tmp2=( "$tmp2[@]" ${^tmp1}.${^~pats} )
+        [[ "$sopt" = */* ]] &&
+	    zstyle -t ":completion${curcontext}:paths" special-dirs &&
+	    tmp2=( "$tmp2[@]" . .. )
+      fi
     fi
     tmp1=( "$tmp2[@]" )
 
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo	Mon Dec 13 14:21:51 1999
+++ Doc/Zsh/compsys.yo	Mon Dec 13 14:36:50 1999
@@ -647,7 +647,8 @@
 completing for the tt(cd) builtin command
 )
 item(tt(paths))(
-used to look up the values of the tt(expand) and tt(cursor) styles
+used to look up the values of the tt(expand), tt(cursor) and
+tt(special-dirs) styles
 )
 item(tt(pods))(
 for perl pods
@@ -1191,6 +1192,11 @@
 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.
+)
 item(tt(stop))(
 If set to `true', the tt(_history_complete_word) bindable
 command will always insert matches as if menucompletion were started
@@ -1894,8 +1900,8 @@
 `tt(-2)', `tt(-n)', `tt(-X)', `tt(-M)', `tt(-P)', `tt(-S)', `tt(-q)',
 `tt(-r)', and `tt(-R)' options from the tt(compadd) builtin.
 
-Finally, the tt(_path_files) function  uses the styles tt(expand) and
-tt(cursor) with the tt(paths) tag.
+Finally, the tt(_path_files) function  uses the styles tt(expand),
+tt(cursor) and tt(special-dirs) with the tt(paths) tag.
 )
 findex(_parameters)
 item(tt(_parameters))(

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: two completion questions
  1999-12-13 13:39 two completion questions Sven Wischnowsky
@ 1999-12-13 16:56 ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-12-13 16:56 UTC (permalink / raw)
  To: zsh-workers

On Dec 13,  2:39pm, Sven Wischnowsky wrote:
} Subject: Re: two completion questions
}
} Zefram wrote:
} 
} > Globbing and completion never generate "." or ".." components; they are
} > filtered out in zreaddir().  The reason for this is that they are pretty
} > much never what you want.  If you have files named ".foo" and ".bar",
} > then type "." and press tab, are "." and ".." really what you want to
} > complete to?  Maybe there should be an option to complete to "." and
} > ".." just like normal filenames, but I think the default should very
} > definitely stay as being the current behaviour.
} 
} Right. This makes it configurable with the special-dirs style. Can
} anyone think of a better name?

I'm dubious that '.' should ever be a completion by itself.  I really don't
want to type `.<TAB>' and end up with `./' on the line -- but I can see the
argument for wanting `..<TAB>' to behave that way.  Yes, it's exactly the
same number of keystrokes to type the slash yourself instead of a tab, but
habits are habits.

Completing '.' would be even more annoying with REC_EXACT.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: two completion questions
@ 1999-12-14  9:09 Sven Wischnowsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 1999-12-14  9:09 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Dec 13,  2:39pm, Sven Wischnowsky wrote:
> } Subject: Re: two completion questions
> }
> } Zefram wrote:
> } 
> } > Globbing and completion never generate "." or ".." components; they are
> } > filtered out in zreaddir().  The reason for this is that they are pretty
> } > much never what you want.  If you have files named ".foo" and ".bar",
> } > then type "." and press tab, are "." and ".." really what you want to
> } > complete to?  Maybe there should be an option to complete to "." and
> } > ".." just like normal filenames, but I think the default should very
> } > definitely stay as being the current behaviour.
> } 
> } Right. This makes it configurable with the special-dirs style. Can
> } anyone think of a better name?
> 
> I'm dubious that '.' should ever be a completion by itself.  I really don't
> want to type `.<TAB>' and end up with `./' on the line -- but I can see the
> argument for wanting `..<TAB>' to behave that way.  Yes, it's exactly the
> same number of keystrokes to type the slash yourself instead of a tab, but
> habits are habits.
> 
> Completing '.' would be even more annoying with REC_EXACT.

I wasn't sure about `.' either, but if I remember correctly, in the
discussions about this in the time of compctl, there were people who
wanted to have the `.', too (with menu-completion and no_rec_exact
this probably makes more sense).

So, to hopefully make everyone satisfied, this patch allows the value
`..' for the special-dirs style to make it add only `..'.

Bye
 Sven

diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files	Mon Dec 13 14:40:00 1999
+++ Completion/Core/_path_files	Tue Dec 14 10:04:54 1999
@@ -226,16 +226,26 @@
       tmp2=( ${^tmp1}*(-/) )
       if [[ ! -o globdots && "$PREFIX" = .* ]]; then
         tmp2=( "$tmp2[@]" ${^tmp1}.*(-/) )
-	zstyle -t ":completion${curcontext}:paths" special-dirs &&
+	if zstyle -s ":completion${curcontext}:paths" special-dirs atmp; then
+	  if [[ "$atmp" = (yes|true|1|on) ]]; then
 	    tmp2=( "$tmp2[@]" . .. )
+	  elif [[ "$atmp" = .. ]]; then
+	    tmp2=( "$tmp2[@]" .. )
+          fi
+        fi
       fi
     else
       tmp2=( ${^tmp1}${^~pats} )
       if [[ ! -o globdots && "$PREFIX" = .* ]]; then
         tmp2=( "$tmp2[@]" ${^tmp1}.${^~pats} )
-        [[ "$sopt" = */* ]] &&
-	    zstyle -t ":completion${curcontext}:paths" special-dirs &&
+        if [[ "$sopt" = */* ]] &&
+	   zstyle -s ":completion${curcontext}:paths" special-dirs atmp; then
+	  if [[ "$atmp" = (yes|true|1|on) ]]; then
 	    tmp2=( "$tmp2[@]" . .. )
+	  elif [[ "$atmp" = .. ]]; then
+	    tmp2=( "$tmp2[@]" .. )
+          fi
+        fi
       fi
     fi
     tmp1=( "$tmp2[@]" )
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo	Mon Dec 13 14:39:40 1999
+++ Doc/Zsh/compsys.yo	Tue Dec 14 10:06:31 1999
@@ -1195,7 +1195,8 @@
 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.
+`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

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-12-14  9:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-13 13:39 two completion questions Sven Wischnowsky
1999-12-13 16:56 ` Bart Schaefer
1999-12-14  9:09 Sven Wischnowsky

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).