Re: Inserting a breakpoint above the current line

2019-01-15 Thread Christopher Stone
On 01/15/2019, at 19:25, Venkat mailto:gvenkata1...@gmail.com>> wrote:
> Thank you so much! I don't know AppleScript very well, so I can't ask further 
> questions to understand what exactly you're doing  . 


Hey Venkat,

Here's a commented version that may help.

--
Best Regards,
Chris



# Create a variable with the text to be inserted.
set textToInsert to "pdb.set_trace()" & linefeed

tell application "BBEdit"
tell front text window

# Get the line where the cursor is.
set start_Line to startLine of selection

# Get the character offset of the cursor.
set character_Offset to characterOffset of selection

tell text of line start_Line

# Find any leading space in the line where the cursor is.
set findRec to find "^\\h+" options {search mode:grep, case 
sensitive:false, starting at top:false}

# Assign a variable to the text of the line where the cursor is.
set cLineText to its contents

end tell

# Assign a variable to the leading space of the line where the cursor 
is (if found).
# Otherwise assing an empty string to that same variable.
if found of findRec = true then
set leadingSpacePad to found text of findRec
else
set leadingSpacePad to ""
end if

# Change the contents of the line where the cursor is to: 
leadingSpacePad & textToInsert & cLineText
set contents of line start_Line to leadingSpacePad & textToInsert & 
cLineText

# Reposition the cursor to the same position in the moved line.
select insertion point after character (character_Offset + (length of 
leadingSpacePad) + (length of textToInsert) - 1)

end tell
end tell



-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, 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: How to Create Finder Folders from BBEdit Text List

2019-01-15 Thread Dave
If you have a space in a folder name, you’ll get two folders unless you quote 
it. Not what I’d call “blowing up.”

I only tried it with 330 names. I’m sure there’s a limit, but I don’t know what 
it is. If you need more folders, make more lists. Or use a loop if it makes you 
happy. 

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, 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: Inserting a breakpoint above the current line

2019-01-15 Thread Christopher Stone
On 01/15/2019, at 17:13, Venkat mailto:gvenkata1...@gmail.com>> wrote:
> What I want to do is if my cursor is anywhere on the c+=1 line, I want to 
> place a breakpoint line directly above it using a quick keyboard shortcut to 
> a clipping, so as to get this:


Hey Venkat,

That's a little bit tricky but not overly difficult.

--
Best Regards,
Chris


# Auth: Christopher Stone
# dCre: 2019/01/15 17:29
# dMod: 2019/01/15 18:30 
# Appl: BBEdit
# Task: Create Python Breakpoint at the Cursor.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Create, @Python, @Breakpoint, @Cursor


set textToInsert to "pdb.set_trace()" & linefeed
set insertTextLen to length of textToInsert

tell application "BBEdit"
tell front text window

set start_Line to startLine of selection
set character_Offset to characterOffset of selection

tell text of line start_Line
set findRec to find "^\\h+" options {search mode:grep, case 
sensitive:false, starting at top:false}
set cLineText to its contents
end tell

if found of findRec = true then
set leadingSpacePad to found text of findRec
else
set leadingSpacePad to ""
end if

set contents of line start_Line to leadingSpacePad & textToInsert & 
cLineText
select insertion point after character (character_Offset + (length of 
leadingSpacePad) + (length of textToInsert) - 1)

end tell
end tell



-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, 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.


Inserting a breakpoint above the current line

2019-01-15 Thread Venkat
I'm trying to replicate a behavior as close as possible to a package in 
Sublime Text. This concerns python, but I'm guessing it can be extended to 
other programming languages as well. I want to insert a breakpoint at the 
point at which I place a cursor. So in the current code block

for a in range(10):
   a+=1
   b+=1
   c+=1

What I want to do is if my cursor is anywhere on the c+=1 line, I want to 
place a breakpoint line directly above it using a quick keyboard shortcut 
to a clipping, so as to get this:

for a in range(10):
   a+=1
   b+=1
   pdb.set_trace()
   c+=1

where pdb.set_trace() is the command that inserts a python breakpoint at 
that point in the code. I know I can create clippings and map keyboard 
shortcuts to them. I was wondering if it was possible to take it a step 
further so that* the clipping is inserted in the line above where the 
cursor is, and is agnostic of cursor location in the line, and also obeys 
the indentation in code. *

Any help would be appreciated. Thank you.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, 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 problem inserting COPY NAME and looping it

2019-01-15 Thread Dante Majorana
Thanks Chris it works perfectly, unfortunately I am not an Applescript expert … 
and I used TextWranglers and now Bbedit trying to adjust the Applescript 
recordings with the little I knew … 
Dante
> On 11 Jan 2019, at 22:31, Christopher Stone  
> wrote:
> 
> On 01/11/2019, at 14:43, Dante Majorana  > wrote:
>> I open from a folder a series of files all included in one folder. Hence I 
>> have window with a number of files as documents.
> 
> 
> Hey Dante,
> 
> BBEdit is very recordable, but recording is really only good for getting the 
> general syntax of things.
> 
> To produce a finished script you have to know what you're doing and know what 
> to leave in, what to take out, and what to add.
> 
> This comes with experience.
> 
> Try this script and see if it does what you want – make sure to test with 
> TEST copies.
> 
> 
> # Auth: Christopher Stone
> # dCre: 2019/01/11 15:27
> # dMod: 2019/01/11 15:27 
> # Appl: BBEdit
> # Task: Prepend Document Name to Document Text.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @BBEdit, @Prepend, @Document, @Name, @Text
> 
> 
> tell application "BBEdit"
> 
> set frontWin to front text window
> set docIDList to ID of documents of frontWin whose on disk is true
> 
> repeat with docID in docIDList
> tell document id docID
> set before its text to its name & linefeed
> end tell
> end repeat
> 
> end tell
> 
> 
> 
> --
> Best Regards,
> Chris
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or need technical support, 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 need technical support, 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: How to Create Finder Folders from BBEdit Text List

2019-01-15 Thread ThePorgie
I couldn't get this to workSo as an absolute last resort I peeked at 
the manual. ;-). According to the manual "Control-Return" should be used. 
That worked like a charm for me.

On Wednesday, January 9, 2019 at 8:54:54 PM UTC-5, jajls wrote:
>
> On 2019 Jan 9, at 20:27, Bill Kochman > 
> wrote:
>
>
> I have a BBEdit text file with a list of about 300 folder names 
> alphabetically listed in it, one name per line. I need a script which will 
> take those 300 names, and create actual folders with those exact names on 
> my hard drive in a folder on my desktop
>
>
>
> Instead of a script, you could use a Shell Worksheet. File > New > Shell 
> Worksheet
>
> Copy your list into the worksheet, then use   Text > Prefix/Suffix Lines… 
>   to prefix each line with "mkdir ". (Be sure to include the space after 
> mkdir.)
> Now change to the container folder: Type on a new line "cd ", then drag 
> the outer folder and drop it so that the line reads, e.g.,
>
>cd ~/Desktop/theOuterFolder
>
> Select that line and type ⌘-Return.
>
> Now select all the mkdir lines (i.e., your list with the added prefixes), 
> and again type ⌘-Return.
>
> Done.
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, 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: How to Create Finder Folders from BBEdit Text List

2019-01-15 Thread Sam Hathaway

On 15 Jan 2019, at 8:04, Dave wrote:

mkdir accepts multiple arguments, so assuming you have a list of names 
called “foldernames.txt,” you can just enter:

mkdir `cat foldernames.txt`
instead of using a loop.


This will blow up if your list of folder names is too long, or if your 
folder names contain spaces.


--
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, 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.


How to Create Finder Folders from BBEdit Text List

2019-01-15 Thread Dave
mkdir accepts multiple arguments, so assuming you have a list of names called 
“foldernames.txt,” you can just enter:
mkdir `cat foldernames.txt`
instead of using a loop. 

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, 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.