diff options
Diffstat (limited to 'Functions')
-rw-r--r-- | Functions/Chpwd/zsh_directory_name_generic | 4 | ||||
-rw-r--r-- | Functions/Misc/is-at-least | 20 | ||||
-rw-r--r-- | Functions/Newuser/zsh-newuser-install | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_detect_p4 | 4 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_maxexports | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_nvcsformats | 1 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_set | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/vcs_info | 2 | ||||
-rw-r--r-- | Functions/Zle/backward-kill-word-match | 2 | ||||
-rw-r--r-- | Functions/Zle/edit-command-line | 10 | ||||
-rw-r--r-- | Functions/Zle/kill-word-match | 2 | ||||
-rw-r--r-- | Functions/Zle/match-words-by-style | 6 | ||||
-rw-r--r-- | Functions/Zle/transpose-words-match | 11 | ||||
-rw-r--r-- | Functions/Zle/url-quote-magic | 2 |
15 files changed, 55 insertions, 19 deletions
diff --git a/Functions/Chpwd/zsh_directory_name_generic b/Functions/Chpwd/zsh_directory_name_generic index 9430c95e4..aa4bf9b84 100644 --- a/Functions/Chpwd/zsh_directory_name_generic +++ b/Functions/Chpwd/zsh_directory_name_generic @@ -16,7 +16,7 @@ zmodload -i zsh/parameter zstyle -s ":zdn:${funcstack[2]}:" mapping _zdn_topvar || _zdn_topvar=zdn_top if (( ! ${(P)#_zdn_topvar} )); then - print -r -- "$0: $_zdn_topver is not set" >&2 + print -r -- "$0: $_zdn_topvar is not set" >&2 return 1 fi @@ -43,7 +43,7 @@ if [[ $1 = n ]]; then if [[ -z $_zdn_cpt ]]; then # If top level component, just try another expansion - if [[ $_zdn_var != $_zdn_top ]]; then + if [[ $_zdn_var != $_zdn_topvar ]]; then # Committed to this expansion, so report failure. print -r -- "$0: no expansion for directory name \`$_zdn_name'" >&2 fi diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least index d4b0e2fe0..d4ff3552a 100644 --- a/Functions/Misc/is-at-least +++ b/Functions/Misc/is-at-least @@ -13,10 +13,16 @@ # is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS # is-at-least 586 $MACHTYPE && echo 'You could be running Mandrake!' # is-at-least $ZSH_VERSION || print 'Something fishy here.' +# +# Note that segments that contain no digits at all are ignored, and leading +# text is discarded if trailing digits follow, because this was the meaning +# of certain zsh version strings in the early 2000s. Other segments that +# begin with digits are compared using NUMERIC_GLOB_SORT semantics, and any +# other segments starting with text are compared lexically. emulate -L zsh -local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version +local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version order min_ver=(${=1}) version=(${=2:-$ZSH_VERSION} 0) @@ -24,6 +30,18 @@ version=(${=2:-$ZSH_VERSION} 0) while (( $min_cnt <= ${#min_ver} )); do while [[ "$part" != <-> ]]; do (( ++ver_cnt > ${#version} )) && return 0 + if [[ ${version[ver_cnt]} = *[0-9][^0-9]* ]]; then + # Contains a number followed by text. Not a zsh version string. + order=( ${version[ver_cnt]} ${min_ver[ver_cnt]} ) + if [[ ${version[ver_cnt]} = <->* ]]; then + # Leading digits, compare by sorting with numeric order. + [[ $order != ${${(On)order}} ]] && return 1 + else + # No leading digits, compare by sorting in lexical order. + [[ $order != ${${(O)order}} ]] && return 1 + fi + [[ $order[1] != $order[2] ]] && return 0 + fi part=${version[ver_cnt]##*[^0-9]} done diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install index 37c60293a..e4028fd50 100644 --- a/Functions/Newuser/zsh-newuser-install +++ b/Functions/Newuser/zsh-newuser-install @@ -512,7 +512,7 @@ $default_options[$match[2]]) fi print -r "Edit a value. If it is left blank, nothing will be saved:" edval=$match[2] - if vared -p "$match[1]> " -h edval; then + if vared -M emacs -p "$match[1]> " -h edval; then # check this assignment doesn't produce multiple words # e.g. "HISTFILE=never rm -f ~" does produce multiple words... # this isn't perfect, e.g. "(this would get split on assignment)", diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 b/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 index 377453f6a..95a534786 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_p4 @@ -2,7 +2,7 @@ ## perforce support by: Phil Pennock ## Distributed under the same BSD-ish license as zsh itself. -# If user-server is true in the :vcs_info:p4:... context, contact the +# If use-server is true in the :vcs_info:p4:... context, contact the # server to decide whether the directory is handled by Perforce. This can # cause a delay if the network times out, in particular if looking up the # server name failed. Hence this is not the default. If a timeout @@ -10,7 +10,7 @@ # vcs_info_p4_dead_servers and the server is never contacted again. The # array must be edited by hand to remove it. # -# If user-server is false or not set, the function looks to see if there is +# If use-server is false or not set, the function looks to see if there is # a file $P4CONFIG somewhere above in the hierarchy. This is far from # foolproof; in fact it relies on you using the particular working practice # of having such files in all client root directories and nowhere above. diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index e1cee7439..472c10d5d 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -247,7 +247,9 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then fi fi local last="$(< "${patchdir}/last")" - git_patches_unapplied=( {$cur..$last} ) + if (( cur+1 <= last )); then + git_patches_unapplied=( {$((cur+1))..$last} ) + fi fi VCS_INFO_git_handle_patches diff --git a/Functions/VCS_Info/VCS_INFO_maxexports b/Functions/VCS_Info/VCS_INFO_maxexports index ea952517f..d697b9abd 100644 --- a/Functions/VCS_Info/VCS_INFO_maxexports +++ b/Functions/VCS_Info/VCS_INFO_maxexports @@ -2,7 +2,7 @@ ## Written by Frank Terbeck <ft@bewatermyfriend.org> ## Distributed under the same BSD-ish license as zsh itself. -setopt localoptions NO_shwordsplit +setopt localoptions NO_shwordsplit unset zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" "max-exports" maxexports || maxexports=2 if [[ ${maxexports} != <-> ]] || (( maxexports < 1 )); then diff --git a/Functions/VCS_Info/VCS_INFO_nvcsformats b/Functions/VCS_Info/VCS_INFO_nvcsformats index 203a86d23..581aa5a97 100644 --- a/Functions/VCS_Info/VCS_INFO_nvcsformats +++ b/Functions/VCS_Info/VCS_INFO_nvcsformats @@ -4,7 +4,6 @@ setopt localoptions noksharrays NO_shwordsplit local c v rr -local -a msgs if [[ $1 == '-preinit-' ]] ; then c='default' diff --git a/Functions/VCS_Info/VCS_INFO_set b/Functions/VCS_Info/VCS_INFO_set index 484c7937d..e3f62ceef 100644 --- a/Functions/VCS_Info/VCS_INFO_set +++ b/Functions/VCS_Info/VCS_INFO_set @@ -2,7 +2,7 @@ ## Written by Frank Terbeck <ft@bewatermyfriend.org> ## Distributed under the same BSD-ish license as zsh itself. -setopt localoptions noksharrays NO_shwordsplit +setopt localoptions noksharrays NO_shwordsplit unset local -i i j if [[ $1 == '--nvcs' ]] ; then diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 628dde9b1..f13f6b501 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -10,7 +10,7 @@ setopt localoptions noksharrays extendedglob NO_shwordsplit local file func sys -local -a static_functions +local -a static_functions msgs local -i maxexports static_functions=( diff --git a/Functions/Zle/backward-kill-word-match b/Functions/Zle/backward-kill-word-match index ded4db2b5..f04614c87 100644 --- a/Functions/Zle/backward-kill-word-match +++ b/Functions/Zle/backward-kill-word-match @@ -32,4 +32,6 @@ while (( count-- )); do done=1 done +zle -f 'kill' + return 0 diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line index 103a1c1a5..353f2609a 100644 --- a/Functions/Zle/edit-command-line +++ b/Functions/Zle/edit-command-line @@ -1,8 +1,8 @@ # Edit the command line using your usual editor. -# Binding this to 'v' in the vi command mode map, +# Binding this to '!' in the vi command mode map, # autoload -Uz edit-command-line # zle -N edit-command-line -# bindkey -M vicmd v edit-command-line +# bindkey -M vicmd '!' edit-command-line # will give ksh-like behaviour for that key, # except that it will handle multi-line buffers properly. @@ -10,7 +10,9 @@ exec </dev/tty # Compute the cursor's position in bytes, not characters. - setopt localoptions nomultibyte + setopt localoptions nomultibyte noksharrays + + (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2] # Open the editor, placing the cursor at the right place if we know how. local editor=${${VISUAL:-${EDITOR:-vi}}} @@ -24,6 +26,8 @@ (*) ${=editor} $1;; esac + (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[1] + # Replace the buffer with the editor output. print -Rz - "$(<$1)" } =(<<<"$PREBUFFER$BUFFER") diff --git a/Functions/Zle/kill-word-match b/Functions/Zle/kill-word-match index 30db5ab35..ffc5be72b 100644 --- a/Functions/Zle/kill-word-match +++ b/Functions/Zle/kill-word-match @@ -31,4 +31,6 @@ while (( count-- )); do done=1 done +zle -f 'kill' + return 0 diff --git a/Functions/Zle/match-words-by-style b/Functions/Zle/match-words-by-style index b387828f3..54e019d23 100644 --- a/Functions/Zle/match-words-by-style +++ b/Functions/Zle/match-words-by-style @@ -111,20 +111,20 @@ done case $wordstyle in (*shell*) local bufwords # This splits the line into words as the shell understands them. - bufwords=(${(z)LBUFFER}) + bufwords=(${(Z:n:)LBUFFER}) nwords=${#bufwords} wordpat1="${(q)bufwords[-1]}" # Take substring of RBUFFER to skip over $skip characters # from the cursor position. - bufwords=(${(z)RBUFFER[1+$skip,-1]}) + bufwords=(${(Z:n:)RBUFFER[1+$skip,-1]}) wordpat2="${(q)bufwords[1]}" spacepat='[[:space:]]#' # Assume the words are at the top level, i.e. if we are inside # 'something with spaces' then we need to ignore the embedded # spaces and consider the whole word. - bufwords=(${(z)BUFFER}) + bufwords=(${(Z:n:)BUFFER}) if (( ${#bufwords[$nwords]} > ${#wordpat1} )); then # Yes, we're in the middle of a shell word. # Find out what's in front. diff --git a/Functions/Zle/transpose-words-match b/Functions/Zle/transpose-words-match index c1db310c1..4d2ac71f1 100644 --- a/Functions/Zle/transpose-words-match +++ b/Functions/Zle/transpose-words-match @@ -11,14 +11,23 @@ # on X would be turned into `barXfoo' with the cursor still on the X, # regardless of what the character X is. +emulate -L zsh autoload -Uz match-words-by-style -local curcontext=":zle:$WIDGET" skip +local curcontext=":zle:$WIDGET" local -a matched_words integer count=${NUMERIC:-1} neg (( count < 0 )) && (( count = -count, neg = 1 )) +if [[ $WIDGET == transpose-words ]]; then + # default is to be a drop-in replacement, check styles for change + zstyle -m $curcontext skip-chars \* || + zstyle -m $curcontext word-style '*subword*' || + { [[ $LBUFFER[-1] != [[:space:]] && $RBUFFER[1] != [[:space:]] || + -z ${RBUFFER//[[:space:]]/} ]] && zle backward-word } +fi + while (( count-- > 0 )); do match-words-by-style diff --git a/Functions/Zle/url-quote-magic b/Functions/Zle/url-quote-magic index 0e49573db..7ee281ea4 100644 --- a/Functions/Zle/url-quote-magic +++ b/Functions/Zle/url-quote-magic @@ -115,7 +115,7 @@ alias globurl='noglob urlglobber ' function url-quote-magic { setopt localoptions noksharrays extendedglob local qkey="${(q)KEYS}" - local -a reply + local -a reply match mbegin mend if [[ "$KEYS" != "$qkey" ]] then local lbuf="$LBUFFER$qkey" |