Re: Applescript equivalent of Ctrl-O (open line)

2011-01-18 Thread Kendall Conrad
System events are certainly the easier (shorter) way to do it:
---
tell application "BBEdit" to tell front window
activate
tell application "System Events" to keystroke end
tell application "System Events" to keystroke return
tell application "System Events" to keystroke tab
end tell
---

Here is at least one way to do it with just BBEdit's capabilities:
---
tell application "BBEdit" to tell front window
set lineNum to startLine of selection
set leng to length of line lineNum
-- Move cursor to end of line
if leng > 0 then
select insertion point after (character (leng) of line lineNum)
end if
-- Find leading whitespace
set theResult to find "(^[\\s]*)" options {search mode:grep}
searching in line (lineNum)
-- Set text to the white space found
set white to ""
if found of theResult then
set white to found text of theResult
end if
-- Add extra indent
set white to white & tab
-- Insert a return plus the white space
set selection to return & white
select insertion point after selection
end tell
---

I assumed you were using tabs for indentation. A little surprisingly,
the BBEdit way executed quicker. The system events way also has issues
if you're holding down any modifier keys (e.g., command, control) as
those keys will be attached to the system events when it does the
keystroke. Not so great. I haven't thoroughly tested either solution
FYI.

-Kendall


On Jan 18, 5:31 pm, Watts Martin  wrote:
> I'm working on a little AppleScript that replicates a trivial but
> cherished feature of another editor -- being able to press Ctrl-Return
> (or whatever) and having it start the new line with an appropriate
> indent.
>
> My script does the right thing now as long as there's nothing on the
> line below where it's executed, but what I'd really like to have
> happen is the equivalent of the Open Line, i.e., when you invoke the
> script at the end of a line that's followed by another one, the second
> line is moved down:
>
> text here
>     |
> text here
>
> Since my script currently just inserts a return followed by the
> appropriate number of spaces or tabs to indent one tab stop past the
> start of the line it was invoked on, it makes a cheerful mess of
> things in this case. Using Open Line would be much better, I suspect
> -- but I can't figure out how to do so from the dictionary alone. Is
> there a way to actually invoke the Open Line command with BBEdit's
> dictionary, or do I need to go through System Events to pull this off?

-- 
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: 


Applescript equivalent of Ctrl-O (open line)

2011-01-18 Thread Watts Martin
I'm working on a little AppleScript that replicates a trivial but
cherished feature of another editor -- being able to press Ctrl-Return
(or whatever) and having it start the new line with an appropriate
indent.

My script does the right thing now as long as there's nothing on the
line below where it's executed, but what I'd really like to have
happen is the equivalent of the Open Line, i.e., when you invoke the
script at the end of a line that's followed by another one, the second
line is moved down:

text here
|
text here

Since my script currently just inserts a return followed by the
appropriate number of spaces or tabs to indent one tab stop past the
start of the line it was invoked on, it makes a cheerful mess of
things in this case. Using Open Line would be much better, I suspect
-- but I can't figure out how to do so from the dictionary alone. Is
there a way to actually invoke the Open Line command with BBEdit's
dictionary, or do I need to go through System Events to pull this off?

-- 
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: 


Applescript equivalent of Ctrl-O (open line)

2011-01-18 Thread Watts Martin
I'm working on a little AppleScript that replicates a trivial but
cherished feature of another editor -- being able to press Ctrl-Return
(or whatever) and having it start the new line with an appropriate
indent.

My script does the right thing now as long as there's nothing on the
line below where it's executed, but what I'd really like to have
happen is the equivalent of the Open Line, i.e., when you invoke the
script at the end of a line that's followed by another one, the second
line is moved down:

text here
|
text here

Since my script currently just inserts a return followed by the
appropriate number of spaces or tabs to indent one tab stop past the
start of the line it was invoked on, it makes a cheerful mess of
things in this case. Using Open Line would be much better, I suspect
-- but I can't figure out how to do so from the dictionary alone. Is
there a way to actually invoke the Open Line command with BBEdit's
dictionary, or do I need to go through System Events to pull this off?

-- 
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: Regex Find

2011-01-18 Thread Christopher Stone
On Jan 18, 2011, at 15:02, Ronald J Kimball wrote:
> Here's the approach I usually take for this kind of task:
> 
> ^(?>(?:(?!\.app).)*)\.app$
__

Hey Ronald,

I bow before the master.  :)

For Rick:

After looking at golem's approach I realized I'd could have provided better 
information:

I want to find the first instance of DEVONthink Pro.app but NOT .apps that it 
contains as in the 2nd line:

/Applications/Applications (Chris)/Data Storage Apps/DEVONthink Pro 
Office/DEVONthink Pro.app

/Applications/Applications (Chris)/Data Storage Apps/DEVONthink Pro 
Office/DEVONthink 
Pro.app/Contents/PlugIns/ExactScanPlugin.bundle/Contents/MacOS/ExactScan 
Capture.app

Fortunately Ronald understood what I was getting at and provided a solution 
that works nicely.

> But I also thought of a simpler approach in this case:
> 
> ^(?!.*\.app.*\.app).*\.app$

Aha!  I was trying to do this earlier, but I couldn't quite get the syntax 
right.

Thanks again Ronald.

I'm just getting into these assertions, and they're still making my head hurt.  
:)

Is there a good tutorial on how they work somewhere?  The BBEdit manual is a 
little light on examples.  (I do have "Mastering Regular Expressions", but it's 
not always an easy read. :)

--
Best Regards,
Chris

-- 
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: Regex Find

2011-01-18 Thread Rick
I think you will have to state the problem more precisely.

On Tue, Jan 18, 2011 at 11:29 AM, Christopher Stone
wrote:

> Hey Folks,
>
> I've been looking at positive and negative assertions until my head is
> spinning.  :)
>
> What I want to do is find the entirety of line 1 but *not* line 2:
>
> ./Address Book.app
> ./Address Book.app/Contents/CodeResources.app
>
> So I want to find a line that ends with ".app" but it cannot contain ".app"
> except at the end.
>
> TIA
>
> --
> Chris
>
>
> --
> 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: 
>

-- 
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: Regex Find

2011-01-18 Thread Ronald J Kimball
On Tue, Jan 18, 2011 at 01:29:50PM -0600, Christopher Stone wrote:
> Hey Folks,
> 
> I've been looking at positive and negative assertions until my head is 
> spinning.  :)
> 
> What I want to do is find the entirety of line 1 but *not* line 2:
> 
> ./Address Book.app
> ./Address Book.app/Contents/CodeResources.app
> 
> So I want to find a line that ends with ".app" but it cannot contain ".app" 
> except at the end.
> 

Here's the approach I usually take for this kind of task:

^(?>(?:(?!\.app).)*)\.app$

(?:(?!\.app).)* matches a substring that doesn't contain ".app".  It does
this by checking whether the next part of the string is ".app"; if it's
not, it matches one character, and repeats.

(?>...) prevents the regex from backtracking into its subexpression once it
matches.  We know that if the regex doesn't get to the end of the string,
backtracking isn't going to help.


But I also thought of a simpler approach in this case:

^(?!.*\.app.*\.app).*\.app$

That one uses a negative lookahead to make sure the string doesn't contain
.app twice, and then matches if it contains .app at the end of the string.

Ronald

-- 
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: Regex Find

2011-01-18 Thread golem
 (^[a-zA-Z0-9./ ]+.appr)
  BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }
 On Tue 11/01/18 14:29 , Christopher Stone  wrote:
 Hey Folks,
 I've been looking at positive and negative assertions until my head
is spinning.  :)
 What I want to do is find the entirety of line 1 but *not* line 2:
 ./Address Book.app
 ./Address Book.app/Contents/CodeResources.app
 So I want to find a line that ends with ".app" but it cannot contain
".app" except at the end.
 TIA
 --
 Chris
 -- 
 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 
 To unsubscribe from this group, send email to
 bbedit+
 For more options, visit this group at
 ;
 If you have a feature request or would like to report a problem, 
 please email "" rather than posting to the group.
 Follow @bbedit on Twitter: ;
 

-- 
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: 


Regex Find

2011-01-18 Thread Christopher Stone
Hey Folks,

I've been looking at positive and negative assertions until my head is 
spinning.  :)

What I want to do is find the entirety of line 1 but *not* line 2:

./Address Book.app
./Address Book.app/Contents/CodeResources.app

So I want to find a line that ends with ".app" but it cannot contain ".app" 
except at the end.

TIA

--
Chris


-- 
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: Where would I be today?

2011-01-18 Thread Simdude
BBedit is an awesome tool but if it didn't exist, you would become
proficient in another editor. I don't have the option of BBedit at
work because we mostly work with Linux so I've gotten good with vi.
I've seen experts in vi that do amazing things. The key is to take the
tool you like and learn it well.

BBedit works well because it's been around for a while and is well
polished. Rich and company are very careful not to throw in features
without careful thought. While I also like my version of vi (vim) the
thousands of plugins are a mixed blessing. I can find plugins to do
anything, but they often are not maintained and conflict with other
plugins. My configuration directory has hundreds of files in it now
and every update brings potential disaster.

I guess the point is get great at whatever you use. And also, thanks
for the tip about moving files. That's one I hadn't known about and
will remember when I'm working from home!

Mark

On Jan 16, 3:35 pm, Bucky Junior 
wrote:
> I just had a "Where would I be today?" moment with BBEdit.
>
> It was "What would I be doing if I didn't have BBEdit?" A very simple action 
> like moving one open file from one editing window to another (by dragging the 
> icon in the top bar) so I could see two files at once just reminded me how 
> much I depend on BBEdit _every_ day.
>
> This is really just a rhetorical question--by the way--I don't anticipate or 
> expect any comments or answers.
>
> Happy to be,
> Bucky

-- 
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: Need script or method to create a sitemap or site index

2011-01-18 Thread Stefano
On 15 Gen, 09:02, BBunny  wrote:
> The "Misc" menu in previous versions of BBEdit contained an "index"
> feature, which generated a hierarchical index—in other words, a sitemap
> —of a Web site, with live links to the pages. With version 9.6, that
> feature has been eliminated. Can anyone suggest a script or other easy
> way of replacing that function? Thanks much.

"The "Misc" menu on the Markup menu, and the commands on it, have
outlived their usefulness and been removed."
I can't just understand their debatable usefulness. I think Index
Document, Index Folder and Site were rather useful instead.
Maybe you know, now there is a Folder Listing (Edit -> Insert ->
Folder Listing). But then you have to add links with a careful search
and replace.

-- 
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: