Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: dirs builtin



Bart wrote:

> On Feb 13,  9:36am, Oliver Kiddle wrote:
> }
> } I've not implemented -l which would expand tilde substitutions -
> } existing code for tilde expansions is mixed in with other
expansions 
> so
> } I'd have to either duplicate or pull apart existing code.
> 
> The dirstack entries are already stored expanded.  All you need to do

> is
> pass a flag through printdirstack() to fprintdir() to tell it to skip

> the
> finddir() call and just print the directory.

Thanks, I should have thought about that. This patch goes on top of the
previous one.

Oliver

--- Src/builtin.c      Sat Feb  2 16:29:08 2002
+++ Src/builtin.c      Tue Feb 19 21:57:46 2002
@@ -51,7 +51,7 @@
     BUILTIN("chdir", 0, bin_cd, 0, 2, BIN_CD, NULL, NULL),
     BUILTIN("continue", BINF_PSPECIAL, bin_break, 0, 1, BIN_CONTINUE,
NULL, NULL),
     BUILTIN("declare", BINF_TYPEOPTS | BINF_MAGICEQUALS |
BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFHLRTUZafghilrtux", NULL),
-    BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "cpv", NULL),
+    BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "clpv", NULL),
     BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmr",
NULL),
     BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL),
     BUILTIN("echo", BINF_PRINTOPTS | BINF_ECHOPTS, bin_print, 0, -1,
BIN_ECHO, "neE", "-"),
@@ -623,10 +623,16 @@
            fmt = "\n";
        else
            fmt = " ";
-       fprintdir(pwd, stdout);
+       if (ops['l'])
+           fputs(pwd, stdout);
+       else
+           fprintdir(pwd, stdout);
        for (node = firstnode(dirstack); node; incnode(node)) {
            printf(fmt, pos++);
-           fprintdir(getdata(node), stdout);
+           if (ops['l'])
+               fputs(getdata(node), stdout);
+           else
+               fprintdir(getdata(node), stdout);
        }
        unqueue_signals();
        putchar('\n');
--- Completion/Zsh/Command/_dirs	Tue Feb 19 22:36:24 2002
+++ Completion/Zsh/Command/_dirs	Tue Feb 19 22:38:10 2002
@@ -2,6 +2,7 @@
 
 _arguments -s \
   '(-)-c[clear the directory stack]' \
+  '(* -c)-l[display directory names in full]' \
   '(* -c)-v[display numbered list of directory stack]' \
   '(* -c)-p[display directory entries on per line]' \
   '(-)*:directory:_directories'
--- Doc/Zsh/builtins.yo Tue Feb 19 22:42:08 2002
+++ Doc/Zsh/builtins.yo Tue Feb 19 22:45:27 2002
@@ -201,7 +201,7 @@
 findex(dirs)
 cindex(directory stack, printing)
 xitem(tt(dirs) [ tt(-c) ] [ var(arg) ... ])
-item(tt(dirs) [ tt(-pv) ])(
+item(tt(dirs) [ tt(-lpv) ])(
 With no arguments, print the contents of the directory stack.
 Directories are added to this stack with the tt(pushd) command,
 and removed with the tt(cd) or tt(popd) commands.
@@ -212,6 +212,9 @@
 startitem()
 item(tt(-c))(
 clear the directory stack.
+)
+item(tt(-l))(
+print directory names in full instead of using of using tt(~)
expressions.
 )
 item(tt(-p))(
 print directory entries one per line.


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com



Messages sorted by: Reverse Date, Date, Thread, Author