summaryrefslogtreecommitdiff
path: root/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Chpwd/zsh_directory_name_generic23
-rw-r--r--Functions/Newuser/zsh-newuser-install1
-rw-r--r--Functions/Prompts/prompt_oliver_setup2
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_detect_git3
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs12
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_svn12
-rw-r--r--Functions/VCS_Info/VCS_INFO_bydir_detect12
-rw-r--r--Functions/VCS_Info/VCS_INFO_patch2subject20
-rw-r--r--Functions/VCS_Info/VCS_INFO_quilt10
-rw-r--r--Functions/VCS_Info/vcs_info6
-rw-r--r--Functions/Zftp/zfautocheck2
-rw-r--r--Functions/Zle/bracketed-paste-magic4
-rw-r--r--Functions/Zle/insert-composed-char4
-rw-r--r--Functions/Zle/smart-insert-last-word5
14 files changed, 77 insertions, 39 deletions
diff --git a/Functions/Chpwd/zsh_directory_name_generic b/Functions/Chpwd/zsh_directory_name_generic
index aa4bf9b84..df21af598 100644
--- a/Functions/Chpwd/zsh_directory_name_generic
+++ b/Functions/Chpwd/zsh_directory_name_generic
@@ -69,25 +69,32 @@ elif [[ $1 = d ]]; then
local _zdn_rest=$_zdn_dir
local -a _zdn_cpts
local _zdn_pref _zdn_pref_raw _zdn_matched _zdn_cpt _zdn_name
+ local _zdn_pref_matched _zdn_rest_matched
+ integer _zdn_matchlen _zdn_len1
while [[ -n $_zdn_var && -n $_zdn_rest ]]; do
+ _zdn_matchlen=0
_zdn_assoc=(${(Pkv)_zdn_var})
- # Sorting in descending order will ensure prefixes
- # come after longer strings with that perfix, so
- # we match more specific directory names preferentially.
_zdn_cpts=(${(Ov)_zdn_assoc})
_zdn_cpt=''
for _zdn_pref_raw in $_zdn_cpts; do
_zdn_pref=${_zdn_pref_raw%/:*}
[[ -z $_zdn_pref ]] && continue
if [[ $_zdn_rest = $_zdn_pref(#b)(/|)(*) ]]; then
- _zdn_cpt=${(k)_zdn_assoc[(r)$_zdn_pref_raw]}
- # if we matched a /, too, add it...
- _zdn_matched+=$_zdn_pref$match[1]
- _zdn_rest=$match[2]
- break
+ _zdn_len1=${#_zdn_pref}
+ if (( _zdn_len1 > _zdn_matchlen )); then
+ _zdn_matchlen=$_zdn_len1
+ _zdn_cpt=${(k)_zdn_assoc[(r)$_zdn_pref_raw]}
+ # if we matched a /, too, add it...
+ _zdn_pref_matched=$_zdn_pref$match[1]
+ _zdn_rest_matched=$match[2]
+ fi
fi
done
+ if (( _zdn_matchlen )); then
+ _zdn_matched+=$_zdn_pref_matched
+ _zdn_rest=$_zdn_rest_matched
+ fi
if [[ -n $_zdn_cpt ]]; then
_zdn_name+=${_zdn_name:+${_zdh_name}:}$_zdn_cpt
if [[ ${_zdn_assoc[$_zdn_cpt]} = (#b)*/:([[:IDENT:]]##) ]]; then
diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install
index e4028fd50..60ac16b13 100644
--- a/Functions/Newuser/zsh-newuser-install
+++ b/Functions/Newuser/zsh-newuser-install
@@ -899,7 +899,6 @@ __zni_options_config() {
# The "no" prefix is used to indicate options on by default.
__zni_apply_defaults -o autocd '' "Change directory given just path." \
extendedglob '' "Use additional pattern matching features." \
- appendhistory '' "Append new history lines instead of overwriting." \
'!nomatch' '' "Unmatched patterns cause an error." \
'!beep' '' "Beep on errors." \
notify '' "Immediately report changes in background job status."
diff --git a/Functions/Prompts/prompt_oliver_setup b/Functions/Prompts/prompt_oliver_setup
index 979411d4b..2df919950 100644
--- a/Functions/Prompts/prompt_oliver_setup
+++ b/Functions/Prompts/prompt_oliver_setup
@@ -5,7 +5,7 @@ prompt_oliver_help() {
With this prompt theme, the prompt contains the current directory,
history number, number of jobs (if non-zero) and the previous
command's exit code (if non-zero) and a final character which
-depends on priviledges.
+depends on privileges.
The colour of the prompt depends on two associative arrays -
$pcolour and $tcolour. Each array is indexed by the name of the
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_git b/Functions/VCS_Info/Backends/VCS_INFO_detect_git
index 61bc483e3..e4191f474 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_detect_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_git
@@ -6,8 +6,7 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && { print -l git-p4 git-svn; return 0 }
-if VCS_INFO_check_com ${vcs_comm[cmd]} && ${vcs_comm[cmd]} rev-parse --is-inside-work-tree &> /dev/null ; then
- vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" || return 1
+if VCS_INFO_check_com ${vcs_comm[cmd]} && vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" ; then
if [[ -d ${vcs_comm[gitdir]}/svn ]] ; then vcs_comm[overwrite_name]='git-svn'
elif [[ -d ${vcs_comm[gitdir]}/refs/remotes/p4 ]] ; then vcs_comm[overwrite_name]='git-p4' ; fi
return 0
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
index e9d172052..9b828bd11 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
@@ -5,11 +5,17 @@
setopt localoptions NO_shwordsplit
local cvsbranch cvsbase
+# Look for the most distant parent that still has a CVS subdirectory.
+# VCS_INFO_detect_cvs ensured that ./CVS/Repository exists.
cvsbase="."
-while [[ -d "${cvsbase}/../CVS" ]]; do
- cvsbase="${cvsbase}/.."
-done
cvsbase=${cvsbase:P}
+while [[ -d "${cvsbase:h}/CVS" ]]; do
+ cvsbase="${cvsbase:h}"
+ if [[ $cvsbase == '/' ]]; then
+ break
+ fi
+done
+
cvsbranch=$(< ./CVS/Repository)
rrn=${cvsbase:t}
cvsbranch=${cvsbranch##${rrn}/}
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index c1547950f..21590addd 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -46,17 +46,19 @@ if (( ${+svninfo[Working_Copy_Root_Path]} )); then
${vcs_comm[cmd]} info --non-interactive -- "${svnbase}" | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done
else
# svn 1.0-1.6
- while [[ -d "${svnbase}/../.svn" ]]; do
+ svnbase=${svnbase:P}
+ while [[ -d "${svnbase:h}/.svn" ]]; do
parentinfo=()
- ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
+ ${vcs_comm[cmd]} info --non-interactive -- "${svnbase:h}" | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
[[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break
svninfo=(${(kv)parentinfo})
- svnbase="${svnbase}/.."
+ svnbase=${svnbase:h}
+ if [[ $svnbase == '/' ]]; then
+ break
+ fi
done
fi
-svnbase=${svnbase:P}
-
rrn=${svnbase:t}
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" )
diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect
index b20c05c9c..29b261413 100644
--- a/Functions/VCS_Info/VCS_INFO_bydir_detect
+++ b/Functions/VCS_Info/VCS_INFO_bydir_detect
@@ -2,6 +2,18 @@
## Written by Frank Terbeck <ft@bewatermyfriend.org>
## Distributed under the same BSD-ish license as zsh itself.
+# Helper function for VCS_INFO_detect_*
+#
+# Usage:
+# vcs_comm[detect_need_file]=FILENAMES VCS_INFO_bydir_detect DIRNAME
+# where DIRNAME is a directory name and FILENAMES is a space-separated list
+# of filenames.
+#
+# If any parent directory of the current working directory, other than the root
+# directory, contains a subdirectory named DIRNAME that contains a file whose name
+# is in FILENAMES, set vcs_comm[basedir] to the path of that parent directory and
+# return true. Otherwise, return false.
+
setopt localoptions NO_shwordsplit
local dirname=$1
local basedir="." file
diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject
index a48c16b04..a467edcdb 100644
--- a/Functions/VCS_Info/VCS_INFO_patch2subject
+++ b/Functions/VCS_Info/VCS_INFO_patch2subject
@@ -14,10 +14,7 @@
IFS= read -r "lines[$i]"
if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---[^-]|Index:)* ]]; then
lines[$i]=()
- # For 'svn log -r N --diff' output, read the first paragraph too.
- if ! [[ $lines[i-1] =~ $svn_log_pattern ]]; then
- break
- fi
+ break
fi
done < "$1"
@@ -55,9 +52,18 @@
fi
} < "$1"
REPLY=$needle
- elif [[ $lines[2] =~ $svn_log_pattern ]]; then
- REPLY=$lines[4]
- if (( ${+lines[5]} )); then REPLY+='...'; fi
+ elif [[ $lines[1] =~ $svn_log_pattern ]] || [[ $lines[2] =~ $svn_log_pattern ]]; then
+ # Read up to the next blank line, and the first two lines after it.
+ integer multiline=0
+ {
+ while read -r needle; [[ -n $needle ]]; do done
+ # Read the first line of the second paragraph, which is the first
+ # line of the log message.
+ read -r needle
+ read -r && [[ -n $REPLY ]] && multiline=1
+ } < "$1"
+ REPLY=$needle
+ if (( multiline )); then REPLY+='...'; fi
elif (( ${+lines[1]} )); then
# The first line of the file is not part of the diff.
REPLY=${lines[1]}
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index 1f20e895d..fef85964a 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -78,7 +78,7 @@ function VCS_INFO_quilt-dirfind() {
VCS_INFO_bydir_detect ${dir}
ret=$?
vcs_comm[detect_need_file]=${oldfile}
- printf '%s' ${vcs_comm[basedir]}
+ REPLY=${vcs_comm[basedir]}
vcs_comm[basedir]="${olddir}"
return ${ret}
}
@@ -113,8 +113,8 @@ function VCS_INFO_quilt-patch2subject() {
;;
esac
- pc="$(VCS_INFO_quilt-dirfind .pc .version)"
- ret=$?
+ VCS_INFO_quilt-dirfind .pc .version
+ ret=$? pc=$REPLY
if (( ret == 0 )); then
[[ ${quiltmode} == 'standalone' ]] && root=${pc}
pc=${pc}/.pc
@@ -138,8 +138,8 @@ function VCS_INFO_quilt-patch2subject() {
zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}"
if [[ "${patches}" != /* ]]; then
tmp=${patches:-patches}
- patches="$(VCS_INFO_quilt-dirfind "${tmp}")"
- ret=$?
+ VCS_INFO_quilt-dirfind "${tmp}"
+ ret=$? patches=$REPLY
(( ret )) && return ${ret}
patches=${patches}/${tmp}
else
diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index d67ae6bf5..9f48bee75 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -59,6 +59,12 @@ vcs_info () {
local -x LC_MESSAGES
local -i maxexports
local -a msgs
+
+ # vcs_comm is used internally for passing values among VCS_INFO_* functions.
+ # It is not part of the public API.
+ #
+ # hook_com, backend_misc, and user_data are public API; see zshcontrib(1)
+ # and Misc/vcs_info-examples.
local -A vcs_comm hook_com backend_misc user_data
LC_MESSAGES=C
diff --git a/Functions/Zftp/zfautocheck b/Functions/Zftp/zfautocheck
index e53fde8d2..a8b24ef0b 100644
--- a/Functions/Zftp/zfautocheck
+++ b/Functions/Zftp/zfautocheck
@@ -4,7 +4,7 @@
# With first argument including n, don't change to the old directory; else do.
#
# Set do_close to 1 if the connection was not previously open, 0 otherwise
-# With first arguemnt including d, don't set do_close to 1. Broadly
+# With first argument including d, don't set do_close to 1. Broadly
# speaking, we use this mechanism to shut the connection after use
# if the connection had been explicitly closed (i.e. didn't time out,
# which zftp test investigates) and we are not using a directory
diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index 4baae823e..840091b44 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -162,7 +162,7 @@ bracketed-paste-magic() {
# There are active widgets. Reprocess $PASTED as keystrokes.
NUMERIC=1
- zle -U - $PASTED
+ zle -U - "$PASTED"
# Just in case there are active undo widgets
@@ -212,7 +212,7 @@ bracketed-paste-magic() {
# Arrange to display highlighting if necessary
if [[ -z $zle_highlight || -n ${(M)zle_highlight:#paste:*} ]]; then
zle -R
- zle .read-command && zle -U - $KEYS
+ zle .read-command && zle -U - "$KEYS"
fi
}
diff --git a/Functions/Zle/insert-composed-char b/Functions/Zle/insert-composed-char
index c0922e7d4..636895a89 100644
--- a/Functions/Zle/insert-composed-char
+++ b/Functions/Zle/insert-composed-char
@@ -27,7 +27,7 @@
# ' Acute
# > Circumflex
# ? Tilde
-# - Macron. (A horizonal bar over the letter.)
+# - Macron. (A horizontal bar over the letter.)
# ( Breve. (A shallow dish shape over the letter.)
# . Dot above, or no dot with lower case i, or dot in the middle of L or l.
# : Diaeresis (Umlaut)
@@ -43,7 +43,7 @@
# 9 Horn
# Hence A! is upper case A with a grave, c, is lower case c with cedilla.
#
-# Some other composed charaters:
+# Some other composed characters:
# Various ligatures:
# AE ae OE oe IJ ij
#
diff --git a/Functions/Zle/smart-insert-last-word b/Functions/Zle/smart-insert-last-word
index cf8715dfe..05f23cba6 100644
--- a/Functions/Zle/smart-insert-last-word
+++ b/Functions/Zle/smart-insert-last-word
@@ -48,13 +48,14 @@ zle auto-suffix-retain
# Not strictly necessary:
# (($+_ilw_hist)) || integer -g _ilw_hist _ilw_count _ilw_cursor _ilw_lcursor _ilw_changeno
+# (($+_ilw_result)) || typeset -g _ilw_result
integer cursor=$CURSOR lcursor=$CURSOR
local lastcmd pattern numeric=$NUMERIC
# Save state for repeated calls
if (( HISTNO == _ilw_hist && cursor == _ilw_cursor &&
- UNDO_CHANGE_NO == _ilw_changeno ))
+ UNDO_CHANGE_NO == _ilw_changeno )) && [[ $BUFFER == $_ilw_result ]]
then
NUMERIC=$[_ilw_count+1]
lcursor=$_ilw_lcursor
@@ -119,7 +120,7 @@ fi
(( NUMERIC > $#lastcmd )) && return 1
LBUFFER[lcursor+1,cursor+1]=$lastcmd[-NUMERIC]
-typeset -g _ilw_cursor=$CURSOR
+typeset -g _ilw_cursor=$CURSOR _ilw_result=$BUFFER
# This is necessary to update UNDO_CHANGE_NO immediately
zle split-undo && typeset -g _ilw_changeno=$UNDO_CHANGE_NO