 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
FR: $CURRENT(word)$ interpretation |
|
I have a hotkey (Alt+0) that uses the macro $CURRENT(word)$ to fetch the current word the caret is in and surround that word with delimiters. This proved surprisingly useful in fixing code lacking said delimiters, as SA does not delimit either declared or user-defined variables upon autocomplete, despite Always add delimiters set to Always add apostrophes ` `. But the way it works is also unexpectedly frustrating. When the caret is inside a word it works perfectly. It's the same if it is at the beginning or at the end of a word. The unpleasant part comes when words sit beside each other without any spaces between them. Yes, that sounds quite impossible, as anyone would consider that situation a single word. The problem is, SA considers semicolons, commas, periods, brackets, parentheses, exclamations marks, you name it, a word. In these cases, being at the beginning of a word has higher priority than being at the end of another word, which results in unwanted behavior.
For example, if the caret is at the location indicated by the pipe:
 |
 |
whatever|;
|
hitting the hotkey on a MariaDB server will end up as:
 |
 |
whatever`;`
|
instead of:
 |
 |
`whatever`;
|
Not considering the semicolons and co. words would quickly solve this but would disable other, more creative uses of the $CURRENT(...)$ macro involving those "words". Perhaps being at the end of a word having higher priority than being at the start of another when deciding which of the words on the caret boundary to pick as a winner might provide a more versatile fix.
|
|
Wed May 03, 2023 3:39 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I'm happy to submit an enhancement request but I need your help with describing it in a formal way. What could solve issues here? If we add an optional parameter to $CURRENT(word)$, for example,
 |
 |
$CURRENT(word, letters)$
$CURRENT(word, digits)$
$CURRENT(word, letters+digits)$
$CURRENT(word, symbols)$
$CURRENT(word, all)$ |
and make letters recognize letters only, letters+digits recognize letters and digits, etc... would that do it?
|
|
Wed May 03, 2023 8:29 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Hmm, your idea of excluding/including stuff in the definition of a "word" is quite a bit better than what I originally suggested, so let's go with that instead. But let me ask a question. Would it be possible to add a regexp pattern as an additional option to $CURRENT(word)$? That would give users absolute control over what should be considered a word in a specific scenario. I'll totally understand if you say "no", I'm just curious about the extent of unexploited potential in that macro.
|
|
Thu May 04, 2023 3:37 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I only meant that particular macros and its behavior. I hope they don't somehow apply that behavioral change to the entire code base, in my opinion that would open a Pandora box. I have submitted an enhancement request ticket with number #SA0043956 for the above. If you want to add or change something, please let us know, I will update the ticket as required.
|
|
Thu May 04, 2023 8:15 am |
|
 |
Mindflux
Joined: 25 May 2013 Posts: 846 Country: United States |
|
|
|
Would there be any way to add $CURRENT(statement)$ to that request?
|
|
Fri May 05, 2023 8:10 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Noted. I will add it to the ticket.
|
|
Fri May 05, 2023 8:25 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
 |
 |
Would there be any way to add $CURRENT(statement)$ to that request? |
Wonderful idea!
|
|
Sat May 06, 2023 8:03 pm |
|
 |
Mindflux
Joined: 25 May 2013 Posts: 846 Country: United States |
|
|
|
 |
 |
 |
 |
Would there be any way to add $CURRENT(statement)$ to that request? |
Wonderful idea! |
This has me wondering if $CURRENT(region)$ and some others would be useful too.
|
|
Sun May 07, 2023 9:28 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|