From 5e2a1cf4cc261d9b9c6f9dea5a53983e04afe275 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Tue, 31 May 2011 19:07:06 +0000 Subject: Jan Pobrislo: 29411: vcs_info: Major bzr backend update. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr | 89 +++++++++++++++++++++-- 1 file changed, 83 insertions(+), 6 deletions(-) (limited to 'Functions') diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr index 5d4deaac9..cae1a3b08 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr @@ -1,13 +1,52 @@ -## vim:ft=zsh +## vim:ft=zsh et ## bazaar support by: Frank Terbeck +## mostly rewritten by: Jan Pobrislo ## Distributed under the same BSD-ish license as zsh itself. setopt localoptions noksharrays extendedglob NO_shwordsplit -local bzrbase bzrbr +local bzrbase bzrbr bzr_changes bzr_type local -a bzrinfo -local -xA hook_com +local -xA hook_com bzr_info + +VCS_INFO_bzr_get_info() { + bzrinfo=( ${(s.:.)$( ${vcs_comm[cmd]} version-info --custom \ + --template="{revno}:{branch_nick}:{clean}")} ) + if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" + then + VCS_INFO_bzr_get_changes + elif [[ ${bzrinfo[2]} == 1 ]] + then + bzr_changes = '1' + fi +} + +VCS_INFO_bzr_get_info_restricted() { + # we are forbidden from fetching info on bound branch from remote repository + bzrinfo=( $(${vcs_comm[cmd]} revno) ${bzrbase:t} ) + if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" && \ + [[ ! $bzr_type == lightweigth ]] + then + VCS_INFO_bzr_get_changes + fi +} + +VCS_INFO_bzr_get_changes() { + local -A counts + local line flag + bzr_changes=$( + ${vcs_comm[cmd]} stat -SV | while read flag line + do + counts[${flag}]=$(( ${counts[${flag}]:-0} + 1 )) + done + for flag in ${(k)counts} + do + printf "%s:%d " $flag ${counts[${flag}]} + done + ) +} if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then + # simple parsing will fail to fetch information from lightweigth checkouts bzrbase=${vcs_comm[basedir]} bzrinfo[2]=${bzrbase:t} if [[ -f ${bzrbase}/.bzr/branch/last-revision ]] ; then @@ -15,9 +54,46 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then bzrinfo[1]=${${bzrinfo[1]}%% *} fi else - bzrbase=${${(M)${(f)"$( ${vcs_comm[cmd]} info )"}:# ##branch\ root:*}/*: ##/} - bzrinfo=( ${${${(M)${(f)"$( ${vcs_comm[cmd]} version-info )"}:#(#s)(revno|branch-nick)*}/*: /}/*\//} ) + # Parse the output of 'bzr info' into associative array bzr_info + ${vcs_comm[cmd]} info | { + local line key value dirtype + read dirtype + grep '^[ a-zA-Z0-9]\+: ' | while read line + do + value=${line#*': '} + key=${${line%%: *}// /_} + bzr_info[$key]=$value + done + } + + case "$dirtype" in + ('Checkout'*) + bzr_type=checkout + bzrbase=${bzr_info[checkout_root]} ;; + ('Repository checkout'*) + bzr_type=checkout + bzrbase=${bzr_info[repository_checkout_root]} ;; + ('Lightweight checkout'*) + bzr_type=lightweigth + bzrbase=${bzr_info[light_checkout_root]} ;; + (*) + bzr_type=standalone + bzrbase=${bzr_info[branch_root]} ;; + esac + bzrbase="$(VCS_INFO_realpath ${bzrbase})" + + if [ -n "${bzr_info[checkout_of_branch]}" ] && \ + zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-server" + then + VCS_INFO_bzr_get_info + else + case ${bzr_info[checkout_of_branch]} in + (file://*) VCS_INFO_bzr_get_info ;; + (*://*) VCS_INFO_bzr_get_info_restricted ;; + (*) VCS_INFO_bzr_get_info ;; + esac + fi fi rrn=${bzrbase:t} @@ -29,5 +105,6 @@ else bzrbr=${hook_com[branch-replace]} fi hook_com=() -VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' '' "${bzrinfo[1]}" '' + +VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' "${bzr_changes}" "${bzrinfo[1]}" "${bzr_changes}" return 0 -- cgit v1.2.3 From 0cc65dba531a792db26592a4e9c1efe5f9f667bd Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Wed, 1 Jun 2011 15:30:20 +0000 Subject: users/16064: example widget for line motion inside multiline buffers without navigating history --- ChangeLog | 5 ++++- Functions/Zle/move-line-in-buffer | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Functions/Zle/move-line-in-buffer (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index e938d66cd..eb64cd4cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-06-01 Barton E. Schaefer + * users/16064: Functions/Zle/move-line-in-buffer: example widget + for moving in multiline buffers without navigating history + * 29416 (plus typo fixes): Doc/Zsh/contrib.yo: Fix (mis-)uses of var() in vcs_info documentation. @@ -14909,5 +14912,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5351 $ +* $Revision: 1.5352 $ ***************************************************** diff --git a/Functions/Zle/move-line-in-buffer b/Functions/Zle/move-line-in-buffer new file mode 100644 index 000000000..1a0efd9ca --- /dev/null +++ b/Functions/Zle/move-line-in-buffer @@ -0,0 +1,16 @@ +#autoload + +# Line motions that do not leave the current history entry, +# for editing in multi-line buffers. + +# To use: +# autoload -Uz move-line-in-buffer +# zle -N up-line-in-buffer move-line-in-buffer +# zle -N down-line-in-buffer move-line-in-buffer +# +# then bindkey as you prefer + +local hno=$HISTNO curs=$CURSOR +zle .${WIDGET:s/in-buffer/or-history} "$@" && +    (( HISTNO != hno && (HISTNO=hno, CURSOR=curs) )) +return 0 -- cgit v1.2.3 From c0d2cb5d025290efd0301bce4ddb7ad23c129eae Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Sun, 5 Jun 2011 05:40:53 +0000 Subject: fix whitespace in Functions/Zle/move-line-in-buffer --- ChangeLog | 7 ++++++- Functions/Zle/move-line-in-buffer | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index d2dab008a..45faa0016 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-06-05 Clint Adams + + * unposted: Functions/Zle/move-line-in-buffer: clean + the funny characters out of move-line-in-buffer. + 2011-06-04 Peter Stephenson * Completion/Zsh/Context/_brace_parameter, Src/Zle/compcore.c @@ -14958,5 +14963,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5362 $ +* $Revision: 1.5363 $ ***************************************************** diff --git a/Functions/Zle/move-line-in-buffer b/Functions/Zle/move-line-in-buffer index 1a0efd9ca..5f37a9d71 100644 --- a/Functions/Zle/move-line-in-buffer +++ b/Functions/Zle/move-line-in-buffer @@ -12,5 +12,5 @@ local hno=$HISTNO curs=$CURSOR zle .${WIDGET:s/in-buffer/or-history} "$@" && -    (( HISTNO != hno && (HISTNO=hno, CURSOR=curs) )) + (( HISTNO != hno && (HISTNO=hno, CURSOR=curs) )) return 0 -- cgit v1.2.3 From 525d0adf1588fd88c3365e626da0bd06a304ef32 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 8 Jun 2011 17:19:12 +0000 Subject: Jeremy Sylvestre: 29468: add some ligatures and symbols to composed characters --- ChangeLog | 7 ++++- Functions/Zle/define-composed-chars | 58 ++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 4777dde22..b6a31cf39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-06-08 Peter Stephenson + + * Jeremy Sylvestre: 29468: Functions/Zle/define-composed-chars: + add some ligatures and symbols. + 2011-06-06 Peter Stephenson * 29462: Src/subst.c: fix warning with some compilers (code was @@ -14975,5 +14980,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5365 $ +* $Revision: 1.5366 $ ***************************************************** diff --git a/Functions/Zle/define-composed-chars b/Functions/Zle/define-composed-chars index 12a357fc1..15d693a3f 100644 --- a/Functions/Zle/define-composed-chars +++ b/Functions/Zle/define-composed-chars @@ -135,6 +135,26 @@ a=j z[$a]="\ i 133 \ " +# ligature with f +a=f +z[$a]="\ +f FB00 \ +" +# ligature with i +a=i +z[$a]="\ +f FB01 \ +" +# ligature with l +a=l +z[$a]="\ +f FB02 \ +" +# ligature with t +a=t +z[$a]="\ +f FB05 s FB06 \ +" # eszett a=s z[$a]="\ @@ -252,6 +272,19 @@ z[$a]+=" Z 5e6" a=h z[$a]+=" S 5e9" +# Superscripts +a=S +z[$a]+=" \ +0 2070 1 B9 2 B2 3 B3 4 2074 5 2075 6 2076 7 2077 8 2078 9 2079 \ ++ 207a - 207b = 207C ( 207D ) 207E n 207f \ +" +# Subscripts +a=s +z[$a]+=" \ +0 2080 1 2081 2 2082 3 2083 4 2084 5 2085 6 2086 7 2087 8 2088 9 2089 \ ++ 208a - 208b = 208C ( 208D ) 208E \ +" + typeset -i 16 -Z 4 ia typeset -i 16 -Z 6 iuni # Extended width characters ^A, ^B, ... (not RFC1345) @@ -327,10 +360,14 @@ z[g]+=" R AE" z[m]+=" ' AF" # degree z[G]+=" D B0" +# degree centigrade +z[C]+=" o 2103" +# degree fahrenheit +z[F]+=" o 2109" +# numero +z[0]+=" N 2116" # +/- z[-]+=" + B1" -# superscripts -z[S]+=" 2 B2 3 B3" # lonely acute a=\' z[$a]+=" ' B4" @@ -342,8 +379,6 @@ z[I]+=" P B6" z[M]+=" . B7" # Lonely cedilla z[,]+=" ' B8" -# Superscript one -z[S]+=" 1 B9" # spanish masculine ordinal z[o]+=" - BA" # right guillemet @@ -415,5 +450,20 @@ z[0]+=" 0 221E" # Female and male z[m]+=" F 2640" z[l]+=" M 2642" +# Commercial AT +z[t]+=" A 40" +# Prime, double prime, triple prime +a=\' +z[$a]+=" 1 2032 2 2033 3 2034" +# Arrows +z[-]+=" < 2190" +a=\! +z[$a]+=" - 2191" +a=\> +z[$a]+=" - 2192 < 2194 = 21D2" +z[v]+=" - 2193" +z[D]+=" U 2195" +a=\= +z[$a]+=" < 21D0 = 21D4" zsh_accented_chars=("${(kv)z[@]}") -- cgit v1.2.3 From f028b97e8f0c7906af4a76909436e9a7f5a06d8a Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Thu, 30 Jun 2011 07:43:53 +0000 Subject: 29526: vcs_info: Set `max-exports' early after certain `start-up' hooks. --- ChangeLog | 7 ++++++- Functions/VCS_Info/vcs_info | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 300400632..17f7db40a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-06-30 Frank Terbeck + + * 29526: Functions/VCS_Info/vcs_info: Set `max-exports' early + after certain `start-up' hooks. + 2011-06-28 Frank Terbeck * Sebastian Ramacher: 29513: Completion/Debian/Command/_apt: Add @@ -15052,5 +15057,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5382 $ +* $Revision: 1.5383 $ ***************************************************** diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 513489b70..5a421dfed 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -70,6 +70,9 @@ vcs_info () { if (( retval == 1 )); then return 0 elif (( retval == 2 )); then + # This needs `max-exports' set. We're still setting it again later + # for more specific contexts. + VCS_INFO_maxexports VCS_INFO_set --nvcs return 0 fi -- cgit v1.2.3 From 4a3ce8ab89c73f88559d9c48fdb4ed459a8aceef Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 3 Aug 2011 20:57:32 +0000 Subject: 29644: work around _describe bug, plus cosmetic tweaks --- ChangeLog | 6 +++++- Functions/Chpwd/zsh_directory_name_cdr | 2 +- Src/Zle/compcore.c | 3 ++- Src/Zle/zle_tricky.c | 13 ++++++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index c6209fca0..dfc2b987e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-08-03 Peter Stephenson + * 29644: Functions/Chpwd/zsh_directory_name_cdr, + Src/Zle/compcore.c, Src/Zle/zle_tricky.c: Work round a bug in + _describe, plus a new comment and some more braces. + * 29633: Doc/Zsh/func.yo, Src/parse.c, Test/C04funcdef.ztst: be more careful that anonymous function syntax doesn't mess up working syntax with other functions. @@ -15195,5 +15199,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5414 $ +* $Revision: 1.5415 $ ***************************************************** diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr index 09aa35a93..c9be7db0c 100644 --- a/Functions/Chpwd/zsh_directory_name_cdr +++ b/Functions/Chpwd/zsh_directory_name_cdr @@ -18,7 +18,7 @@ elif [[ $1 = c ]]; then values=(${${(f)"$(cdr -l)"}/ ##/:}) keys=(${values%%:*}) _describe -t dir-index 'recent directory index' \ - values keys -V unsorted -S']' + values -V unsorted -S']' return fi fi diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 2e2749835..b1de6c6cc 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -607,7 +607,7 @@ callcompfunc(char *s, char *fn) if (rdstr) compredirect = rdstr; kset |= CP_REDIRECT; - } else + } else { switch (linwhat) { case IN_ENV: compcontext = (linarr ? "array_value" : "value"); @@ -637,6 +637,7 @@ callcompfunc(char *s, char *fn) aadd = 1; } } + } compcontext = ztrdup(compcontext); if (compwords) freearray(compwords); diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 19787f9ff..999b2b7be 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -398,7 +398,18 @@ mod_export char *cmdstr; /**/ mod_export char *varname; -/* != 0 if we are in a subscript */ +/* + * != 0 if we are in a subscript. + * Of course, this being the completion code, you're expected to guess + * what the different numbers actually mean, but here's a cheat: + * 1: Key of an ordinary array + * 2: Key of a hash + * 3: Ummm.... this appears to be a special case of 2. After a lot + * of uncommented code looking for groups of brackets, we suddenly + * decide to set it to 2. The only upshot seems to be that compctl + * then doesn't add a matching ']' at the end, so I think it means + * there's one there already. + */ /**/ mod_export int insubscr; -- cgit v1.2.3 From 20c52f622154ed00fac8ed3cf6416e955551d372 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 14 Aug 2011 13:40:53 +0000 Subject: 28852: Use syntax that doesn't depend on SHORT_LOOPS being set. --- ChangeLog | 5 ++++- Functions/Misc/zargs | 4 ++-- Functions/Zle/match-words-by-style | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 5b71d978c..e1cbeaa84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * 29673: Doc/Zsh/compsys.yo: Clarify what 'other' in the ignore-line style does. + * 28852: Misc/zargs, Zle/match-words-by-style: Use syntax that doesn't + depend on SHORT_LOOPS being set. + 2011-08-11 Peter Stephenson * Src/Modules/datetime.mdd: unposted: also fix the autofeatures. @@ -15239,5 +15242,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5423 $ +* $Revision: 1.5424 $ ***************************************************** diff --git a/Functions/Misc/zargs b/Functions/Misc/zargs index 58d84617e..8350b1aba 100644 --- a/Functions/Misc/zargs +++ b/Functions/Misc/zargs @@ -207,7 +207,7 @@ then else call=($command) # Use "repeat" here so "continue" won't complain. - repeat 1 eval "$execute ; $analyze" + repeat 1; do eval "$execute ; $analyze"; done return $ret fi fi @@ -273,7 +273,7 @@ do repeat $P do ((ARGC)) || break - for (( end=l; end && ${(c)#argv[1,end]} > s; end/=2 )) : + for (( end=l; end && ${(c)#argv[1,end]} > s; end/=2 )) { } (( end > n && ( end = n ) )) args=( $argv[1,end] ) shift $((end > ARGC ? ARGC : end)) diff --git a/Functions/Zle/match-words-by-style b/Functions/Zle/match-words-by-style index 69ceba76a..b387828f3 100644 --- a/Functions/Zle/match-words-by-style +++ b/Functions/Zle/match-words-by-style @@ -220,8 +220,7 @@ if [[ $wordstyle = *subword* ]]; then fi match=() -charskip= -repeat $skip charskip+=\? +charskip=${(l:skip::?:)} eval pat2='${RBUFFER##(#b)('${charskip}${spacepat}')('\ ${wordpat2}')('${spacepat}')}' -- cgit v1.2.3 From fdcabaf507ba1dd41fe1345f15989623c941ba31 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Thu, 18 Aug 2011 02:23:31 +0000 Subject: Use preexec hook to replace "fg" et al. with the jobtext of the resumed job. --- Functions/Prompts/prompt_bart_setup | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'Functions') diff --git a/Functions/Prompts/prompt_bart_setup b/Functions/Prompts/prompt_bart_setup index 1cc7b6f08..a264cdce1 100644 --- a/Functions/Prompts/prompt_bart_setup +++ b/Functions/Prompts/prompt_bart_setup @@ -67,15 +67,38 @@ prompt_bart_help () { } integer PSCOL=1 +typeset PSCMD= + +prompt_bart_preexec () { + setopt localoptions noxtrace noksharrays unset + local -a cmd; cmd=( ${(z)3} ) + if [[ $cmd[1] = fg ]] + then + shift cmd + cmd[1]=${cmd[1]:-%+} + fi + if [[ $#cmd -eq 1 && $cmd[1] = %* ]] + then + PSCMD=$jobtexts[$cmd[1]] + elif [[ -o autoresume && -n $jobtexts[%?$2] ]] + then + PSCMD=$jobtexts[%?$2] + else + PSCMD=$2 + fi + return 0 +} prompt_bart_precmd () { setopt localoptions noxtrace noksharrays unset local zero='%([BSUbfksu]|[FB]{*})' escape colno lineno + : "${PSCMD:=$history[$[HISTCMD-1]]}" # Default to history text + # Using psvar here protects against unwanted promptsubst expansions. - psvar[7]="$history[$[HISTCMD-1]]" # Use history text, not just number - psvar[8]='' # No padding until we compute it + psvar[7]="$PSCMD" + psvar[8]='' # No padding until we compute it psvar[9]=() typeset -g PSCOL @@ -153,6 +176,7 @@ prompt_bart_setup () { repeat 1 case "$1:l" in (off|disable) add-zsh-hook -D precmd "prompt_*_precmd" + add-zsh-hook -D preexec "prompt_*_preexec" functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch}" [[ $prompt_theme[1] = bart ]] && PS1=${${(f)PS1}[-1]} return 1 @@ -182,6 +206,7 @@ prompt_bart_setup () { # Paste our special commands into precmd and TRAPWINCH add-zsh-hook precmd prompt_bart_precmd + add-zsh-hook preexec prompt_bart_preexec functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch} prompt_bart_winch" -- cgit v1.2.3 From c4beabbc643d5cea4f1a54ecc65fe82d25175d56 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sat, 20 Aug 2011 18:39:24 +0000 Subject: Belatedly add move-line-in-buffer. --- ChangeLog | 6 ++++-- Functions/Zle/.distfiles | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 315083080..9183dc348 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ -2011-08-20 Barton E. Schaefer +2011-08-20 Barton E. Schaefer + + * unposted: Functions/Zle/.distfiles: add move-line-in-buffer * 29711: Completion/compaudit: avoid calling potentially-slow "getent group" unless group-writable directories are found. @@ -15328,5 +15330,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5444 $ +* $Revision: 1.5445 $ ***************************************************** diff --git a/Functions/Zle/.distfiles b/Functions/Zle/.distfiles index 22eef1e6e..256044fa5 100644 --- a/Functions/Zle/.distfiles +++ b/Functions/Zle/.distfiles @@ -25,6 +25,7 @@ kill-word-match match-word-context match-words-by-style modify-current-argument +move-line-in-buffer narrow-to-region narrow-to-region-invisible predict-on -- cgit v1.2.3 From 557baa173c6be93e475d6e25d3fb0c80164d6e87 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Mon, 29 Aug 2011 16:08:28 +0000 Subject: users/16291: prompt_bart_preexec uses history text in the non-"fg" case to avoid alias expansion. --- ChangeLog | 7 ++++++- Functions/Prompts/prompt_bart_setup | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 0bd63d991..5c800d16b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-08-29 Barton E. Schaefer + + * users/16291: Functions/Prompts/prompt_bart_setup: revert to + using history text in non-"fg" case to avoid alias expansion. + 2011-08-29 Mikael Magnusson * 29722: Completion/X/Command/_mplayer: escape colon. @@ -15344,5 +15349,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5448 $ +* $Revision: 1.5449 $ ***************************************************** diff --git a/Functions/Prompts/prompt_bart_setup b/Functions/Prompts/prompt_bart_setup index a264cdce1..6cbbb71c7 100644 --- a/Functions/Prompts/prompt_bart_setup +++ b/Functions/Prompts/prompt_bart_setup @@ -70,7 +70,7 @@ integer PSCOL=1 typeset PSCMD= prompt_bart_preexec () { - setopt localoptions noxtrace noksharrays unset + setopt localoptions noxtrace noshwordsplit noksharrays unset local -a cmd; cmd=( ${(z)3} ) if [[ $cmd[1] = fg ]] then @@ -84,7 +84,8 @@ prompt_bart_preexec () { then PSCMD=$jobtexts[%?$2] else - PSCMD=$2 + # Use history text to avoid alias expansion + PSCMD=$history[$HISTCMD] fi return 0 } -- cgit v1.2.3 From a6e039e12e5b9e480b876971ff644c3180efb2bc Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 4 Nov 2011 14:31:23 +0000 Subject: 29892: fix regular expression replacements in replace-string improve variable save and restore in read-from-minibuffer --- ChangeLog | 7 ++++++- Functions/Zle/read-from-minibuffer | 35 +++++++++++------------------------ Functions/Zle/replace-string-again | 6 ++++-- 3 files changed, 21 insertions(+), 27 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index d2a18fd80..8eda2f415 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2011-11-04 Peter Stephenson + * 29892: Functions/Zle/read-from-minibuffer, + Functions/Zle/replace-string: fix regular expression + replacements right of the cursor; make save and restore + in read-from-minibuffer more automated. + * 29891: Doc/Zsh/zle.yo, Src/Zle/zle_thingy.c: allow "zle -lL" with arguments to list in -L format. @@ -15538,5 +15543,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5492 $ +* $Revision: 1.5493 $ ***************************************************** diff --git a/Functions/Zle/read-from-minibuffer b/Functions/Zle/read-from-minibuffer index fce6b5319..57e926884 100644 --- a/Functions/Zle/read-from-minibuffer +++ b/Functions/Zle/read-from-minibuffer @@ -19,26 +19,19 @@ while getopts "k:" opt; do done (( OPTIND > 1 )) && shift $(( OPTIND - 1 )) +local readprompt="$1" lbuf_init="$2" rbuf_init="$3" + +# Use anonymous function to make sure special values get restored, +# even if this function is called as a widget. +# local +h ensures special parameters stay special. +() { local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY " -# We could use the local variables mechanism to save these -# values, but if read-from-minibuffer is called as a widget -# (which isn't actually all that useful) the values won't be -# restored because the variables are already local at the current -# level and don't get restored when they go out of scope. -# We could do it with an additional function level. - local save_lbuffer=$LBUFFER - local save_rbuffer=$RBUFFER - local save_predisplay=$PREDISPLAY - local save_postdisplay=$POSTDISPLAY - local -a save_region_highlight - save_region_highlight=("${region_highlight[@]}") - -{ - LBUFFER="$2" - RBUFFER="$3" - PREDISPLAY="$pretext${1:-? }" - POSTDISPLAY= + local +h LBUFFER="$lbuf_init" + local +h RBUFFER="$rbuf_init" + local +h PREDISPLAY="$pretext${readprompt:-? }" + local +h POSTDISPLAY= + local +h -a region_highlight region_highlight=("P${#pretext} ${#PREDISPLAY} bold") if [[ -n $keys ]]; then @@ -50,12 +43,6 @@ done stat=$? (( stat )) || REPLY=$BUFFER fi -} always { - LBUFFER=$save_lbuffer - RBUFFER=$save_rbuffer - PREDISPLAY=$save_predisplay - POSTDISPLAY=$save_postdisplay - region_highlight=("${save_region_highlight[@]}") } return $stat diff --git a/Functions/Zle/replace-string-again b/Functions/Zle/replace-string-again index f24c14f88..dac3db755 100644 --- a/Functions/Zle/replace-string-again +++ b/Functions/Zle/replace-string-again @@ -40,8 +40,10 @@ if [[ $curwidget = *(pattern|regex)* ]]; then rep2+=$rep if [[ $curwidget = *regex* ]]; then autoload -Uz regexp-replace - regexp-replace LBUFFER $_replace_string_src $rep2 || return 1 - regexp-replace RBUFFER $_replace_string_src $rep2 || return 1 + integer ret=1 + regexp-replace LBUFFER $_replace_string_src $rep2 && ret=0 + regexp-replace RBUFFER $_replace_string_src $rep2 && ret=0 + return ret else LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} -- cgit v1.2.3 From ec6914b061c652a26078af71a29a3d3402583b52 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 7 Nov 2011 11:13:48 +0000 Subject: 29894: display and use previous replacement in replace-string --- ChangeLog | 7 ++++++- Doc/Zsh/contrib.yo | 5 +++++ Functions/Zle/replace-string | 20 +++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 8eda2f415..b9ac1e6ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-07 Peter Stephenson + + * 29894: Doc/Zsh/contrib.yo, Functions/Zle/replace-string: + display previous replacement and reuse if source string is empty. + 2011-11-04 Peter Stephenson * 29892: Functions/Zle/read-from-minibuffer, @@ -15543,5 +15548,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5493 $ +* $Revision: 1.5494 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 05bbcd7ec..b02c61c45 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2335,6 +2335,11 @@ regular expression matching is performed, else a literal string replacement. Note that the previous source and replacement text are the same whether pattern, regular expression or string matching is used. +In addition, tt(replace-string) shows the previous replacement above +the prompt, so long as there was one during the current session; if the +source string is empty, that replacement will be repeated without +the widget prompting for a replacement string. + For example, starting from the line: example(print This line contains fan and fond) diff --git a/Functions/Zle/replace-string b/Functions/Zle/replace-string index bc608e577..a3416a403 100644 --- a/Functions/Zle/replace-string +++ b/Functions/Zle/replace-string @@ -3,7 +3,15 @@ setopt extendedglob autoload -Uz read-from-minibuffer replace-string-again -local p1="Replace: " p2=" with: " +local p1 p2 + +if [[ -n $_replace_string_src ]]; then + p1="[$_replace_string_src -> $_replace_string_rep]"$'\n' +fi + +p1+="Replace: " +p2=" with: " + # Saving curwidget is necessary to avoid the widget name being overwritten. local REPLY previous curwidget=$WIDGET @@ -14,10 +22,12 @@ else fi read-from-minibuffer $p1 ${previous:+$_replace_string_src} || return 1 -typeset -g _replace_string_src=$REPLY +if [[ -n $REPLY ]]; then + typeset -g _replace_string_src=$REPLY -read-from-minibuffer "$p1$_replace_string_src$p2" \ - ${previous:+$_replace_string_rep} || return 1 -typeset -g _replace_string_rep=$REPLY + read-from-minibuffer "$p1$_replace_string_src$p2" \ + ${previous:+$_replace_string_rep} || return 1 + typeset -g _replace_string_rep=$REPLY +fi replace-string-again $curwidget -- cgit v1.2.3 From 6ed7fab103836bb4fd716e90eef255630674fffe Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Wed, 9 Nov 2011 17:49:25 +0000 Subject: Akinori MUSHA: 29900: Backends/VCS_INFO_detect_svn: Adjust detection to support subversion 1.7. --- ChangeLog | 8 +++++++- Functions/VCS_Info/Backends/VCS_INFO_detect_svn | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index e712811a5..70e82baa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-11-09 Frank Terbeck + + * Akinori MUSHA: 29900: + Functions/VCS_Info/Backends/VCS_INFO_detect_svn: Adjust detection + to support subversion 1.7. + 2011-11-08 Peter Stephenson * Haakon Riiser: 29895, 29887: Completion/Unix/Command/_ffmpeg, @@ -15559,5 +15565,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5496 $ +* $Revision: 1.5497 $ ***************************************************** diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_svn b/Functions/VCS_Info/Backends/VCS_INFO_detect_svn index a777ecc43..43dedcde9 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_svn @@ -7,5 +7,5 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && return 1 VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 -{ [[ -f ".svn/entries" ]] || [[ -f ".svn/format" ]] } && return 0 -return 1 +vcs_comm[detect_need_file]="entries format" +VCS_INFO_bydir_detect '.svn' || return 1 -- cgit v1.2.3 From 7c4a81113448b4177bd9c35fd5b04b60dcaf35a7 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 18 Nov 2011 09:52:50 +0000 Subject: 29908: make MIME functions handle stacked suffixes --- ChangeLog | 9 +++++- Doc/Zsh/contrib.yo | 17 ++++++++++ Functions/MIME/.distfiles | 5 ++- Functions/MIME/zsh-mime-handler | 70 ++++++++++++++++++++++++++++++++--------- 4 files changed, 84 insertions(+), 17 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 05c5ba28e..b72cb695c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-11-18 Peter Stephenson + + * 29908: Doc/Zsh/contrib.yo, Functions/MIME/.distfiles, + Functions/MIME/zsh-mime-contexts, Functions/MIME/zsh-mime-handler: + make MIME functions handle contexts with stacked suffixes such + as .pdf.gz. + 2011-11-17 Peter Stephenson * Jun T.: 29907: Src/Modules/pcre.c: remove declaration of @@ -15582,5 +15589,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5500 $ +* $Revision: 1.5501 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index b02c61c45..aee0bd7f4 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2803,6 +2803,23 @@ start with tt(:mime:), with additional components in some cases. It is recommended that a trailing tt(*) (suitably quoted) be appended to style patterns in case the system is extended in future. Some examples are given below. + +For files that have multiple suffixes, e.g. tt(.pdf.gz), where the +context includes the suffix it will be looked up starting with the +longest possible suffix until a match for the style is found. +For example, if tt(.pdf.gz) produces a match for the handler, that +will be used; otherwise the handler for tt(.gz) will be used. Note +that, owing to the way suffix aliases work, it is always required that +there be a handler for the shortest possible suffix, so in this example +tt(.pdf.gz) can only be handled if tt(.gz) is also handled (though +not necessarily in the same way). Alternatively, if no handling +for tt(.gz) on its own is needed, simply adding the command + +example(alias -s gz=zsh-mime-handler) + +to the initialisation code is sufficient; tt(.gz) will not be handled +on its own, but may be in combination with other suffixes. + startitem() kindex(current-shell, MIME style) item(tt(current-shell))( diff --git a/Functions/MIME/.distfiles b/Functions/MIME/.distfiles index 01ac0d7ef..93c13f7da 100644 --- a/Functions/MIME/.distfiles +++ b/Functions/MIME/.distfiles @@ -1,4 +1,7 @@ DISTFILES_SRC=' .distfiles -zsh-mime-setup zsh-mime-handler pick-web-browser +pick-web-browser +zsh-mime-contexts +zsh-mime-handler +zsh-mime-setup ' diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler index 9a40e67bb..abaf0b6e3 100644 --- a/Functions/MIME/zsh-mime-handler +++ b/Functions/MIME/zsh-mime-handler @@ -34,6 +34,8 @@ setopt extendedglob cbases nullglob $autocd # We need zformat from zsh/zutil for %s replacement. zmodload -i zsh/zutil +autoload -Uz zsh-mime-contexts + # Look for options. Because of the way this is usually invoked, # (there is always a command to be handled), only handle options # up to second last argument. @@ -62,12 +64,15 @@ shift $(( OPTIND - 1 )) # just as well pass them all down. However, we just take the # suffix from the first since that's what invoked us via suffix -s. -local suffix context +local suffix s local -a match mbegin mend -[[ $1 = (#b)*.([^.]##) ]] || return 1 -suffix=${(L)match[1]} -context=":mime:.${suffix}:" +suffix=${1:t} +if [[ $suffix != *.* ]]; then + "No suffix in command: $1" >&2 + return 1 +fi +suffix=${suffix#*.} local handler flags no_sh no_bg arg integer i @@ -77,11 +82,11 @@ local -a exec_asis hand_nonex # despite being called for interpretation by the mime handler. # Defaults to executable files, which ensures that they are executed as # they are, even if they have a suffix. -zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)' '*(/)') +zsh-mime-contexts -a $suffix execute-as-is exec_asis || exec_asis=('*(*)' '*(/)') # Set to a list of patterns for which the handler will be used even # if the file doesn't exist on the disk. -zstyle -a $context handle-nonexistent hand_nonex || +zsh-mime-contexts -a $suffix handle-nonexistent hand_nonex || hand_nonex=('[[:alpha:]]#:/*') local pattern @@ -92,9 +97,9 @@ local -a files # actual file or its directory. local dir local -a filepath -if zstyle -t $context find-file-in-path && [[ $1 != /* ]] && +if zsh-mime-contexts -t $suffix find-file-in-path && [[ $1 != /* ]] && [[ $1 != */* || -o pathdirs ]]; then - zstyle -a $context file-path filepath || filepath=($path) + zsh-mime-contexts -a $suffix file-path filepath || filepath=($path) for dir in $filepath; do if [[ -e $dir/$1 ]]; then 1=$dir/$1 @@ -153,19 +158,54 @@ if [[ ! -e $1 ]]; then fi fi -zstyle -s $context handler handler || - handler="${zsh_mime_handlers[$suffix]}" -zstyle -s $context flags flags || - flags="${zsh_mime_flags[$suffix]}" +if ! zsh-mime-contexts -s $suffix handler handler; then + # Look for handler starting with longest suffix match. + # Typically we'd only get a match for the shortest, but don't assume so. + s=$suffix + while true; do + handler="${zsh_mime_handlers[$s]}" + if [[ -n $handler ]]; then + break + fi + if [[ $s = *.* ]]; then + s=${s#*.} + else + break + fi + done + if [[ -z $handler ]]; then + if [[ $suffix = *.* ]]; then + print "No handler specified for suffix .$suffix or any final part" >&2 + else + print "No handler specified for suffix .$suffix" >&2 + fi + return 1 + fi +fi +if ! zsh-mime-contexts -s $suffix flags flags; then + # Same again for flags. + s=$suffix + while true; do + flags="${zsh_mime_flags[$suffix]}" + if [[ -n $flags ]]; then + break + fi + if [[ $s = *.* ]]; then + s=${s#*.} + else + break + fi + done +fi # Set to yes if we use eval instead of sh -c for complicated mailcap lines # Can possibly break some mailcap entries which expect sh compatibility, # but is faster, as a new process is not spawned. -zstyle -t $context current-shell && no_sh=yes +zsh-mime-contexts -t $suffix current-shell && no_sh=yes # Set to yes if the process shouldn't be backgrounded even if it doesn't need a # terminal and display is set. -zstyle -t $context never-background && no_bg=yes +zsh-mime-contexts -t $suffix never-background && no_bg=yes local hasmeta stdin @@ -241,7 +281,7 @@ if [[ $flags = *copiousoutput* ]]; then # We need to page the output. # Careful in case PAGER is a set of commands and arguments. local -a pager - zstyle -a $context pager pager || pager=(${=PAGER:-more}) + zsh-mime-contexts -a $suffix pager pager || pager=(${=PAGER:-more}) if [[ -n $stdin ]]; then cat $argv | $execargs | $pager else -- cgit v1.2.3 From 6e29de366cadd79b66b8e8eb1426cff06d407074 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 20 Nov 2011 16:05:12 +0000 Subject: Missed file. --- Functions/MIME/zsh-mime-contexts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Functions/MIME/zsh-mime-contexts (limited to 'Functions') diff --git a/Functions/MIME/zsh-mime-contexts b/Functions/MIME/zsh-mime-contexts new file mode 100644 index 000000000..08f125158 --- /dev/null +++ b/Functions/MIME/zsh-mime-contexts @@ -0,0 +1,24 @@ +# Helper for zsh-mime-handler. +# +# Pass in a zstyle option, a suffix, which might include multiple parts +# (e.g. pdf.gz), plus remaining zstyle arguments plus arguments to zstyle. +# Try to match the style starting with the longest possible suffix. + +local context suffix option + +option=$1 +shift +suffix=$1 +shift + +while true; do + context=":mime:.${suffix}:" + zstyle $option $context "$@" && return 0 + if [[ $suffix = *.* ]]; then + suffix=${suffix#*.} + else + break + fi +done + +return 1 -- cgit v1.2.3