From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3903 invoked from network); 25 Nov 2005 10:25:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 25 Nov 2005 10:25:16 -0000 Received: (qmail 90137 invoked from network); 25 Nov 2005 10:25:10 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Nov 2005 10:25:10 -0000 Received: (qmail 10795 invoked by alias); 25 Nov 2005 10:25:04 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22027 Received: (qmail 10780 invoked from network); 25 Nov 2005 10:25:03 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 25 Nov 2005 10:25:03 -0000 Received: (qmail 89241 invoked from network); 25 Nov 2005 10:25:03 -0000 Received: from cluster-d.mailcontrol.com (HELO rly11d.srv.mailcontrol.com) (217.69.20.190) by a.mx.sunsite.dk with SMTP; 25 Nov 2005 10:25:01 -0000 Received: from exchange03.csr.com ([62.189.241.194]) by rly11d.srv.mailcontrol.com (MailControl) with ESMTP id jAPAOxDp023965 for ; Fri, 25 Nov 2005 10:25:00 GMT Received: from news01 ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 25 Nov 2005 10:27:45 +0000 Date: Fri, 25 Nov 2005 10:24:58 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: PATCH: newuser system Message-Id: <20051125102458.6e00e74f.pws@csr.com> In-Reply-To: <1051124182000.ZM30724@candle.brasslantern.com> References: <200511231113.jANBD95L013878@news01.csr.com> <1051124060054.ZM29995@candle.brasslantern.com> <20051124114211.1fc867ab.pws@csr.com> <1051124182000.ZM30724@candle.brasslantern.com> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 25 Nov 2005 10:27:45.0455 (UTC) FILETIME=[DFFCD3F0:01C5F1AA] X-Scanned-By: MailControl A-05-40-01 (www.mailcontrol.com) on 10.68.0.121 Bart Schaefer wrote: > Sorry, my obfuscation was incomplete. :-) > > PWD=$zd eval 'zdmsg=${(%):-%~}' I don't think that works... I think it's because the internal variable doesn't get set when you change PWD, rather PWD is set as a normal variable when you change directory. Trying this showed up another problem which I'll patch separately. > } [...] maybe I could set the initial [keymap] state to "Recommended" > } and the default so that it picks "bindkey -e" unless you explicitly > } tell it not to? > > Sounds like the right idea. This changes that, and also fixes the fact that actually if you didn't edit the recommended settings then they weren't saved. It also fixes the problem noticed by Wayne: if compinstall has been run and returned status 0, I assume there's nothing more to do. There are a few minor fixes, including skipping the initial explanatory screen if the user explicitly ran the function with the -f argument. Index: Functions/Newuser/zsh-newuser-install =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Newuser/zsh-newuser-install,v retrieving revision 1.3 diff -u -r1.3 zsh-newuser-install --- Functions/Newuser/zsh-newuser-install 24 Nov 2005 11:46:47 -0000 1.3 +++ Functions/Newuser/zsh-newuser-install 25 Nov 2005 10:15:16 -0000 @@ -56,6 +56,7 @@ install_state[history]=Recommended install_state[completion]=Recommended +install_state[bindkey]=Recommended # Don't save anything if interrupted. trap 'save=0' HUP INT QUIT @@ -344,6 +345,11 @@ displays=("${display_lines[@]}") outputs=("${output_lines[@]}") + if [[ -n ${states[(r)not yet saved]} ]]; then + # default should be installed, unless user says otherwise + (( changes++ )) + fi + while true; do clear print -r $1 @@ -531,7 +537,8 @@ # Also save any lines suitably marked to parsed_* and state_* # by rerunning __zni_parse_lines on each such line. for (( i = 1; i <= ${#output_lines}; i++ )); do - if [[ $state_lines[$i] = ("set but not saved"|"not to be saved") ]] + if [[ $state_lines[$i] = \ + ("set but not saved"|"not to be saved"|"not yet saved") ]] then __zni_parse_lines $state_lines[$i] $output_lines[$i] fi @@ -659,6 +666,15 @@ (vi) lines+=("bindkey -v") ;; + + (none) + ;; + + (*) + print -r "\ +*** Internal error: bad type $parsed_keymaps[main] for keymap ***" >&2 + read -k key'?--- Type a key in forlorn hope --- ' + ;; esac fi # Now bindings. @@ -753,8 +769,12 @@ ;; (2) - compinstall - install_state[completion]="Configured" + if compinstall; then + install_state[completion]="Configured" + # compinstall has done it's thing, so we don't need + # to write anything. + completion_lines=() + fi ;; (0) @@ -772,7 +792,7 @@ } __zni_bindkey_config() { - __zni_apply_defaults -B none "Change default editing configuration" + __zni_apply_defaults -B emacs "Change default editing configuration" if __zni_display_and_edit "Default editing configuration" \ "The keys in the shell's line editor can be made to behave either" \ @@ -838,53 +858,54 @@ fi -clear -print -r "This is the Z Shell configuration function for new users, $myname." +# skip initial screen if the function was deliberately run by the user. if [[ $1 != -f ]]; then - print -r "You are seeing this message because you have no zsh startup files + clear + print -r "This is the Z Shell configuration function for new users, $myname. +You are seeing this message because you have no zsh startup files (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory $zdmsg). This function can help you with a few settings that should -make your use of the shell easier." -fi +make your use of the shell easier. -print -r " You can: (q) Quit and do nothing. The function will be run again next time." -if [[ ! -f $zd/.zshrc ]]; then - print -r " + if [[ ! -f $zd/.zshrc ]]; then + print -r " (0) Exit, creating the file $zdmsg/.zshrc containing just a comment. That will prevent this function being run again." -fi -print -r " + fi + print -r " (1) Continue to main menu. " -read -k key$longprompt -print + read -k key$longprompt + print -case $key in - ([qQ]) - return 0 - ;; + case $key in + ([qQ]) + return 0 + ;; - (0) - print -r $msg >$zd/.zshrc - return 0 - ;; + (0) + print -r $msg >$zd/.zshrc + return 0 + ;; - (1) - ;; + (1) + ;; - (*) - print -r "Aborting." - if [[ $1 != -f ]]; then - print "The function will be run again next time. To prevent this, execute: + (*) + print -r "Aborting." + if [[ $1 != -f ]]; then + print "\ +The function will be run again next time. To prevent this, execute: touch $zdmsg/.zshrc" - fi - return 1 - ;; -esac + fi + return 1 + ;; + esac +fi while true; do clear @@ -903,7 +924,8 @@ print -r " the new completion system.\ ${install_state[completion]:+ ($install_state[completion].)} -(3) Configure how keys behave when editing command lines. +(3) Configure how keys behave when editing command lines.\ +${install_state[bindkey]:+ ($install_state[bindkey].)} (4) Pick some of the more common shell options. These are simple on or off switches controlling the shell's features. \ @@ -954,7 +976,7 @@ if (( save )); then if [[ -f $zd/.zshrc ]]; then cp $zd/.zshrc $zd/.zshrc.zni && - print -r "Copied old '$zdd/.zshrc' to '$zdd/.zshrc.zni'. + print -r "Copied old '$zdmsg/.zshrc' to '$zdmsg/.zshrc.zni'. " fi -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com