Re: AppleScript for Word-Selection at the Cursor

2017-12-04 Thread Oliver Boermans
Thank-you!


On 2 December 2017 at 19:36, Christopher Stone 
wrote:

> On 12/02/2017, at 02:25, Christopher Stone 
> wrote:
>
> So — if the cursor is positioned between the “><” symbols below — the
> first iteration will select to the quotes and the second iteration will
> select to the brackets.
>
> { "Mary Pop>
> --
>
> I meant the cursor take the *place* of “><” in the text.
>
> -ccs
>
> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or would like to report a problem, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: 
> ---
> You received this message because you are subscribed to the Google Groups
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.
> Visit this group at https://groups.google.com/group/bbedit.
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: AppleScript for Word-Selection at the Cursor

2017-12-02 Thread Christopher Stone
On 12/02/2017, at 02:25, Christopher Stone > wrote:
> So — if the cursor is positioned between the “><” symbols below — the first 
> iteration will select to the quotes and the second iteration will select to 
> the brackets.
> 
> { "Mary Pop><” in the text.

-ccs

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: AppleScript for Word-Selection at the Cursor

2017-12-02 Thread Christopher Stone
On 11/30/2017, at 16:57, Oliver Boermans > wrote:
> I’ve fantasised about taking keyboard word selection further, I’d like the 
> same keyboard shortcut to do a little more if the word was already >selected<.
> 
> Specifically I’d like it to attempt to expand to inside (then around) the 
> next closest pair of delimiters (<[{“"''"”}]>), a “selection expander” e.g.


Hey Oliver,

Gruber's script is elegant in its economy, but it doesn't handle hyphenated 
words (and perhaps some other cases).

I'll use it for a while and then have a go at improving it.

Here's what I think is a pretty good effort at your 
expand-selection-to-delimeter request, although it hasn't been tested enough 
yet for me to be confident.


# Auth: Christopher Stone
# dCre: 2017/12/02 01:30
# dMod: 2017/12/02 01:52 
# Appl: BBEdit
# Task: Expand selection to next closest pair of delimiters.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @BBEdit, @Expand, @Selection, @Next, 
@Closest, @Pair, @Delimiters


tell application "BBEdit"
tell front text window

set findBackwardsRec to find "[{‘’“”\"'}]" options {search mode:grep, 
backwards:true}
set startChar to characterOffset of found object of findBackwardsRec
set findForwardsRec to find "[{‘’“”\"'}]" options {search mode:grep}
set endChar to characterOffset of found object of findForwardsRec

select (characters startChar thru endChar)

end tell
end tell



So — if the cursor is positioned between the “><” symbols below — the first 
iteration will select to the quotes and the second iteration will select to the 
brackets.

{ "Mary Pop>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: AppleScript for Word-Selection at the Cursor

2017-12-01 Thread Christopher Stone
On 11/30/2017, at 16:47, Neil Faiman > wrote:
> Take a look at this article 
>  from 
> Daring Fireball in 2003.


Hey Neil,

Perfect.  And more elegant than what I was doing.

> More than you wanted to know. 

Not at all.  :)

Thanks.

--
Take Care,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: AppleScript for Word-Selection at the Cursor

2017-12-01 Thread Roland Küffner
Hi Chris,

I can offer no efficient solution but I can affirm that this is a very
handy functionality (if you ever tried the command viw in vim you know who
it feels :-)

In BBEdit I use two scripts for selecting words. The fist one is the same
Neil pointed to (from John Gruber).

The second one ignores punctuation. This is basically a recorded search
(backwards for \s than forward for \s extending selection). As your
Applescript capabilities are legendary and well known in this list (and
elsewhere), I’m sure that approach would well meet your „spaghetti“
definition. But on the other side, this dirty script *feels* fast enough
and I use it day in and day out.

Maybe BBEdit’s Select Menu will get a 'word' sibbling on some future day.
Till then it’s pasta for me ...

Roland


On Thu, Nov 30, 2017 at 10:28 PM, Christopher Stone <
listmeis...@suddenlink.net> wrote:

> Hey Folks,
>
> I'm trying to write some efficient AppleScript code to select the WORD the
> cursor is IN or next to (right or left).
>
> Examples would be having the cursor anywhere between the “>” & “<” symbols
> in the text below:
>
> 
>
> >Now< is the time for all good men to come to the aid of their country
>
> >Supercalifragilisticexpialidocious< is obviously from “Mary Poppins” if
> you're of a certain age...
>
> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
> >tempor<
>
> 
>
> I've got some spaghetti code I don't like at the moment and thought I'd
> ask before continuing to reinvent the wheel.
>
> TIA.
>
> --
> Best Regards,
> Chris
>
> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or would like to report a problem, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: 
> ---
> You received this message because you are subscribed to the Google Groups
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.
> Visit this group at https://groups.google.com/group/bbedit.
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: AppleScript for Word-Selection at the Cursor

2017-11-30 Thread Oliver Boermans
I’ve fantasised about taking keyboard word selection further, I’d like the
same keyboard shortcut to do a little more if the word was already
>selected<.

Specifically I’d like it to attempt to expand to inside (then around) the
next closest pair of delimiters (<[{“"''"”}]>), a “selection expander” e.g.

before:
"Mary P>oPoppins<"

after:
">Mary Poppins<"

after:
>"Mary Poppins"<

and so on…

Some time ago I made a start on attempting this, but sadly didn’t get very
far.


On 1 December 2017 at 07:58, Christopher Stone 
wrote:

> Hey Folks,
>
> I'm trying to write some efficient AppleScript code to select the WORD the
> cursor is IN or next to (right or left).
>
> Examples would be having the cursor anywhere between the “>” & “<” symbols
> in the text below:
>
> 
>
> >Now< is the time for all good men to come to the aid of their country
>
> >Supercalifragilisticexpialidocious< is obviously from “Mary Poppins” if
> you're of a certain age...
>
> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
> >tempor<
>
> 
>
> I've got some spaghetti code I don't like at the moment and thought I'd
> ask before continuing to reinvent the wheel.
>
> TIA.
>
> --
> Best Regards,
> Chris
>
> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or would like to report a problem, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: 
> ---
> You received this message because you are subscribed to the Google Groups
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.
> Visit this group at https://groups.google.com/group/bbedit.
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


AppleScript for Word-Selection at the Cursor

2017-11-30 Thread Christopher Stone
Hey Folks,

I'm trying to write some efficient AppleScript code to select the WORD the 
cursor is IN or next to (right or left).

Examples would be having the cursor anywhere between the “>” & “<” symbols in 
the text below:



>Now< is the time for all good men to come to the aid of their country

>Supercalifragilisticexpialidocious< is obviously from “Mary Poppins” if you're 
>of a certain age...

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
>tempor<



I've got some spaghetti code I don't like at the moment and thought I'd ask 
before continuing to reinvent the wheel.

TIA.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.