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

Re: PATCH: update prompt themes



On Sat, 17 May 2008 18:35:10 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } -	functions[precmd]="${functions[precmd]//prompt_bart_precmd}"
> } +        precmd_functions[(r)prompt_*_precmd]=
> } +	precmd_functions=($precmd_functions)
> 
> I'm curious why the second assignment is necessary there.  Remove an
> empty element?  Couldn't you just do this?
> 
>     precmd_functions[(r)prompt_*_precmd]=()
> 
> Or perhaps better
> 
>     add-zsh-hook -D precmd 'prompt_*_precmd'

Yes, the latter is correct.  I missed that one when I updated to use
add-zsh-hook because it wasn't in the usual place.

> (Or do I misunderstand the -D option you added?)
> 
> }  	# Abuse the fg assoc to hold our selected colors ...
> } -	fg[%m]=$fg[${1:-red}]
> 
> Er, the fg assoc came from Functions/Misc/colors which you're no longer
> including, so it's no longer "abuse" to do this to the $fg that you've
> declared global in this same function.

Well, yes, but I didn't really want to fiddle too much with the
comments.

Index: Functions/Prompts/prompt_bart_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_bart_setup,v
retrieving revision 1.14
diff -u -r1.14 prompt_bart_setup
--- Functions/Prompts/prompt_bart_setup	17 May 2008 22:42:17 -0000	1.14
+++ Functions/Prompts/prompt_bart_setup	18 May 2008 16:10:39 -0000
@@ -151,8 +151,7 @@
     # A few extra niceties ...
     repeat 1 case "$1:l" in
       (off|disable)
-        precmd_functions[(r)prompt_*_precmd]=
-	precmd_functions=($precmd_functions)
+        add-zsh-hook -D precmd "prompt_*_precmd"
 	functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch}"
 	[[ $prompt_theme[1] = bart ]] && PS1=${${(f)PS1}[-1]}
 	return 1
@@ -162,7 +161,10 @@
 	[[ $prompt_theme[1] = bart ]] && break
 	;&
       (*)
-	# Abuse the fg assoc to hold our selected colors ...
+	# Use the fg assoc to hold our selected colors ...
+	# This used to be provided by the function colors, but is now
+	# set directly from here.  There should be no clash if both
+	# are in use.
 	fg[%m]="%F{${1:-red}}"
 	fg[%h]="%F{${2:-blue}}"
 	fg[%~]="%F{${3:-default}}"


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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