Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] edit-command-line breaks arguments with spaces



On Oct 14,  8:40pm, Marco Hinz wrote:
}
} Oh, wow. Splitting words but taking quoted arguments into account.. I
} was looking for something like (z).
}
} The patch works well and I'd prefer that approach.

The following seems to be the full set of agreed-upon changes.


diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 353f260..e17893e 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -15,15 +15,15 @@
   (( $+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}}}
+  local editor=( "${(@Q)${(z)${VISUAL:-${EDITOR:-vi}}}}" )
   case $editor in 
     (*vim*)
       integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
-      ${=editor} -c "normal! ${byteoffset}go" -- $1;;
+      "${(@)editor}" -c "normal! ${byteoffset}go" -- $1;;
     (*emacs*)
-      local lines=( ${(f):-"$PREBUFFER$LBUFFER"} )
-      ${=editor} +${#lines}:$((${#lines[-1]} + 1)) $1;;
-    (*) ${=editor} $1;;
+      local lines=( "${(@f):-"$PREBUFFER$LBUFFER"}" )
+      "${(@)editor}" +${#lines}:$((${#lines[-1]} + 1)) $1;;
+    (*) "${(@)editor}" $1;;
   esac
 
   (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[1]



Messages sorted by: Reverse Date, Date, Thread, Author