Insert Next List Item

2011-08-07 Thread oliver
I'm coming from TextMate, and I'm loving BBEdit so far, but there's
one thing I sorely miss. Let's say you're writing a list of items like
this: (^ = insertion point)

1. Milk
2. Eggs
3. Bacon^

At this point I want to hit a shortcut and have "4. " inserted on the
next line. Would this be possible with AppleScript?

It would be great if the script would look for bulleted lists and do
the right thing as well.

* Milk
* Eggs
* Bacon

I'm thinking it might have to be an AppleScript to select the line and
then call a Text Filter to handle finding the number/star and
appending the next one... but my kung fu is not strong enough to
figure it out.

Any help is appreciated. Thanks!

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at

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: 


Re: Insert Next List Item

2011-08-07 Thread Christopher Stone
On Aug 07, 2011, at 21:35, oliver wrote:
> I'm thinking it might have to be an AppleScript to select the line and then 
> call a Text Filter to handle finding the number/star and appending the next 
> one... but my kung fu is not strong enough to figure it out.
__

Hey Oliver,

This is very quick and dirty, but it'll work with the numerical increment and 
the asterisk bullet.

It's expecting the insertion point (cursor) to be at the end of the line, but 
it could easily be adjusted so that anywhere in the line would do.

You can put it in the script menu and give it a keyboard shortcut and go to 
town.

The logic is pretty straightforward, so you can add more characters like '•' to 
the mix if desired.

--
Best Regards,
Chris

__


tell application "BBEdit"
  try
tell text of front text window
  set lineOfInsertionPoint to line (startLine of selection)
  set findReco to find "^\\d+\\." searching in lineOfInsertionPoint options 
{search mode:grep}
  if found of findReco = true then
set leadingNumber to text 1 thru -2 of (found text of findReco)
set text of selection to return & (leadingNumber + 1) & ". "
select insertion point after selection
  else if found of findReco = false then
set findReco to find "^\\* " searching in lineOfInsertionPoint options 
{search mode:grep}
if found of findReco = true then
  set text of selection to return & "* "
  select insertion point after selection
end if
  end if
end tell
  on error errMsg number errNum
set sep to "=="
set e to sep & return & "Error: " & errMsg & return & sep & return ¬
  & "Error Number: " & errNum & return & sep
beep
display dialog e
  end try
end tell

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at

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: 


Re: Insert Next List Item

2011-08-08 Thread oliver
Perfect! Thank you!

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at

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: 


Re: Insert Next List Item

2012-03-26 Thread KG
Hey Christopher,

Just a minor request to your existing script. This works fantastically if 
you line starts with the bullet. Assuming you have some indentation like 4 
tab stops and then the bullet, the script stops. I made a couple of mods to 
the script as follows:

---
tell application "BBEdit"
try
tell text of front text window
set lineOfInsertionPoint to line (startLine of selection)
set findReco to find "^\\d+\\." searching in 
lineOfInsertionPoint options {search mode:grep}
if found of findReco = true then
set leadingNumber to text 1 thru -2 of (found text of 
findReco)
set text of selection to return & (leadingNumber + 1) & 
". "
select insertion point after selection
else if found of findReco = false then
set findReco to find "^\\* " searching in 
lineOfInsertionPoint options {search mode:grep}
if found of findReco = true then
set text of selection to return & "* "
select insertion point after selection
else
set findReco to find "^\\s*\\+" searching in 
lineOfInsertionPoint options {search mode:grep}
if found of findReco = true then

set text of selection to return & tab & "+ "
select insertion point after selection
end if
end if
end if
end tell
on error errMsg number errNum
set sep to "=="
set e to sep & return & "Error: " & errMsg & return & sep & 
return ¬
& "Error Number: " & errNum & return & sep
beep
display dialog e
end try
end tell
---


Essentially the \s* helps ignore white space at the beginning. There's just 
one problem with my script. It inserts the new bullet point ignoring the 
previous number of tab stops. Is there a way in applescript to get hold of 
the number of tab stops and insert that at the beginning as well?

Thanks again.


On Monday, August 8, 2011 7:04:04 AM UTC+3, Christopher Stone wrote:
>
> On Aug 07, 2011, at 21:35, oliver wrote:
>
> I'm thinking it might have to be an AppleScript to select the line and 
> then call a Text Filter to handle finding the number/star and appending the 
> next one... but my kung fu is not strong enough to figure it out.
>
> __
>
> Hey Oliver,
>
> This is very quick and dirty, but it'll work with the numerical increment 
> and the asterisk bullet.
>
> It's expecting the insertion point (cursor) to be at the end of the line, 
> but it could easily be adjusted so that anywhere in the line would do.
>
> You can put it in the script menu and give it a keyboard shortcut and go 
> to town.
>
> The logic is pretty straightforward, so you can add more characters like 
> '•' to the mix if desired.
>
> --
> Best Regards,
> Chris
>
> __
>
>
> tell application "BBEdit"
>   try
> tell text of front text window
>   set lineOfInsertionPoint to line (startLine of selection)
>   set findReco to find "^\\d+\\." searching in lineOfInsertionPoint 
> options {search mode:grep}
>   if found of findReco = true then
> set leadingNumber to text 1 thru -2 of (found text of findReco)
> set text of selection to return & (leadingNumber + 1) & ". "
> select insertion point after selection
>   else if found of findReco = false then
> set findReco to find "^\\* " searching in lineOfInsertionPoint 
> options {search mode:grep}
> if found of findReco = true then
>   set text of selection to return & "* "
>   select insertion point after selection
> end if
>   end if
> end tell
>   on error errMsg number errNum
> set sep to "=="
> set e to sep & return & "Error: " & errMsg & return & sep & return ¬
>   & "Error Number: " & errNum & return & sep
> beep
> display dialog e
>   end try
> end tell
>

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at

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 @bbe

Re: Insert Next List Item

2012-03-26 Thread Watts Martin
While I don't have the script available at the moment, the "Smart New Line" 
script in the BBEdit Editor Actions Package I linked to a little earlier 
(http://www.ranea.org/bbedit_editoractions.html) may be something to look at. 
It handles bullets that are "-" or "*" at the start of a line and can continue 
the list, and handles the current indentation and expand tabs settings 
correctly.

It doesn't try to number lists as the one below does, but that might be 
something I could add for Markdown.  

--  
Watts Martin
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Monday, March 26, 2012 at 13:45 , KG wrote:

> Hey Christopher,
>  
> Just a minor request to your existing script. This works fantastically if you 
> line starts with the bullet. Assuming you have some indentation like 4 tab 
> stops and then the bullet, the script stops. I made a couple of mods to the 
> script as follows:
>  
> ---
> tell application "BBEdit"
> try
> tell text of front text window
> set lineOfInsertionPoint to line (startLine of selection)
> set findReco to find "^\\d+\\." searching in 
> lineOfInsertionPoint options {search mode:grep}
> if found of findReco = true then
> set leadingNumber to text 1 thru -2 of (found text of 
> findReco)
> set text of selection to return & (leadingNumber + 1) & 
> ". "
> select insertion point after selection
> else if found of findReco = false then
> set findReco to find "^\\* " searching in 
> lineOfInsertionPoint options {search mode:grep}
> if found of findReco = true then
> set text of selection to return & "* "
> select insertion point after selection
> else
> set findReco to find "^\\s*\\+" searching in 
> lineOfInsertionPoint options {search mode:grep}
> if found of findReco = true then
>  
> set text of selection to return & tab & "+ "
> select insertion point after selection
> end if
> end if
> end if
> end tell
> on error errMsg number errNum
> set sep to "=="
> set e to sep & return & "Error: " & errMsg & return & sep & 
> return ¬
> & "Error Number: " & errNum & return & sep
> beep
> display dialog e
> end try
> end tell
>  
> ---
>  
>  
> Essentially the \s* helps ignore white space at the beginning. There's just 
> one problem with my script. It inserts the new bullet point ignoring the 
> previous number of tab stops. Is there a way in applescript to get hold of 
> the number of tab stops and insert that at the beginning as well?
>  
> Thanks again.
>  
>  
> On Monday, August 8, 2011 7:04:04 AM UTC+3, Christopher Stone wrote:
> > On Aug 07, 2011, at 21:35, oliver wrote:
> > > I'm thinking it might have to be an AppleScript to select the line and 
> > > then call a Text Filter to handle finding the number/star and appending 
> > > the next one... but my kung fu is not strong enough to figure it out.
> >  
> >  
> > __
> >  
> > Hey Oliver,
> >  
> > This is very quick and dirty, but it'll work with the numerical increment 
> > and the asterisk bullet.
> >  
> > It's expecting the insertion point (cursor) to be at the end of the line, 
> > but it could easily be adjusted so that anywhere in the line would do.
> >  
> > You can put it in the script menu and give it a keyboard shortcut and go to 
> > town.
> >  
> > The logic is pretty straightforward, so you can add more characters like 
> > '•' to the mix if desired.
> >  
> > --
> > Best Regards,
> > Chris
> >  
> > __
> >  
> >  
> > tell application "BBEdit"
> >   try
> > tell text of front text window
> >   set lineOfInsertionPoint to line (startLine of selection)
> >   set findReco to find "^\\d+\\." searching in lineOfInsertionPoint 
> > options {search mode:grep}
> >   if found of findReco = true then
> > set leadingNumber to text 1 thru -2 of (found text of findReco)
> > set text of selection to return & (leadingNumber + 1) & ". "
> > select insertion point after selection
> >   else if found of findReco = false then
> > set findReco to find "^\\* " searching in lineOfInsertionPoint 
> > options {search mode:grep}
> > if found of findReco = true then
> >   set text of selection to 

Re: Insert Next List Item

2012-03-26 Thread Kendall Conrad
My Smart Newline script can achieve this. You can examine the code
near the top to see how I capture to white space at the start of the
line if that's all you care about. I also updated the script this
evening to also handle numbered lists, which was part of the original
discussion question, though this is a little late for that I suppose,
but others might find it useful.

http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/

-Kendall

On Mar 26, 4:45 pm, KG  wrote:
> Hey Christopher,
>
> Just a minor request to your existing script. This works fantastically if
> you line starts with the bullet. Assuming you have some indentation like 4
> tab stops and then the bullet, the script stops. I made a couple of mods to
> the script as follows:
>
> ---
>     tell application "BBEdit"
>         try
>             tell text of front text window
>                 set lineOfInsertionPoint to line (startLine of selection)
>                 set findReco to find "^\\d+\\." searching in
> lineOfInsertionPoint options {search mode:grep}
>                 if found of findReco = true then
>                     set leadingNumber to text 1 thru -2 of (found text of
> findReco)
>                     set text of selection to return & (leadingNumber + 1) &
> ". "
>                     select insertion point after selection
>                 else if found of findReco = false then
>                     set findReco to find "^\\* " searching in
> lineOfInsertionPoint options {search mode:grep}
>                     if found of findReco = true then
>                         set text of selection to return & "* "
>                         select insertion point after selection
>                     else
>                         set findReco to find "^\\s*\\+" searching in
> lineOfInsertionPoint options {search mode:grep}
>                         if found of findReco = true then
>
>                             set text of selection to return & tab & "+ "
>                             select insertion point after selection
>                         end if
>                     end if
>                 end if
>             end tell
>         on error errMsg number errNum
>             set sep to "=="
>             set e to sep & return & "Error: " & errMsg & return & sep &
> return ¬
>                 & "Error Number: " & errNum & return & sep
>             beep
>             display dialog e
>         end try
>     end tell
> ---
>
> Essentially the \s* helps ignore white space at the beginning. There's just
> one problem with my script. It inserts the new bullet point ignoring the
> previous number of tab stops. Is there a way in applescript to get hold of
> the number of tab stops and insert that at the beginning as well?
>
> Thanks again.
>
>
>
>
>
>
>
> On Monday, August 8, 2011 7:04:04 AM UTC+3, Christopher Stone wrote:
>
> > On Aug 07, 2011, at 21:35, oliver wrote:
>
> > I'm thinking it might have to be an AppleScript to select the line and
> > then call a Text Filter to handle finding the number/star and appending the
> > next one... but my kung fu is not strong enough to figure it out.
>
> > __
>
> > Hey Oliver,
>
> > This is very quick and dirty, but it'll work with the numerical increment
> > and the asterisk bullet.
>
> > It's expecting the insertion point (cursor) to be at the end of the line,
> > but it could easily be adjusted so that anywhere in the line would do.
>
> > You can put it in the script menu and give it a keyboard shortcut and go
> > to town.
>
> > The logic is pretty straightforward, so you can add more characters like
> > '•' to the mix if desired.
>
> > --
> > Best Regards,
> > Chris
>
> > __
>
> > tell application "BBEdit"
> >   try
> >     tell text of front text window
> >       set lineOfInsertionPoint to line (startLine of selection)
> >       set findReco to find "^\\d+\\." searching in lineOfInsertionPoint
> > options {search mode:grep}
> >       if found of findReco = true then
> >         set leadingNumber to text 1 thru -2 of (found text of findReco)
> >         set text of selection to return & (leadingNumber + 1) & ". "
> >         select insertion point after selection
> >       else if found of findReco = false then
> >         set findReco to find "^\\* " searching in lineOfInsertionPoint
> > options {search mode:grep}
> >         if found of findReco = true then
> >           set text of selection to return & "* "
> >           select insertion point after selection
> >         end if
> >       end if
> >     end tell
> >   on error errMsg number errNum
> >     set sep to "=="
> >     set e to sep & return & "Error:

Re: Insert Next List Item

2012-03-27 Thread KG
@Kendall : just one more thing, can you provide a link to the latest 
source. from the url you provided i don't see the numbered list edit that 
you said you made

Thanks

On Tuesday, March 27, 2012 5:14:31 AM UTC+3, Kendall Conrad wrote:
>
> My Smart Newline script can achieve this. You can examine the code 
> near the top to see how I capture to white space at the start of the 
> line if that's all you care about. I also updated the script this 
> evening to also handle numbered lists, which was part of the original 
> discussion question, though this is a little late for that I suppose, 
> but others might find it useful. 
>
> http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/ 
>
> -Kendall 
>
> On Mar 26, 4:45 pm, KG  wrote: 
> > Hey Christopher, 
> > 
> > Just a minor request to your existing script. This works fantastically 
> if 
> > you line starts with the bullet. Assuming you have some indentation like 
> 4 
> > tab stops and then the bullet, the script stops. I made a couple of mods 
> to 
> > the script as follows: 
> > 
> > 
> ---
>  
>
> > tell application "BBEdit" 
> > try 
> > tell text of front text window 
> > set lineOfInsertionPoint to line (startLine of 
> selection) 
> > set findReco to find "^\\d+\\." searching in 
> > lineOfInsertionPoint options {search mode:grep} 
> > if found of findReco = true then 
> > set leadingNumber to text 1 thru -2 of (found text 
> of 
> > findReco) 
> > set text of selection to return & (leadingNumber + 
> 1) & 
> > ". " 
> > select insertion point after selection 
> > else if found of findReco = false then 
> > set findReco to find "^\\* " searching in 
> > lineOfInsertionPoint options {search mode:grep} 
> > if found of findReco = true then 
> > set text of selection to return & "* " 
> > select insertion point after selection 
> > else 
> > set findReco to find "^\\s*\\+" searching in 
> > lineOfInsertionPoint options {search mode:grep} 
> > if found of findReco = true then 
> > 
> > set text of selection to return & tab & "+ " 
> > select insertion point after selection 
> > end if 
> > end if 
> > end if 
> > end tell 
> > on error errMsg number errNum 
> > set sep to "==" 
> > set e to sep & return & "Error: " & errMsg & return & sep & 
> > return ¬ 
> > & "Error Number: " & errNum & return & sep 
> > beep 
> > display dialog e 
> > end try 
> > end tell 
> > 
> ---
>  
>
> > 
> > Essentially the \s* helps ignore white space at the beginning. There's 
> just 
> > one problem with my script. It inserts the new bullet point ignoring the 
> > previous number of tab stops. Is there a way in applescript to get hold 
> of 
> > the number of tab stops and insert that at the beginning as well? 
> > 
> > Thanks again. 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Monday, August 8, 2011 7:04:04 AM UTC+3, Christopher Stone wrote: 
> > 
> > > On Aug 07, 2011, at 21:35, oliver wrote: 
> > 
> > > I'm thinking it might have to be an AppleScript to select the line and 
> > > then call a Text Filter to handle finding the number/star and 
> appending the 
> > > next one... but my kung fu is not strong enough to figure it out. 
> > 
> > > __ 
> > 
> > > Hey Oliver, 
> > 
> > > This is very quick and dirty, but it'll work with the numerical 
> increment 
> > > and the asterisk bullet. 
> > 
> > > It's expecting the insertion point (cursor) to be at the end of the 
> line, 
> > > but it could easily be adjusted so that anywhere in the line would do. 
> > 
> > > You can put it in the script menu and give it a keyboard shortcut and 
> go 
> > > to town. 
> > 
> > > The logic is pretty straightforward, so you can add more characters 
> like 
> > > '•' to the mix if desired. 
> > 
> > > -- 
> > > Best Regards, 
> > > Chris 
> > 
> > > __ 
> > 
> > > tell application "BBEdit" 
> > >   try 
> > > tell text of front text window 
> > >   set lineOfInsertionPoint to line (startLine of selection) 
> > >   set findReco to find "^\\d+\\." searching in 
> lineOfInsertionPoint 
> > > options {search mode:grep} 
> > >   if found of findReco = true then 
> > > set leadingNumber to text 1 thru -2 of (found tex

Re: Insert Next List Item

2012-03-27 Thread KG
@Kendall : neat script. thanks again. 

@Kendall+Watts: One additional request-can the scripts be modified to pick 
the first character on the line and then use that as a bullet? for e.g any 
of the following could be bullets in my MD document ("+","-","*"). I have 
currently modified your scripts to take care of this, but rather than an 
if,else,if,else I thought it would be really cool to have the script 
automatically pick up the bullet character and insert.

Cheers and thanks for the great scripts.

On Tuesday, March 27, 2012 5:14:31 AM UTC+3, Kendall Conrad wrote:
>
> My Smart Newline script can achieve this. You can examine the code 
> near the top to see how I capture to white space at the start of the 
> line if that's all you care about. I also updated the script this 
> evening to also handle numbered lists, which was part of the original 
> discussion question, though this is a little late for that I suppose, 
> but others might find it useful. 
>
> http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/ 
>
> -Kendall 
>
> On Mar 26, 4:45 pm, KG  wrote: 
> > Hey Christopher, 
> > 
> > Just a minor request to your existing script. This works fantastically 
> if 
> > you line starts with the bullet. Assuming you have some indentation like 
> 4 
> > tab stops and then the bullet, the script stops. I made a couple of mods 
> to 
> > the script as follows: 
> > 
> > 
> ---
>  
>
> > tell application "BBEdit" 
> > try 
> > tell text of front text window 
> > set lineOfInsertionPoint to line (startLine of 
> selection) 
> > set findReco to find "^\\d+\\." searching in 
> > lineOfInsertionPoint options {search mode:grep} 
> > if found of findReco = true then 
> > set leadingNumber to text 1 thru -2 of (found text 
> of 
> > findReco) 
> > set text of selection to return & (leadingNumber + 
> 1) & 
> > ". " 
> > select insertion point after selection 
> > else if found of findReco = false then 
> > set findReco to find "^\\* " searching in 
> > lineOfInsertionPoint options {search mode:grep} 
> > if found of findReco = true then 
> > set text of selection to return & "* " 
> > select insertion point after selection 
> > else 
> > set findReco to find "^\\s*\\+" searching in 
> > lineOfInsertionPoint options {search mode:grep} 
> > if found of findReco = true then 
> > 
> > set text of selection to return & tab & "+ " 
> > select insertion point after selection 
> > end if 
> > end if 
> > end if 
> > end tell 
> > on error errMsg number errNum 
> > set sep to "==" 
> > set e to sep & return & "Error: " & errMsg & return & sep & 
> > return ¬ 
> > & "Error Number: " & errNum & return & sep 
> > beep 
> > display dialog e 
> > end try 
> > end tell 
> > 
> ---
>  
>
> > 
> > Essentially the \s* helps ignore white space at the beginning. There's 
> just 
> > one problem with my script. It inserts the new bullet point ignoring the 
> > previous number of tab stops. Is there a way in applescript to get hold 
> of 
> > the number of tab stops and insert that at the beginning as well? 
> > 
> > Thanks again. 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Monday, August 8, 2011 7:04:04 AM UTC+3, Christopher Stone wrote: 
> > 
> > > On Aug 07, 2011, at 21:35, oliver wrote: 
> > 
> > > I'm thinking it might have to be an AppleScript to select the line and 
> > > then call a Text Filter to handle finding the number/star and 
> appending the 
> > > next one... but my kung fu is not strong enough to figure it out. 
> > 
> > > __ 
> > 
> > > Hey Oliver, 
> > 
> > > This is very quick and dirty, but it'll work with the numerical 
> increment 
> > > and the asterisk bullet. 
> > 
> > > It's expecting the insertion point (cursor) to be at the end of the 
> line, 
> > > but it could easily be adjusted so that anywhere in the line would do. 
> > 
> > > You can put it in the script menu and give it a keyboard shortcut and 
> go 
> > > to town. 
> > 
> > > The logic is pretty straightforward, so you can add more characters 
> like 
> > > '•' to the mix if desired. 
> > 
> > > -- 
> > > Best Regards, 
> > > Chris 
> > 
> > > __ 
> > 
> > > tell application "BBEdit" 
> > >   try 
>

Re: Insert Next List Item

2012-03-27 Thread Kendall Conrad
The link I provided does have the latest code. If you visited the page 
somewhat recently you may need to do a refresh to see the latest changes. 
The code will state that is was last updated March 26 at the top of the 
code listing.

The updated code does handle doing lists that start with *, #, and -, but 
not +. I thought about it, but couldn't think of anytime I've seen it used. 
It would be very easy to add though to the code. Just edit the section 
"Check for lists" and add \\+ to the two regex finds. It has to be escaped 
since it's a special character for regex. I'll make an update when I get a 
chance, probably within the next 20 hours.

-Kendall

On Tuesday, March 27, 2012 2:18:19 AM UTC-4, KG wrote:
>
> @Kendall : just one more thing, can you provide a link to the latest 
> source. from the url you provided i don't see the numbered list edit that 
> you said you made
>
> Thanks
>
> On Tuesday, March 27, 2012 5:14:31 AM UTC+3, Kendall Conrad wrote:
>>
>> My Smart Newline script can achieve this. You can examine the code 
>> near the top to see how I capture to white space at the start of the 
>> line if that's all you care about. I also updated the script this 
>> evening to also handle numbered lists, which was part of the original 
>> discussion question, though this is a little late for that I suppose, 
>> but others might find it useful. 
>>
>> http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/ 
>>
>> -Kendall 
>>
>> On Mar 26, 4:45 pm, KG  wrote: 
>> > Hey Christopher, 
>> > 
>> > Just a minor request to your existing script. This works fantastically 
>> if 
>> > you line starts with the bullet. Assuming you have some indentation 
>> like 4 
>> > tab stops and then the bullet, the script stops. I made a couple of 
>> mods to 
>> > the script as follows: 
>> > 
>> > 
>> ---
>>  
>>
>> > tell application "BBEdit" 
>> > try 
>> > tell text of front text window 
>> > set lineOfInsertionPoint to line (startLine of 
>> selection) 
>> > set findReco to find "^\\d+\\." searching in 
>> > lineOfInsertionPoint options {search mode:grep} 
>> > if found of findReco = true then 
>> > set leadingNumber to text 1 thru -2 of (found text 
>> of 
>> > findReco) 
>> > set text of selection to return & (leadingNumber + 
>> 1) & 
>> > ". " 
>> > select insertion point after selection 
>> > else if found of findReco = false then 
>> > set findReco to find "^\\* " searching in 
>> > lineOfInsertionPoint options {search mode:grep} 
>> > if found of findReco = true then 
>> > set text of selection to return & "* " 
>> > select insertion point after selection 
>> > else 
>> > set findReco to find "^\\s*\\+" searching in 
>> > lineOfInsertionPoint options {search mode:grep} 
>> > if found of findReco = true then 
>> > 
>> > set text of selection to return & tab & "+ 
>> " 
>> > select insertion point after selection 
>> > end if 
>> > end if 
>> > end if 
>> > end tell 
>> > on error errMsg number errNum 
>> > set sep to "==" 
>> > set e to sep & return & "Error: " & errMsg & return & sep & 
>> > return ¬ 
>> > & "Error Number: " & errNum & return & sep 
>> > beep 
>> > display dialog e 
>> > end try 
>> > end tell 
>> > 
>> ---
>>  
>>
>> > 
>> > Essentially the \s* helps ignore white space at the beginning. There's 
>> just 
>> > one problem with my script. It inserts the new bullet point ignoring 
>> the 
>> > previous number of tab stops. Is there a way in applescript to get hold 
>> of 
>> > the number of tab stops and insert that at the beginning as well? 
>> > 
>> > Thanks again. 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > On Monday, August 8, 2011 7:04:04 AM UTC+3, Christopher Stone wrote: 
>> > 
>> > > On Aug 07, 2011, at 21:35, oliver wrote: 
>> > 
>> > > I'm thinking it might have to be an AppleScript to select the line 
>> and 
>> > > then call a Text Filter to handle finding the number/star and 
>> appending the 
>> > > next one... but my kung fu is not strong enough to figure it out. 
>> > 
>> > > 
>> __ 
>> > 
>> > > Hey Oliver, 
>> > 
>> > > This is very quick and dirty, but it'll work with the numerical 
>> increment 
>> > > and the asterisk bullet. 
>> > 
>> > > It's expecting the insertion point (cursor) to 

Re: Insert Next List Item

2012-03-28 Thread Kendall Conrad
For anyone that was waiting, I did update the script to include handling of 
+ listed items. I also added >. I made some other enhancements too while I 
was at it. The numerical listing handles both going 3. to 4., but also 2.4. 
to 2.5. so it handles decimal numbering or sub sections. Lastly, I added 
HTML list item support; it creates a  tags, copies the  tag's 
attributes from the current line, and duplicates them and also places the 
cursor inside the tag.

If you have visited the page before you'll likely need to hit refresh to 
ensure you're seeing the latest page updates. I haven't had a chance to do 
thorough testing so if you see issues or have other suggestions let me know.

http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/

-Kendall

On Tuesday, March 27, 2012 9:50:05 AM UTC-4, Kendall Conrad wrote:
>
> The link I provided does have the latest code. If you visited the page 
> somewhat recently you may need to do a refresh to see the latest changes. 
> The code will state that is was last updated March 26 at the top of the 
> code listing.
>
> The updated code does handle doing lists that start with *, #, and -, but 
> not +. I thought about it, but couldn't think of anytime I've seen it used. 
> It would be very easy to add though to the code. Just edit the section 
> "Check for lists" and add \\+ to the two regex finds. It has to be escaped 
> since it's a special character for regex. I'll make an update when I get a 
> chance, probably within the next 20 hours.
>
> -Kendall
>
> On Tuesday, March 27, 2012 2:18:19 AM UTC-4, KG wrote:
>>
>> @Kendall : just one more thing, can you provide a link to the latest 
>> source. from the url you provided i don't see the numbered list edit that 
>> you said you made
>>
>> Thanks
>>
>> On Tuesday, March 27, 2012 5:14:31 AM UTC+3, Kendall Conrad wrote:
>>>
>>> My Smart Newline script can achieve this. You can examine the code 
>>> near the top to see how I capture to white space at the start of the 
>>> line if that's all you care about. I also updated the script this 
>>> evening to also handle numbered lists, which was part of the original 
>>> discussion question, though this is a little late for that I suppose, 
>>> but others might find it useful. 
>>>
>>> http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/ 
>>>
>>> -Kendall 
>>>
>>> On Mar 26, 4:45 pm, KG  wrote: 
>>> > Hey Christopher, 
>>> > 
>>> > Just a minor request to your existing script. This works fantastically 
>>> if 
>>> > you line starts with the bullet. Assuming you have some indentation 
>>> like 4 
>>> > tab stops and then the bullet, the script stops. I made a couple of 
>>> mods to 
>>> > the script as follows: 
>>> > 
>>> > 
>>> ---
>>>  
>>>
>>> > tell application "BBEdit" 
>>> > try 
>>> > tell text of front text window 
>>> > set lineOfInsertionPoint to line (startLine of 
>>> selection) 
>>> > set findReco to find "^\\d+\\." searching in 
>>> > lineOfInsertionPoint options {search mode:grep} 
>>> > if found of findReco = true then 
>>> > set leadingNumber to text 1 thru -2 of (found text 
>>> of 
>>> > findReco) 
>>> > set text of selection to return & (leadingNumber + 
>>> 1) & 
>>> > ". " 
>>> > select insertion point after selection 
>>> > else if found of findReco = false then 
>>> > set findReco to find "^\\* " searching in 
>>> > lineOfInsertionPoint options {search mode:grep} 
>>> > if found of findReco = true then 
>>> > set text of selection to return & "* " 
>>> > select insertion point after selection 
>>> > else 
>>> > set findReco to find "^\\s*\\+" searching in 
>>> > lineOfInsertionPoint options {search mode:grep} 
>>> > if found of findReco = true then 
>>> > 
>>> > set text of selection to return & tab & "+ 
>>> " 
>>> > select insertion point after selection 
>>> > end if 
>>> > end if 
>>> > end if 
>>> > end tell 
>>> > on error errMsg number errNum 
>>> > set sep to "==" 
>>> > set e to sep & return & "Error: " & errMsg & return & sep 
>>> & 
>>> > return ¬ 
>>> > & "Error Number: " & errNum & return & sep 
>>> > beep 
>>> > display dialog e 
>>> > end try 
>>> > end tell 
>>> > 
>>> ---
>>>  
>>>
>>> > 
>>> > Essentially the \s* helps ignore white space at the beginning. There's 
>>> just 
>>> > one problem with my

Re: Insert Next List Item

2012-03-30 Thread KG
Rock on Sir !

On Wednesday, March 28, 2012 1:56:11 PM UTC+3, Kendall Conrad wrote:
>
> For anyone that was waiting, I did update the script to include handling 
> of + listed items. I also added >. I made some other enhancements too while 
> I was at it. The numerical listing handles both going 3. to 4., but also 
> 2.4. to 2.5. so it handles decimal numbering or sub sections. Lastly, I 
> added HTML list item support; it creates a  tags, copies the  tag's 
> attributes from the current line, and duplicates them and also places the 
> cursor inside the tag.
>
> If you have visited the page before you'll likely need to hit refresh to 
> ensure you're seeing the latest page updates. I haven't had a chance to do 
> thorough testing so if you see issues or have other suggestions let me know.
>
> http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/
>
> -Kendall
>
> On Tuesday, March 27, 2012 9:50:05 AM UTC-4, Kendall Conrad wrote:
>>
>> The link I provided does have the latest code. If you visited the page 
>> somewhat recently you may need to do a refresh to see the latest changes. 
>> The code will state that is was last updated March 26 at the top of the 
>> code listing.
>>
>> The updated code does handle doing lists that start with *, #, and -, but 
>> not +. I thought about it, but couldn't think of anytime I've seen it used. 
>> It would be very easy to add though to the code. Just edit the section 
>> "Check for lists" and add \\+ to the two regex finds. It has to be escaped 
>> since it's a special character for regex. I'll make an update when I get a 
>> chance, probably within the next 20 hours.
>>
>> -Kendall
>>
>> On Tuesday, March 27, 2012 2:18:19 AM UTC-4, KG wrote:
>>>
>>> @Kendall : just one more thing, can you provide a link to the latest 
>>> source. from the url you provided i don't see the numbered list edit that 
>>> you said you made
>>>
>>> Thanks
>>>
>>> On Tuesday, March 27, 2012 5:14:31 AM UTC+3, Kendall Conrad wrote:

 My Smart Newline script can achieve this. You can examine the code 
 near the top to see how I capture to white space at the start of the 
 line if that's all you care about. I also updated the script this 
 evening to also handle numbered lists, which was part of the original 
 discussion question, though this is a little late for that I suppose, 
 but others might find it useful. 


 http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/ 

 -Kendall 

 On Mar 26, 4:45 pm, KG  wrote: 
 > Hey Christopher, 
 > 
 > Just a minor request to your existing script. This works 
 fantastically if 
 > you line starts with the bullet. Assuming you have some indentation 
 like 4 
 > tab stops and then the bullet, the script stops. I made a couple of 
 mods to 
 > the script as follows: 
 > 
 > 
 ---
  

 > tell application "BBEdit" 
 > try 
 > tell text of front text window 
 > set lineOfInsertionPoint to line (startLine of 
 selection) 
 > set findReco to find "^\\d+\\." searching in 
 > lineOfInsertionPoint options {search mode:grep} 
 > if found of findReco = true then 
 > set leadingNumber to text 1 thru -2 of (found 
 text of 
 > findReco) 
 > set text of selection to return & (leadingNumber 
 + 1) & 
 > ". " 
 > select insertion point after selection 
 > else if found of findReco = false then 
 > set findReco to find "^\\* " searching in 
 > lineOfInsertionPoint options {search mode:grep} 
 > if found of findReco = true then 
 > set text of selection to return & "* " 
 > select insertion point after selection 
 > else 
 > set findReco to find "^\\s*\\+" searching in 
 > lineOfInsertionPoint options {search mode:grep} 
 > if found of findReco = true then 
 > 
 > set text of selection to return & tab & 
 "+ " 
 > select insertion point after selection 
 > end if 
 > end if 
 > end if 
 > end tell 
 > on error errMsg number errNum 
 > set sep to "==" 
 > set e to sep & return & "Error: " & errMsg & return & sep 
 & 
 > return ¬ 
 > & "Error Number: " & errNum & return & sep 
 > beep 
 > display dialog e 
 > end try 
 > end tell 
 > 
 -

Re: Insert Next List Item

2012-04-29 Thread Oliver Taylor
This is fantastic, thank you Sir.

On Wednesday, March 28, 2012 3:56:11 AM UTC-7, Kendall Conrad wrote:
>
> For anyone that was waiting, I did update the script to include handling 
> of + listed items. I also added >. I made some other enhancements too while 
> I was at it. The numerical listing handles both going 3. to 4., but also 
> 2.4. to 2.5. so it handles decimal numbering or sub sections. Lastly, I 
> added HTML list item support; it creates a  tags, copies the  tag's 
> attributes from the current line, and duplicates them and also places the 
> cursor inside the tag.
>
> If you have visited the page before you'll likely need to hit refresh to 
> ensure you're seeing the latest page updates. I haven't had a chance to do 
> thorough testing so if you see issues or have other suggestions let me know.
>
> http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/
>
> -Kendall
>
> On Tuesday, March 27, 2012 9:50:05 AM UTC-4, Kendall Conrad wrote:
>>
>> The link I provided does have the latest code. If you visited the page 
>> somewhat recently you may need to do a refresh to see the latest changes. 
>> The code will state that is was last updated March 26 at the top of the 
>> code listing.
>>
>> The updated code does handle doing lists that start with *, #, and -, but 
>> not +. I thought about it, but couldn't think of anytime I've seen it used. 
>> It would be very easy to add though to the code. Just edit the section 
>> "Check for lists" and add \\+ to the two regex finds. It has to be escaped 
>> since it's a special character for regex. I'll make an update when I get a 
>> chance, probably within the next 20 hours.
>>
>> -Kendall
>>
>> On Tuesday, March 27, 2012 2:18:19 AM UTC-4, KG wrote:
>>>
>>> @Kendall : just one more thing, can you provide a link to the latest 
>>> source. from the url you provided i don't see the numbered list edit that 
>>> you said you made
>>>
>>> Thanks
>>>
>>> On Tuesday, March 27, 2012 5:14:31 AM UTC+3, Kendall Conrad wrote:

 My Smart Newline script can achieve this. You can examine the code 
 near the top to see how I capture to white space at the start of the 
 line if that's all you care about. I also updated the script this 
 evening to also handle numbered lists, which was part of the original 
 discussion question, though this is a little late for that I suppose, 
 but others might find it useful. 


 http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/ 

 -Kendall 

 On Mar 26, 4:45 pm, KG  wrote: 
 > Hey Christopher, 
 > 
 > Just a minor request to your existing script. This works 
 fantastically if 
 > you line starts with the bullet. Assuming you have some indentation 
 like 4 
 > tab stops and then the bullet, the script stops. I made a couple of 
 mods to 
 > the script as follows: 
 > 
 > 
 ---
  

 > tell application "BBEdit" 
 > try 
 > tell text of front text window 
 > set lineOfInsertionPoint to line (startLine of 
 selection) 
 > set findReco to find "^\\d+\\." searching in 
 > lineOfInsertionPoint options {search mode:grep} 
 > if found of findReco = true then 
 > set leadingNumber to text 1 thru -2 of (found 
 text of 
 > findReco) 
 > set text of selection to return & (leadingNumber 
 + 1) & 
 > ". " 
 > select insertion point after selection 
 > else if found of findReco = false then 
 > set findReco to find "^\\* " searching in 
 > lineOfInsertionPoint options {search mode:grep} 
 > if found of findReco = true then 
 > set text of selection to return & "* " 
 > select insertion point after selection 
 > else 
 > set findReco to find "^\\s*\\+" searching in 
 > lineOfInsertionPoint options {search mode:grep} 
 > if found of findReco = true then 
 > 
 > set text of selection to return & tab & 
 "+ " 
 > select insertion point after selection 
 > end if 
 > end if 
 > end if 
 > end tell 
 > on error errMsg number errNum 
 > set sep to "==" 
 > set e to sep & return & "Error: " & errMsg & return & sep 
 & 
 > return ¬ 
 > & "Error Number: " & errNum & return & sep 
 > beep 
 > display dialog e 
 > end try 
 > end