about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-06-21 18:16:40 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-06-21 18:16:40 +0100
commit09e1b2434d6c44d95d97c87d5e803e5f5e747b6e (patch)
tree2abc2637301d1d24e488c5cb37245685104071c7 /Functions
parentdd7852089705e8228228f9e2fb69437b43ddb7e6 (diff)
downloadzsh-09e1b2434d6c44d95d97c87d5e803e5f5e747b6e.tar.gz
zsh-09e1b2434d6c44d95d97c87d5e803e5f5e747b6e.tar.xz
zsh-09e1b2434d6c44d95d97c87d5e803e5f5e747b6e.zip
35545: enhance narrow-to-region to return LBUFFER and RBUFFER
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Zle/narrow-to-region13
1 files changed, 11 insertions, 2 deletions
diff --git a/Functions/Zle/narrow-to-region b/Functions/Zle/narrow-to-region
index 86fd7ac13..c65c80cb9 100644
--- a/Functions/Zle/narrow-to-region
+++ b/Functions/Zle/narrow-to-region
@@ -11,6 +11,8 @@
 # Either or both may be empty.
 #   -n           Only replace the text before or after the region with
 #                the -p or -P options if the text was not empty.
+#   -l lbufvar   ) $lbufvar and $rbufvar will contain the value of $LBUFFER and
+#   -r rbufvar   ) $RBUFFER resulting from any recursive edit (i.e. not with -S or -R)
 #   -S statevar
 #   -R statevar
 # Save or restore the state in/from the parameter named statevar.  In
@@ -28,16 +30,20 @@ integer _ntr_start _ntr_end _ntr_swap _ntr_cursor=$CURSOR _ntr_mark=$MARK
 integer _ntr_stat
 
 local _ntr_opt _ntr_pretext _ntr_posttext _ntr_usepretext _ntr_useposttext
-local _ntr_nonempty _ntr_save _ntr_restore
+local _ntr_nonempty _ntr_save _ntr_restore _ntr_lbuffer _ntr_rbuffer
 
-while getopts "np:P:R:S:" _ntr_opt; do
+while getopts "l:np:P:r:R:S:" _ntr_opt; do
   case $_ntr_opt in
+    (l) _ntr_lbuffer=$OPTARG
+	;;
     (n) _ntr_nonempty=1
 	;;
     (p) _ntr_pretext=$OPTARG _ntr_usepretext=1
 	;;
     (P) _ntr_posttext=$OPTARG _ntr_useposttext=1
 	;;
+    (r) _ntr_rbuffer=$OPTARG
+	;;
     (R) _ntr_restore=$OPTARG
         ;;
     (S)	_ntr_save=$OPTARG
@@ -101,6 +107,9 @@ fi
 if [[ -z $_ntr_save && -z $_ntr_restore ]]; then
   zle recursive-edit
   _ntr_stat=$?
+
+  [[ -n $_ntr_lbuffer ]] && eval "${_ntr_lbuffer}=\${LBUFFER}"
+  [[ -n $_ntr_rbuffer ]] && eval "${_ntr_rbuffer}=\${RBUFFER}"
 fi
 
 if [[ -n $_ntr_restore || -z $_ntr_save ]]; then