about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2013-03-17 20:52:55 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2013-03-17 20:52:55 +0000
commitab8fe84a8c179f5990c4fd7cd7e2cfa82ed03cc3 (patch)
tree051041d09465f82a0861f9cea523b49fe04b1aa3 /Functions
parent136cc1e1b79ebc07f5deb630fea9d325276d077c (diff)
downloadzsh-ab8fe84a8c179f5990c4fd7cd7e2cfa82ed03cc3.tar.gz
zsh-ab8fe84a8c179f5990c4fd7cd7e2cfa82ed03cc3.tar.xz
zsh-ab8fe84a8c179f5990c4fd7cd7e2cfa82ed03cc3.zip
31155: minor extra zcalc features and documentation
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Misc/zcalc11
1 files changed, 10 insertions, 1 deletions
diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc
index d78c35ed2..e9dcc78b9 100644
--- a/Functions/Misc/zcalc
+++ b/Functions/Misc/zcalc
@@ -166,6 +166,14 @@ while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do
   line="$prev_line$line"
   prev_line=
   cont_prompt=
+  # Test whether there are as many open as close
+  # parentheses in the line so far.
+  if [[ ${#line//[^\(]} -gt ${#line//[^\)]} ]]; then
+      prev_line+=$line
+      cont_prompt="..."
+      line=
+      continue
+  fi
   [[ -z $line ]] && break
   # special cases
   # Set default base if `[#16]' or `[##16]' etc. on its own.
@@ -178,6 +186,7 @@ while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do
 	defbase=$match[1]
       fi
       print -s -- $line
+      print -- $(( ${defbase} ans ))
       line=
       continue
     else
@@ -233,7 +242,7 @@ while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do
       continue
     ;;
 
-    ((:|)function[[:blank:]]##(#b)([^[:blank:]]##)(|[[:blank:]]##([^[:blank:]]*)))
+    ((function|:f(unc(tion|)|))[[:blank:]]##(#b)([^[:blank:]]##)(|[[:blank:]]##([^[:blank:]]*)))
       zmathfuncdef $match[1] $match[3]
       line=
       continue