You could just add another tweak:
findSelector "Dan's code for hunting down selectors with keyword parts; while this doesn't give a true parse, in most cases it does what we want, in where it doesn't, we're none the worse for it." | sel possibleParens | sel := self withBlanksTrimmed. (sel includes: $:) ifTrue: [sel := sel copyReplaceAll: ':' with: ': '. "for the style (aa max:bb) with no space" sel := sel copyReplaceAll: '[:' with: '[ :'. "for the style ([:a) with no space" "<<<<<<<=======" possibleParens := sel findTokens: Character separators. sel := self class streamContents: [:s | | level | level := 0. possibleParens do: [:token | | n | (level = 0 and: [token endsWith: ':']) ifTrue: [s nextPutAll: token] ifFalse: [(n := token occurrencesOf: $( ) > 0 ifTrue: [level := level + n]. (n := token occurrencesOf: $[ ) > 0 ifTrue: [level := level + n]. (n := token occurrencesOf: $] ) > 0 ifTrue: [level := level - n]. (n := token occurrencesOf: $) ) > 0 ifTrue: [level := level - n]]]]].
sel isEmpty ifTrue: [^ nil]. sel isOctetString ifTrue: [sel := sel asOctetString]. Symbol hasInterned: sel ifTrue: [:aSymbol | ^ aSymbol]. ^ nil
On 3/1/13 3:31 PM, Bert Freudenberg wrote:
On 2013-03-01, at 21:18, Chris Muller asqueaker@gmail.com wrote:
That bit? The selecting of a bunch of text around a keyword message? That impressed me no end. It _rocks_.
Oh I know, and I think Dan Ingalls is the one who originally implemented it over a decade ago!
It's great indeed. Would be even more awesome if someone could make it ignore block arguments ...
The selection spanning block args is not the problem, its when it spans a keyword selector symbol.
Try this:
self do: [:i | ] separatedBy: []
If you remove the ":i" it works.
- Bert -