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

PATCH: misc cleanup



Some cleanup (or what I call cleanup).

Note the lines marked with a `*', I'd like to have these changes made...

- change the comments in the header files (as mentioned by Bart)
- change `zmodload' in a static shell:
  - without the `e' option the arguments are take as module names and
    tested if they are available; if not, an error is signaled
  - the `-i' option is ignored in this case
  - (yes, I have tried it with a non-dynamic shell)
  - something more clever with the delayed initialisation stuff
    mentioned by Bart has to wait a bit (and maybe we first should try 
    to agree upon what exactly we want, and how, and...)
- some cleanup in the completion functions
  - the code from `_job' is moved into `_jobs' which is a better name
    anyway
  - I changed some uses of `_files' to not use `-/g' any more; I'm
    optimistic that we will have more sophisticated grouping/priority
    possibilities in the near future; then we'll want to have them
    more consistent anyway
* - the file `Base/_job' should be removed now
* - and the file `Builtins/_jobs' should be moved into `Base'; the
    `#compdef' line from it is moved into `_fg_jobs' (brother of
    `_bg_jobs'), but `_jobs' itself is used by `Base/_command_names'
* - `Core/_display' can be removed, too -- it isn't used anymore,
    replaced by `compdisplay' from the computil module

Ok. That's all for now...

Bye
 Sven

diff -u -r oldsrc/Zle/comp.h Src/Zle/comp.h
--- oldsrc/Zle/comp.h	Wed Nov  3 10:25:40 1999
+++ Src/Zle/comp.h	Wed Nov  3 10:27:21 1999
@@ -1,5 +1,5 @@
 /*
- * complete.h - header file for completion
+ * comp.h - header file for completion
  *
  * This file is part of zsh, the Z shell.
  *
diff -u -r oldsrc/Zle/compctl.h Src/Zle/compctl.h
--- oldsrc/Zle/compctl.h	Wed Nov  3 10:25:40 1999
+++ Src/Zle/compctl.h	Wed Nov  3 10:27:32 1999
@@ -1,5 +1,5 @@
 /*
- * comp.h - header file for completion
+ * compctl.h - header file for completion
  *
  * This file is part of zsh, the Z shell.
  *
diff -u -r oldsrc/builtin.c Src/builtin.c
--- oldsrc/builtin.c	Wed Nov  3 10:25:35 1999
+++ Src/builtin.c	Wed Nov  3 10:32:04 1999
@@ -127,7 +127,7 @@
 #ifdef DYNAMIC
     BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ILabcfdipue", NULL),
 #else
-    BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "e", NULL),
+    BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ei", NULL),
 #endif
 };
 
diff -u -r oldsrc/module.c Src/module.c
--- oldsrc/module.c	Wed Nov  3 10:25:37 1999
+++ Src/module.c	Wed Nov  3 10:37:10 1999
@@ -1251,9 +1251,9 @@
 int
 bin_zmodload(char *nam, char **args, char *ops, int func)
 {
-    /* We understand only the -e option. */
+    /* We understand only the -e option (and ignore -i). */
 
-    if (ops['e']) {
+    if (ops['e'] || *args) {
 	LinkNode node;
 
 	if (!*args) {
@@ -1261,13 +1261,19 @@
 		nicezputs((char *) getdata(node), stdout);
 		putchar('\n');
 	    }
-	    return 0;
 	} else {
-	    for (; *args; args++)
+	    for (; *args; args++) {
 		for (node = firstnode(bltinmodules); node; incnode(node))
 		    if (!strcmp(*args, (char *) getdata(node)))
-			return 0;
+			break;
+		if (!node) {
+		    if (!ops['e'])
+			zerrnam(nam, "cannot load module: `%s'", *args, 0);
+		    return 1;
+		}
+	    }
 	}
+	return 0;
     }
     /* Otherwise we return 1 -- different from the dynamic version. */
     return 1;
diff -u olddoc/Zsh/builtins.yo Doc/Zsh/builtins.yo
--- olddoc/Zsh/builtins.yo	Wed Nov  3 10:26:21 1999
+++ Doc/Zsh/builtins.yo	Wed Nov  3 10:38:26 1999
@@ -1400,10 +1400,10 @@
 enditem()
 
 In a shell without dynamic loading only the tt(-e) option is
-supported. In such a shell the return status of tt(zmodload) without
-arguments or options is one whereas in a shell with dynamic loading
-the return status without arguments or options is always zero. This
-can be used to test if the shell supports dynamic loading of modules
-or not.
+supported and the tt(-i) option is ignored. In such a shell the return
+status of tt(zmodload) without arguments or options is one whereas in
+a shell with dynamic loading the return status without arguments or
+options is always zero. This can be used to test if the shell supports
+dynamic loading of modules or not.
 )
 enditem()
diff -u -r oldcompletion/Base/_command_names Completion/Base/_command_names
--- oldcompletion/Base/_command_names	Wed Nov  3 10:25:15 1999
+++ Completion/Base/_command_names	Wed Nov  3 11:04:14 1999
@@ -15,7 +15,7 @@
 
 # Complete jobs in implicit fg and bg
 if [[ -z "$ext" && "$PREFIX[1]" = "%" ]]; then
-  _job -P '%'
+  _jobs
   [[ nm -ne compstate[nmatches] ]] && return
 fi
 
diff -u -r oldcompletion/Builtins/_bg_jobs Completion/Builtins/_bg_jobs
--- oldcompletion/Builtins/_bg_jobs	Wed Nov  3 10:25:17 1999
+++ Completion/Builtins/_bg_jobs	Wed Nov  3 11:04:14 1999
@@ -1,3 +1,3 @@
 #compdef bg
 
-_job -s -P '%'
+_jobs -s
diff -u -r oldcompletion/Builtins/_fg_jobs Completion/Builtins/_fg_jobs
--- oldcompletion/Builtins/_fg_jobs	Wed Nov  3 11:15:00 1999
+++ Completion/Builtins/_fg_jobs	Wed Nov  3 11:15:28 1999
@@ -0,0 +1,3 @@
+#compdef disown fg jobs
+
+_jobs
diff -u -r oldcompletion/Builtins/_hash Completion/Builtins/_hash
--- oldcompletion/Builtins/_hash	Wed Nov  3 10:25:19 1999
+++ Completion/Builtins/_hash	Wed Nov  3 11:04:14 1999
@@ -10,7 +10,8 @@
     compadd "$expl[@]" -q -S '=' - "${(@k)nameddirs}"
   fi
 elif compset -P 1 '*\='; then
-  _files -/g '*(*)'
+  _description expl 'executable file'
+  _files "$expl[@]" -g '*(*)'
 else
   _description expl command
   compadd "$expl[@]" -q -S '=' - "${(@k)commands}"
diff -u -r oldcompletion/Builtins/_jobs Completion/Builtins/_jobs
--- oldcompletion/Builtins/_jobs	Wed Nov  3 10:25:19 1999
+++ Completion/Builtins/_jobs	Wed Nov  3 11:15:34 1999
@@ -1,3 +1,27 @@
-#compdef disown fg jobs
+#autoload
+
+local expl disp jobs job jids
+
+if [[ "$1" = -r ]]; then
+  jids=( "${(@k)jobstates[(R)running*]}" )
+  shift
+  _description expl 'running job'
+elif [[ "$1" = -s ]]; then
+  jids=( "${(@k)jobstates[(R)running*]}" )
+  shift
+  _description expl 'suspended job'
+else
+  [[ "$1" = - ]] && shift
+  jids=( "${(@k)jobtexts}" )
+  _description expl job
+fi
+
+disp=()
+jobs=()
+for job in "$jids[@]"; do
+  disp=( "$disp[@]" "${(l:3:: ::%:)job} -- ${jobtexts[$job]}" )
+  jobs=( "$jobs[@]" "$job" )
+done
+
+compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]"
 
-_job -P '%'
diff -u -r oldcompletion/Builtins/_kill Completion/Builtins/_kill
--- oldcompletion/Builtins/_kill	Wed Nov  3 10:25:19 1999
+++ Completion/Builtins/_kill	Wed Nov  3 11:03:00 1999
@@ -8,7 +8,7 @@
 else
   local ret=1
 
-  _job && ret=0
+  _jobs && ret=0
 
   list=("${(@M)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*}")
   _description expl 'process ID'
diff -u -r oldcompletion/Builtins/_wait Completion/Builtins/_wait
--- oldcompletion/Builtins/_wait	Wed Nov  3 10:25:20 1999
+++ Completion/Builtins/_wait	Wed Nov  3 11:03:07 1999
@@ -2,7 +2,7 @@
 
 local list ret=1 expl
 
-_job -P '%' && ret=0
+_jobs && ret=0
 
 list=("${(@M)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*}")
 _description expl 'process ID'
diff -u -r oldcompletion/User/_gdb Completion/User/_gdb
--- oldcompletion/User/_gdb	Wed Nov  3 10:25:27 1999
+++ Completion/User/_gdb	Wed Nov  3 11:04:15 1999
@@ -1,8 +1,5 @@
 #compdef gdb
 
-# This uses the configuration keys `ps_args' and `ps_listargs'
-# described in the `_wait' function.
-
 local cur="$words[CURRENT]" prev w list ret=1 expl
 
 [[ "$PREFIX" = --* ]] &&
@@ -17,7 +14,7 @@
   compadd "$expl[@]" - /dev/tty*
 elif compset -P '-(exec|se)='; then
   _description expl executable
-  _files "$expl[@]" -/g '*(*)'
+  _files "$expl[@]" -g '*(*)'
 elif compset -P '-(symbols|core|command)='; then
   _files
 elif [[ "$PREFIX" = -* ]]; then
@@ -33,7 +30,7 @@
   (-d) _files -/ && return 0 ;;
   (-[csx]) _files && return 0 ;;
   (-e) _description expl executable
-       _files "$expl[@]" -/g '*(*)' && return 0 ;;
+       _files "$expl[@]" -g '*(*)' && return 0 ;;
   (-b) _description -V expl 'baud rate'
        compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
                           9600 19200 38400 57600 115200 230400 && return 0 ;;
@@ -53,6 +50,6 @@
     return ret
   else
     _description expl executable
-    _files "$expl[@]" -/g '*(*)'
+    _files "$expl[@]" -g '*(*)'
   fi
 fi
diff -u -r oldcompletion/User/_perldoc Completion/User/_perldoc
--- oldcompletion/User/_perldoc	Wed Nov  3 10:25:30 1999
+++ Completion/User/_perldoc	Wed Nov  3 11:04:15 1999
@@ -21,7 +21,7 @@
   _perl_basepods
 
   _description expl 'Perl modules and .pods'
-  _path_files "$expl[@]"  -/ -g '*.(pod|pm)'
+  _files "$expl[@]"  -g '*.(pod|pm)'
 
   [[ nm -ne "$compstate[nmatches]" ]]
 }

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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