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

Re: delete-whole-word-match fails on words starting with -, patch



On 09/11/2007, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> Peter Stephenson wrote:
> > "Mikael Magnusson" wrote:
> > > -- isn't documented in the manual for the zle builtin, but seems to do
> > > the trick anyway.
> >
> > The function's been rewritten to use lower level facilities, so that
> > shouldn't occur.
>
> I'm talking nonsense:  no, it hasn't been rewritten and I must have been
> looking at the wrong thing.  However, I still don't understand
> how you're getting that problem.  Could you send a trace with "setopt
> xtrace" both in there and in match-words-by-style (I presume it
> depends on what word style is in effect since I can't se it)?

By that, if you mean the problem with words starting with -, i
realized it only happens if you call it as kill-whole-word-match.

% -te<ctrl-delete>st bar
delete-whole-word-match:zle:52: unknown option: test
% bar

with xtrace set and same sequence,

+delete-whole-word-match:13> setopt extendedglob
+delete-whole-word-match:15> local 'curcontext=:zle:kill-whole-word-match'
+delete-whole-word-match:16> local -a matched_words
+delete-whole-word-match:18> integer pos1 pos2
+delete-whole-word-match:20> autoload -U match-words-by-style
+delete-whole-word-match:21> match-words-by-style
+match-words-by-style:67> emulate -L zsh
+match-words-by-style:68> setopt extendedglob
+match-words-by-style:70> local wordstyle spacepat wordpat1 wordpat2
opt charskip wordchars wordclass
+match-words-by-style:71> local match mbegin mend pat1 pat2 word1
word2 ws1 ws2 ws3 skip
+match-words-by-style:72> local nwords MATCH MBEGIN MEND
+match-words-by-style:74> local 'curcontext=:zle:kill-whole-word-match'
+match-words-by-style:76> autoload -U match-word-context
+match-words-by-style:77> match-word-context
+match-word-context:5> emulate -L zsh
+match-word-context:6> setopt extendedglob
+match-word-context:8> local -a worcon bufwords
+match-word-context:9> local pat tag lastword word
+match-word-context:10> integer iword
+match-word-context:12> zstyle -a :zle:kill-whole-word-match word-context worcon
+match-word-context:12> return 0
+match-words-by-style:79> getopts w:s:c:C: opt
+match-words-by-style:103> [[ -z '' ]]
+match-words-by-style:103> zstyle -s :zle:kill-whole-word-match
word-style wordstyle
+match-words-by-style:104> [[ -z '' ]]
+match-words-by-style:104> zstyle -s :zle:kill-whole-word-match skip-chars skip
+match-words-by-style:105> [[ -z '' ]]
+match-words-by-style:105> skip=0
+match-words-by-style:107> case shell (shell)
+match-words-by-style:108> local bufwords
+match-words-by-style:110> bufwords=( -t )
+match-words-by-style:111> nwords=1
+match-words-by-style:112> wordpat1=-t
+match-words-by-style:116> bufwords=( est bar )
+match-words-by-style:117> wordpat2=est
+match-words-by-style:118> spacepat='[[:space:]]#'
+match-words-by-style:123> bufwords=( -test bar )
+match-words-by-style:124> ((  5 > 2  ))
+match-words-by-style:127> eval 'pat1=${LBUFFER%%(#b)(-t)([[:space:]]#)}'
+(eval):1> pat1=''
+match-words-by-style:129> wordpat1=-t
+match-words-by-style:130> wordpat2='est '
+match-words-by-style:132> wordpat1=-t
+match-words-by-style:133> wordpat2='est\ '
+match-words-by-style:187> match=( )
+match-words-by-style:188> eval 'pat1=${LBUFFER%%(#b)(-t)([[:space:]]#)}'
+(eval):1> pat1=''
+match-words-by-style:189> word1=-t
+match-words-by-style:190> ws1=''
+match-words-by-style:192> match=( )
+match-words-by-style:193> charskip=''
+match-words-by-style:196> eval
'pat2=${RBUFFER##(#b)([[:space:]]#)(est\ )([[:space:]]#)}'
+(eval):1> pat2=bar
+match-words-by-style:199> ws2=''
+match-words-by-style:200> word2='est '
+match-words-by-style:201> ws3=''
+match-words-by-style:203> matched_words=( '' -t '' '' 'est ' '' bar )
+delete-whole-word-match:23> [[ -n '' ]]
+delete-whole-word-match:29> pos1=0
+delete-whole-word-match:32> [[ -n '' ]]
+delete-whole-word-match:39> ((  pos2 = CURSOR + 4 + 1  ))
+delete-whole-word-match:44> ((  CURSOR = pos1  ))
+delete-whole-word-match:48> [[ kill-whole-word-match == '*kill*' ]]
+delete-whole-word-match:49> local 'word=-test '
+delete-whole-word-match:50> [[ backward-char == '*kill*' ]]
+delete-whole-word-match:53> zle copy-region-as-kill '-test '

delete-whole-word-match:zle:53: unknown option: test
+delete-whole-word-match:56> BUFFER=bar

Adding the -- fixes it as it instead runs
+delete-whole-word-match:53> zle copy-region-as-kill -- -test

In both cases, the end result is the same, but the error message
messes up the display a bit in the first.

-- 
Mikael Magnusson



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