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 --- Functions/Zle/move-line-in-buffer | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Functions/Zle/move-line-in-buffer (limited to 'Functions/Zle') 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/Zle') 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/Zle') 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 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/Zle') 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 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/Zle') 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 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/Zle') 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/Zle') 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