Re: Old BBEdit versions?

2019-02-07 Thread Christopher Stone
On 02/07/2019, at 05:07, TJ Luoma mailto:luo...@gmail.com>> 
wrote:
> /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
>  -kill -r -domain local -domain system -domain user

There's nothing wrong with using the command line for this, but my go-to tool 
for such maintenance is Onyx.

https://www.titanium-software.fr/en/onyx.html 


  Maintenance (panel) > Rebuilding (tab)

The developer has kept it up-to-date and free for well over a decade now.

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


Re: Can't save project

2019-02-05 Thread Christopher Stone
On 02/05/2019, at 18:50, Barbara Snyder mailto:barb...@signalfx.com>> wrote:
> Ok so creating a new project saves it, but then I added files to it. Does it 
> just keep auto-saving?


Hey Barbara,

Yes, the project should auto-save as you go along...

You do have the full commercial version of BBEdit - yes?

What version?

What version of macOS?

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


Re: Can't save project

2019-02-05 Thread Christopher Stone
On 02/05/2019, at 17:02, Barbara Snyder mailto:barb...@signalfx.com>> wrote:
> ...Then I wanted to save the project, but the option was greyed out. 
> 
> So I started over - created a new project, added some files. Save Project is 
> still greyed out.


Hey Barbara,

When you create a project you have to save it immediately, so I think you're 
missing something.

BBEdit Menu Bar > File > New > Project...

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


Re: Pattern matching that will exclude items matching another pattern

2019-02-04 Thread Christopher Stone
On 02/04/2019, at 13:20, Jim Witte mailto:jim.wi...@gmail.com>> wrote:
> What I have is a list of words …


Hey Jim (and everyone),

When requesting help with Regular Expressions and or text-processing please 
always include sample text for both the search text and the desired result text.

These samples should be as real-world as possible.

Make believe samples often contain omissions or mistakes that make them 
unreliable for testing.

Regular Expressions are complex to really complex and require testing.

The easier you make it for people to test the more likely you'll get help in 
the first place – and the better quality that help will be in the second place.

As the old adage says: “A picture is worth a thousand words.”

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


Re: Faster method of opening Scratchpad with AppleScript

2019-01-24 Thread Christopher Stone
On 01/24/2019, at 09:25, Ben Smith mailto:benpto...@gmail.com>> wrote:
> Yep, I had the same thought after I made the post. :-) That method is fast 
> every time so I'll have to train myself to use hotkeys instead of Alfred. Odd 
> though.


Hey Ben,

Actually it's not that odd if I conjecture correctly and Alfred is using 
`osascript` to run a text AppleScript through the shell.

Keyboard Maestro is a trifle slower when using text AppleScript scripts as 
compared to compiled AppleScripts.

If you want the fastest possible AppleScript-runner you want to take a look at 
FastScripts .

The difference between it and Keyboard Maestro on my elderly 17" i7 MacBook Pro 
is not huge but is perceptible (to me).

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


Re: Another Applescript problem

2019-01-21 Thread Christopher Stone
On 01/21/2019, at 10:08, Rich Siegel mailto:sie...@barebones.com>> wrote:
> With a slight structural change to the script, you could use it in a "Run 
> AppleScript" step in a text factory. These can be applied to any combination 
> of files or folders. More on how to do this is in the user manual.


Hey Folks,

I don't normally think about Text Factories, because I personally find them 
awkward to work with compared to scripts (usually).

Nevertheless Rich's comment made me take a new look – since I hadn't for quite 
some time.

It was relatively trivial to turn the following shell script and AppleScript 
into two different Text Factories that operate on files in a specific folder 
path – thus saving a fair bit of scripting.


#!/usr/bin/env bash

sed '
3d
7d
9d
'


on ApplyTextTransform(fileData)
set fileData to paragraphs of fileData
set item 3 of fileData to 0
set item 7 of fileData to 0
set item 9 of fileData to 0
set fileData to text of fileData
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text 
item delimiters, linefeed}
set fileData to fileData as text
set AppleScript's text item delimiters to oldTIDS
return fileData
end ApplyTextTransform

** This AppleScript is NOT designed for huge files, although it runs nearly 
instantaneously on a 5000 line file on my system.


•• NOTE ••

To run on disk items a Text Factory MUST be located in BBEdit's Scripts folder:

~/Library/Application Support/BBEdit/Scripts/

To run on the front text document (or the selected text in it) a Text Factory 
must be located in the Text Filters folder:

~/Library/Application Support/BBEdit/Text Filters/

Text Factories are not completely intuitive, so it's a good idea to review them 
in BBEdit's User Manual.

Creating and Configuring Text Factories p.132

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


Re: Another Applescript problem

2019-01-20 Thread Christopher Stone
On 01/20/2019, at 15:34, Dante Majorana mailto:the.d@gmail.com>> wrote:
> With the standard "choose folder with prompt" as I might have folders in 
> various disks and the main hard drive in documents, desktop ...


Hey Dante,

Well, the simplest method for non-shell-heads is probably:

--------
# Auth: Christopher Stone
# dCre: 2019/01/20 23:32
# dMod: 2019/01/20 23:37
# Appl: BBEdit, Finder
# Task: Process Files in a User Chosen Folder.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Finder, @Process, @Files, @Folder


tell application (path to frontmost application as text)
set targetFolder to choose folder
end tell

tell application "Finder"
set fileList to files of targetFolder as alias list
end tell

tell application "BBEdit"
repeat with theFile in fileList
open theFile
tell front text window
delete line 3
delete line (7 - 1)
delete line (9 - 2)
save its document
close
end tell
end repeat
end tell



You should be able to read the script and tell what it's doing, but let me know 
if anything is opaque.

Now then – if you're brave and want a faster solution – you can quickly change 
the files in-place with `sed` in a shell script.

HEED the WARNINGS! listed in the script header!

This shell script will be faster and more transparent than the AppleScript.


#!/usr/bin/env bash
# ------
# Auth: Christopher Stone
# dCre: 2019/01/21 00:16
# dMod: 2019/01/21 01:21
# Task: Delete Lines 3, 7, and 9 from files in the front Finder Window.
# Tags: @ccstone, @Shell, @Script, @Delete, @Lines, @Front, @Finder, @Window
# --

# WARNINGS!

# This script operates on the FRONTMOST Finder Window.

# Files are CHANGED in-place and are NOT backed up first.

# Test with TEST files – NOT production files!

# --

# set -x # Debugging on/off

export LC_ALL="en_US.UTF-8"

read -r -d '' asCmdStr <<'EOF'
   try
  tell application "Finder"
 return POSIX path of (target of front window as alias)
  end tell
   on error errMsg
  return errMsg
   end try
EOF

asResult=$(osascript -e "$asCmdStr");

if [[ "$asResult" == "Can’t "* ]]; then

   echo "$asResult";
   
   # Ideally throw an error message here...

else

   targetDir="$asResult";

   cd "$targetDir";

   oldIFS=$IFS;
   IFS=$'\n';

   for filePath in $('ls' -1)
do
  sed -i "" '
3d
7d
9d
  ' "$filePath"
done

   IFS=$oldIFS;

fi


While this script can run from BBEdit (or another shell-script runner) just 
fine, I personally would run it using a keyboard shortcut via FastScripts 
<https://www.red-sweater.com/fastscripts/> in the Finder.

NOTE – At the moment there is NO “Are You Sure You Wan't to Do this?” dialog – 
it's run and done.

--
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: <https://www.twitter.com/bbedit>
--- 
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: Another Applescript problem

2019-01-20 Thread Christopher Stone
On 01/19/2019, at 12:05, Dante Majorana mailto:the.d@gmail.com>> wrote:
> How can I loop this to a folder of choice?


Hey Dante,

How do you want to choose this folder?

Front Finder window?

An Open dialog?

A fixed Path?

Does the folder have any subfolders in it?

Approximately how many files will you deal with at a time?

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


Re: Saved search with shortcut

2019-01-19 Thread Christopher Stone
On 01/19/2019, at 11:44, MJ BLUE mailto:kaposia2...@gmail.com>> wrote:
> I tried to create an apple script with this but was unsuccessful.
> 
> I don't want to perform the search, I just want my saved search to come up 
> with a keystroke instead of having to go into the FIND mode and select the 
> saved search. (I'm having to do this every other minute.)


Hey MJ,

Give this a try:

tell application "BBEdit"
tell front text window's text
replace "MATCH" using "REPLACE" options {search mode:grep, case 
sensitive:false, starting at top:true}
end tell
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.


Re: Want to strip text out of closed captions to send my father who's partially disabled.

2019-01-18 Thread Christopher Stone
On 01/18/2019, at 20:00, Dj mailto:futurevint...@gmail.com>> wrote:
> Hello, my father is hard of hearing and I'd like to send him some closed 
> caption files so he can read the content like you would a book. Is there an 
> easy way to strip data out of the below example so it's only text, and not 
> timestamps and tags?


Hey Dj,

BBEdit already has a command to convert HTML to Text, so part of that's easy.

You can do it from BBEdit > MenuBar > MarkUp > Utilities > Translate HTML to 
Text

Or more conveniently for automating you can do it with AppleScript.

Then let's add in a little find/replace, and Poof!  Job done.

When trying to do this sort of thing often best to have a look around Google 
first.

Google Search:

regex how to remove html tags

The second hit is pretty good:

https://www.regextester.com/93515 <https://www.regextester.com/93515>

I'm not using that, since I'm letting BBEdit do the work for me in this case – 
but I have used that pattern in other cases.

--
Take Care,
Chris

--------
# Auth: Christopher Stone
# dCre: 2019/01/18 23:14
# dMod: 2019/01/18 23:14 
# Appl: BBEdit
# Task: Convert HTML to Text and Use RegEx to Remove SubTitle Stamps.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Convert, @HTML, @Text, @RegEx, 
@Remove, @SubTitle, @Stamps


tell application "BBEdit"
tell front text window

translate html to text entity conversion true ¬
tag removal true ¬
paragraph conversion true ¬
create new document true ¬
without selection only

tell its text
replace "^(\\d{4}|\\d{2}:\\d{2}:.+)\\R?" using "" options {search 
mode:grep, case sensitive:false, starting at top:true}
end tell

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: <https://www.twitter.com/bbedit>
--- 
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: Delete space at the beginning of line

2019-01-18 Thread Christopher Stone
On 01/18/2019, at 20:02, Cecily Walker mailto:cecily.wal...@gmail.com>> wrote:
> When I tried this, I got an error that read: "This pattern cannot be used, 
> because PCRE reported an error: quantifier does not follow a repeatable item 
> (109)"


Hey Cecily,

That's odd.  How are you accessing the post on BBEdit-Talk?

Via email client or via the web (and which browser)?

I'm wondering if your medium added some nasty invisible characters to the 
pattern.

Paste into BBEdit and show invisibles to look.

Use the Zap Gremlins feature to replace oddball characters with a bullet 
character, so you can visualize them.

> This is the one that finally worked!

Das ist gut.

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


Re: Another Applescript problem

2019-01-18 Thread Christopher Stone
On 01/18/2019, at 16:57, Dante Majorana mailto:the.d@gmail.com>> wrote:
> My goal is to delete the same PARAGRAPHS in a series of TXT files
> 
> The paragraphs I need to delete are always the same
> 
> Beginning from par at line 9, then . line 7 then line 3


Hey Dante,

You can do that like this:


tell application "BBEdit"
tell front text window
delete line 9
delete line 7
delete line 3
end tell
end tell


Or like this:


tell application "BBEdit"
tell front text window
delete line 3
delete line (7 - 1)
delete line (9 - 2)
end tell
end tell


Or you can use a text filter like this:

#!/usr/bin/env bash

sed '
3d
7d
9d
'

The text filter is a bit more efficient, because it does everything at once – 
and therefore undo is only 1 step instead of 3.

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


Re: Delete space at the beginning of line

2019-01-18 Thread Christopher Stone
On 01/18/2019, at 14:45, Cecily Walker mailto:cecily.wal...@gmail.com>> wrote:
> I'm really struggling with Grep and trying to write a pattern that deletes 3 
> spaces at the beginning of each line.


Hey Cecily,

I tend to write patterns like that this way:

^ {3}

OR

^[ ]{3}

Surrounding the space with a class helps make it pop out when you read it.

{3} is an enumerator that means 3 of the character or group before it.

> I have the text of a recipe file that was formerly a numbered list (HTML). 
> When I copied the text, it retained the spaces. I'd like to remove the spaces 
> at the beginning of every line. What is the correct pattern to make this 
> happen? 


What I'd probably start with is something more generic:

^\h+|\h+$

^  ==  Start of line
\h ==  Horizontal whitespace
+  ==  One or more
|  ==  OR
\h ==  Horizontal whitespace
+  ==  One or more
$  ==  End of line

This will strip leading and trailing whitespace from each line.

Only when I have cases where there's other spacing I need to keep will I get 
specific like the first couple of patterns.

I have BBEdit Text Filters written that do many of these jobs, and a couple of 
keystrokes gets me to them.

I also have many saved regular expressions in Typinator, so I have quick access 
to them.

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


Re: How to Create Finder Folders from BBEdit Text List

2019-01-18 Thread Christopher Stone
On 01/16/2019, at 19:03, Dave mailto:dave.live...@gmail.com>> wrote:
> Thanks, Chris. I've always used that literal newline inside single quotes in 
> scripts and the command-line, but people think there's something wrong when 
> they see that continuation prompt. 


Hey Dave,

The specific point is that the script does everything.  The user only has to 
provide the text file with the directory list.

On the other hand I do prefer to use a token for a newline character, because 
it reads more clearly for me.

oldIFS=$IFS; IFS=$'\n'; mkdir `cat ~/Downloads/test.txt`; IFS=$oldIFS

In this case Bash 4.4.23 on macOS Sierra 10.12.6 won't convert a double-quoted 
string into a newline for the IFS parameter, so I had to resort to using a C 
string.

--
Take Care,
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.


Re: How to Create Finder Folders from BBEdit Text List

2019-01-16 Thread Christopher Stone
On 01/16/2019, at 08:56, Dave mailto:dave.live...@gmail.com>> wrote:
> I have a correction to make. I don't think there's actually any way to escape 
> the spaces or quote the folder names in list like this, so if you need to use 
> folder names with spaces (something I avoid, btw) what you need to do is to 
> remove the space charater from the $IFS environment variable, e.g.


Hey Dave,

Something like this will work:

oldIFS=$IFS; IFS=$'\n'; mkdir `cat ~/Downloads/test.txt`; IFS=$oldIFS

--
Take Care,
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.


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: 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: <https://www.twitter.com/bbedit>
--- 
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: One-liner to replace multiple spaces between words (only words) with one space isn't working

2019-01-14 Thread Christopher Stone
On 01/14/2019, at 12:32, ThePorgie mailto:thepo...@gmail.com>> wrote:
> Using the double space leaves two spaces intact after a sentence if desired.


Hey There,

Nicely done!  

Here's another way to write that that makes it easy to read:

(?https://www.twitter.com/bbedit>
--- 
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: One-liner to replace multiple spaces between words (only words) with one space isn't working

2019-01-13 Thread Christopher Stone
On 01/13/2019, at 03:06, Marek Stepanek mailto:ms...@podiuminternational.org>> wrote:
> I did not know \h = horizontal white space. And it is even working with 
> BBEdit. Is it mentioned in the User Manual BBEdit? Suggesting a little 
> correction:


Hey Marek,

Then you'll want to contact support, because Rich and Patrick are not 
guaranteed to read the user list.

In any case – keep in mind that BBEdit uses PCRE (Perl Compatible Regular 
Expressions) and generally (but not perfectly) follows the PCRE specification:

https://www.pcre.org/original/doc/html/pcrepattern.html 


Curated change Log:

http://www.rexegg.com/pcre-documentation.html 


You'll see that \h, \H, \v, \V, and \R have been around for quite a while.

> Your search and replace is not doing what Dj was asking for ...

So?

My pattern is quite intentionally more flexible and handles spaces, 
non-breaking-spaces, and tabs.

Dj is smart enough to decide if he prefers his method or mine for this purpose.

> I am wondering, why you want to put it into a perl-script and not directly in 
> search and replace of BBEdit. 

Is that a question for Dj or me?

I save a lot of time and effort by having a variety of pre-made BBEdit text 
filters.

I even built a Keyboard Maestro macro to make them easier to use.



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


Re: One-liner to replace multiple spaces between words (only words) with one space isn't working

2019-01-13 Thread Christopher Stone
On 01/12/2019, at 19:32, Dj mailto:futurevint...@gmail.com>> wrote:
> I'm only trying to change space between words and not carriage returns and 
> all that. So far I've tried placing this in the scripts folder:
> 
> perl -pe 's/ +/ /g'


Hey Dj,

The code you have above is the sort of thing that would normally be embedded in 
a shell script or used directly from the command line.

Here's a more normal Perl script that would be used as a text-filter in BBEdit, 
and it does exactly what your code above does.

* Lines 2-5 are optional depending upon what you're doing, but I'm allowing for 
UTF8 text requiring that the Perl used be at least v5.010 (which is pretty old 
by now)


#!/usr/bin/env perl -sw
use v5.010;
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8"); 

while (<>) {
s/\h+/ /g;
print;
}


The -p switch in your script above stands in for this while structure, and it 
provides for the script to die quietly when it runs out of data to process.

That exact structure looks like this:


#!/usr/bin/env perl -sw

while (<>) {
# your program goes here
} continue {
print or die "-p destination: $!\n";
}


The -e switch in your script above stands for execute, so Perl knows to execute 
the quoted text.

You can find all of the command line switches by pasting “perldoc run” into the 
Terminal and typing Return.

You can also paste “perldoc run” into a BBEdit Shell Worksheet, make sure the 
cursor is on that line, and hit Enter.

This will give you the same text as in the Terminal, but you'll have access to 
BBEdit's search functions.

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


Re: One-liner to replace multiple spaces between words (only words) with one space isn't working

2019-01-12 Thread Christopher Stone
On 01/12/2019, at 19:32, Dj mailto:futurevint...@gmail.com>> wrote:
> I'm only trying to change space between words and not carriage returns and 
> all that. So far I've tried placing this in the scripts folder:
> 
> perl -pe 's/ +/ /g'


Hey Dj,

All shell scripts have to have a legitimate shebang line identifying what kind 
of script is to run.

In your case if you want to run at Perl one-liner you need to id your script as 
Bash (or another shell that runs Perl).

This will work:

#!/usr/bin/env bash
perl -pe 's/\h+/ /g'

I've changed your  to \h for horizontal whitespace.

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


Entable - BBEdit, TextWrangler, Nedit Filter

2019-01-12 Thread Christopher Stone
Hey Folks,

I found a useful plug-in for BBEdit called `entable`.

It's a plain old Perl script, so it can be used as a text-filter in BBEdit or 
from the command line.

http://entable.s3.amazonaws.com/index.html 


I've changed the shebang/use block in my copy to better support Unicode text:


#!/usr/bin/perl -sw
use v5.010; # ccs
use utf8;   # ccs
binmode(STDIN, ":utf8");# ccs
binmode(STDOUT, ":utf8");   # ccs


Simple usage as a BBEdit text-filter once installed in /usr/local/bin/

Taking tab as the column delimiter:


#!/usr/bin/env bash
entable INTAB


Place a minimum of 5 spaces between columns:


#!/usr/bin/env bash
entable INTAB -s 5


Pretty slick.  

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


Re: Applescript problem inserting COPY NAME and looping it

2019-01-11 Thread Christopher Stone
On 01/11/2019, at 14:43, Dante Majorana mailto:the.d@gmail.com>> 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: <https://www.twitter.com/bbedit>
--- 
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-11 Thread Christopher Stone
On 01/11/2019, at 07:09, Dante Majorana mailto:the.d@gmail.com>> wrote:
> I open a series of text files and launch the Applescript Facilities setting 
> them to record.
> However Applescript doesn't record this action when I click on Edit->copy 
> path->Copy Name
> As I need to add the filename only in the sequence of files how do I add the 
> proper syntax to the open Applescript window?


Hey Dante,

I'm not following what you're trying to do.

Can you describe the overall workflow without AppleScript?

If so I should be able to advise.

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


Re: How to Create Finder Folders from BBEdit Text List

2019-01-11 Thread Christopher Stone
On 01/11/2019, at 01:18, Bill Kochman mailto:wordweaver...@gmail.com>> wrote:
> Are you saying that I need to paste in a long list of the folder names in 
> that variable? If so, do I need to separate that by commas, or spaces, or one 
> name per line, or what?


Hey Bill,

See how I've placed the folder names 1 per line here:

set folderNameList to paragraphs 2 thru -2 of "
Folder 01
Folder 02
Folder 03
"

I'm doing all the work for you by transforming a text list into an AppleScript 
list.

So all you have to do is paste your list into the variable in place of the 
current 3 item list.

Run my script as is from the Applescript Editor and see how it works.

Change a couple of the names and try that.

You should then have a feel for how the script works.

On the other hand – if you want to send me your complete name list I can write 
you a working script.

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


Re: How to Create Finder Folders from BBEdit Text List

2019-01-09 Thread Christopher Stone
On 01/09/2019, at 19:27, Bill Kochman mailto:wordweaver...@gmail.com>> wrote:
> Basically, 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.


Hey Bill,

I'm assuming you want to be able to reuse this at need, so I think a 
self-contained script is the way to go.

Here's how to do that with AppleScript.

Place your folder name list in the variable folderNameList, run the script, and 
go-to-town.

Save it as an AppleScript using the Applescript Editor to this folder:

~/Library/Application Support/BBEdit/Scripts/

Run it from the script menu or give it a handy keyboard shortcut.

--
Best Regards,
Chris

----
# Auth: Christopher Stone
# dCre: 2019/01/09 21:50
# dMod: 2019/01/09 21:50 
# Appl: Finder
# Task: Create a new folder-set on the Desktop from a Name List.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Finder, @Create, @Folder-set, @Set, @Desktop, 
@Name, @List


try

set desktopFolderName to "New Folder Set"

set folderNameList to paragraphs 2 thru -2 of "
Folder 01
Folder 02
Folder 03
"

tell application "Finder"
if folder desktopFolderName of desktop exists then
error "Folder " & desktopFolderName & "already exists on the 
Desktop!"
else
set newFolder to (make new folder at desktop with properties 
{name:desktopFolderName}) as alias
repeat with i in folderNameList
make new folder at newFolder with properties {name:i}
end repeat
activate
reveal newFolder
end if
end tell

on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set 
ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error 
Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try



-- 
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: <https://www.twitter.com/bbedit>
--- 
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: BBEdit/TextWrangler markers lost when files moved

2019-01-08 Thread Christopher Stone
On 01/08/2019, at 02:02, Tibor Páli mailto:palitiborlas...@gmail.com>> wrote:
> However, the markers are different (not syncing) in the same document on the 
> two computers. Adding, changing, deleting markers in one computer is not 
> replicated in the other.
> Maybe the markers do not belong anymore to the DocumentState?
> I am on Mac OSX 10.13.6 and BBEdit 12.5.2


Hey Tibor,

Okay, you better contact support.

Bare Bones Software mailto:supp...@barebones.com>>

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


Re: Noob trying to improve on these grep / expressions

2019-01-05 Thread Christopher Stone
On 01/04/2019, at 20:59, Dj mailto:futurevint...@gmail.com>> wrote:
> The last couple things I'm curious about before doing a deeper dive... To 
> remove all text between paranthesis (and also the parenthesis), what would 
> that expression be? 


Hey Dj,

Something like this:

\([^)]+\)

1. Literal open Paren.
2. Any character not close Paren, 1 or more
3. Literal close Paren

> How about only extracting the last sentence of each paragraph?   No biggie, 
> if that's asking too much, appreciate the time you've given here.

Something like this:

(?<=\A|[.?!]|\v)[^.?!\v]+[.?!](?=\v|\z)

(?<=\A|[.?!]|\v)  ==  Positive Lookbehind for Start of Text, End Punctuation, 
or Vertical Whitespace.
[^.?!\v]+ ==  Any character NOT end punctuation or vertical whitespace, 
1 or more.
[.?!] ==  End punctuation.
(?=\v|\z) ==  Positive Lookahead for vertical whitespace or End of Text.

This is unsophisticated, because there is no provision for possible quoting.

But it'll do for now.  :)

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


Re: Noob trying to improve on these grep / expressions

2019-01-05 Thread Christopher Stone
On 01/04/2019, at 13:44, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> RegExRX seems to have gone dormant five years ago. 
> Do you have any news/updates regarding newer/better approaches, if any?


Hey Alfredo,

Good news – I heard back from Kem Tekinay the developer of RegExRX (see 
appended).

--
Best Regards,
Chris


Begin forwarded message:

From: Kem Tekinay
Subject: Re: [MTC WEBSITE] Software Support
Date: Jan 04, 2019 at 22:36:46 CST
To: Christopher Stone

Me too! :-)

Yes, I rely on it too, so I’ll be doing that before it actually makes a 
difference.

Thanks.

> On Jan 4, 2019, at 2:53 PM, Christopher Stone wrote:
> 
> RegExRX is a 32-bit app.
> 
> Are you going to update it to 64-bit.
> 
> I for one would sure appreciate it.


-- 
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: <https://www.twitter.com/bbedit>
--- 
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: Noob trying to improve on these grep / expressions

2019-01-04 Thread Christopher Stone
On 01/04/2019, at 13:44, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> RegExRX seems to have gone dormant five years ago. 
> 
> Do you have any news/updates regarding newer/better approaches, if any?


Hey Alfredo,

Crud.  I didn't realize it was a 32-bit app.

You can find it here:

http://www.mactechnologies.com/index.php?page=downloads#regexrx 

And you can drop the developer a note requesting an update.  (I just did.)

I usually start building a regular expression with BBEdit.

If I'm having trouble I usually go to Patterns.

But there are times when RegExRx is better, so I hope the dev gets on his 
keyboard and drums out some new code.

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


Re: Replace Script w/ Date Conversion

2019-01-04 Thread Christopher Stone
On 01/04/2019, at 09:56, 'Holger Bartel' via BBEdit Talk 
mailto:bbedit@googlegroups.com>> wrote:
> I have a bunch of .yaml files in which I would like to replace/add one value 
> with a timestamp, which needs to be created from two other fields/values. I 
> think this needs the help of a filter/shell script and I’d love a pointer in 
> the direction of how to achieve this.


Hey Holger,

It would be useful to have a couple of actual example files.

You need to explain how you plan to access the files – what your actual 
workflow looks like.

It appears that you're transforming from normal date/time to epoch time - yes?

That transformation will definitely require some scripting.

You say you need to replace/add one value – what does that mean?

Are you needing to remove both the date and time stamps and replace them with 
the “Eventtimestamp”?

Or are you needing to simply add the “Eventtimestamp” after the other stamps?

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


Re: Noob trying to improve on these grep / expressions

2019-01-03 Thread Christopher Stone
On 01/01/2019, at 13:47, Dj mailto:futurevint...@gmail.com>> wrote:
> From what I see with your results, I think this is getting me to the place of 
> "good enough" for this problem.


Hey Dj,

Very good.

> So the embarrasing part, I've tried to take your text and make a shell script 
> to place in the script folder. I followed directions from a tutorial that had 
> me run a command from terminal to make the text into a script: 

I believe I gave you instructions on how to use a BBEdit Text Filter.

You do not need to make the script executable.

> I then tried it in the apple script editor, plugged your text below into 
> there and then saved it as a .scpt.

This can never work, because the Applescript Editor is for AppleScript.

The Perl script is a shell script.

> I'm sure the daunting initial hurdles will start to make more sense.

Yes.  Everyone who starts this journey feels lost at sea for a while.

> This whole text was the correct format to make a script from without Perl 
> right?

Right.


#!/usr/bin/env perl -0777 -sw
use v5.12;
use utf8;

my $text = <>;
my @array = $text =~ /(\b\w[^.!]+?\?)/gms;
$, = "\n";
say @array;


Paste the above into a BBEdit text document.

Save it in this directory:

~/Library/Application Support/BBEdit/Text Filters/

(If the directory doesn't exist then create it.)

Give the script a descriptive name like:

MyPerlScript.pl

Run it on the front document (or selection in the front document) from the:

Text > Apply Text Filter > YourScriptName

Menu.


AppleScript is very useful, but it's a whole different animal.

Paste this into the Applescript Editor:

tell application "BBEdit"
activate
make new text document with properties {text:"My First AppleScript!"}
end tell

And click the run button or type Cmd-R.

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


Re: Noob trying to improve on these grep / expressions

2018-12-31 Thread Christopher Stone
On 12/31/2018, at 13:54, Dj mailto:futurevint...@gmail.com>> wrote:
> Mike, that makes a lot more sense now. I looked at page for the Module and it 
> seems it's run from terminal and OSX has perl pre-installed?


Hey Dj,

BBEdit can run shell scripts as Text-Filters, and they do not need to be run 
from the Terminal.

BBEdit text-filters operate on the selection if there is one, otherwise they 
operate on the whole front document.

Text filters are installed here:

~/Library/Application Support/BBEdit/Text Filters/

Text filters are run from:

BBEdit Menu Bar > Text > Apply Text Filter > 

And of course you can give them keyboard shortcuts in BBEdit's Menus & 
Shortcuts preferences.

http://www.bbeditextras.org/wiki/index.php?title=Text_Filters 


See the User Manual for more details.

> Or is it a "module" than can be run somehow from within BBEdit?

Perl comes pre-installed on macOS, although it's usually a fairly old version.

The module Mike recommends is something you the user have to install, and 
that's probably more complication than you want to mess with.

For that matter it doesn't really do the job in and of itself.  It requires 
additional coding.

A Perl script using the Lingua module that'll run as a BBEdit Text Filter would 
looks something like this:


#!/usr/bin/env perl -0777 -sw
use v5.12;
use utf8;
use Lingua::EN::Sentence qw( get_sentences add_acronyms );

my $text = <>;

add_acronyms('lt','gen'); ## adding support for 'Lt. Gen.'
my $sentences = get_sentences($text); ## Get the sentences.

foreach my $sentence (@$sentences) {
   if ( $sentence =~ /(\b\w[^.!]+?\?)/ ) {
  say $1;
   }
}


It produces this:

—Eskimo proverb What can be added to the happiness of man who is in health, out 
of debt, and has a clear conscience?
—Adam Smith Do you prefer that you be right, or that you be happy?
What am I doing right?
—Tom Walsh Why not seize the pleasure at once?
How often is happiness destroyed by preparation, foolish preparation?
Unhappiness Is anyone in all the world safe from unhappiness?
—Vauvenargues Why is it that so many people are afraid to admit that they are 
happy?
—Maurice Maeterlinck Who is the happiest of men?
Da vies Is life so wretched?
Isn't it rather your hands which are too small, your vision which is muddled?
—Marcus Cato the Elder If you haven't forgiven yourself something, how can you 
forgive others?
—Mark Twain How shall I love the sin, yet keep the sense, And love the 
offender, yet detest the offence?
—George Macdonald Who would care to question the ground of forgiveness or 
compassion?
—Socrates Who Is Really Poor?
—Japanese proverb Who Is Really Rich?
—Colette Was it always my nature to take a bad time and block out the good 
times, until any success became an accident and failure seemed the only truth?
Next to what?


Which is nearly the same result as my plain regular expression.

I can accomplish the same result as the script using the Lingua module without 
using it:


#!/usr/bin/env perl -0777 -sw
use v5.12;
use utf8;

my $text = <>;
my @array = $text =~ /(\b\w[^.!]+?\?)/gms;
$, = "\n";
say @array;


Perl is a wonderful tool for parsing text, but learning it requires a pretty 
sizable investment.

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


Re: Noob trying to improve on these grep / expressions

2018-12-31 Thread Christopher Stone
On 12/31/2018, at 13:49, Dj mailto:futurevint...@gmail.com>> wrote:
> can I ask where you ran that expression in BBedit? Just menu ---> search 
> > find. 


Hey Dj,

Beginning around v11.0 BBEdit has had an “Extract” button in the Find dialog.




Find:

\b\w[^.!]+?\?

Replace:

Nothing

Using your test text I get this:

Eskimo proverb What can be added to the happiness of man who is in health, out 
of debt, and has a clear conscience?
Adam Smith Do you prefer that you be right, or that you be happy?
What am I doing right?
Tom Walsh Why not seize the pleasure at once?
How often is happiness destroyed by preparation, foolish preparation?
Unhappiness Is anyone in all the world safe from unhappiness?
Vauvenargues Why is it that so many people are afraid to admit that they are 
happy?
Maurice Maeterlinck Who is the happiest of men?
Da vies Is life so wretched?
Isn't it rather your hands which are too small, your vision which is muddled?
Marcus Cato the Elder If you haven't forgiven yourself something, how can you 
forgive others?
Mark Twain How shall I love the sin, yet keep the sense, And love the offender, 
yet detest the offence?
George Macdonald Who would care to question the ground of forgiveness or 
compassion?
Socrates Who Is Really Poor?
Japanese proverb Who Is Really Rich?
Colette Was it always my nature to take a bad time and block out the good 
times, until any success became an accident and failure seemed the only truth?
Next to what?

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


Re: Noob trying to improve on these grep / expressions

2018-12-30 Thread Christopher Stone
On 12/29/2018, at 11:53, Dj mailto:futurevint...@gmail.com>> wrote:
> Hello,  I'm trying to extract every sentence that ends with a question from 
> some text files. I'm using the old text wrangler -> process lines ->  copy to 
> new document, but I'm still getting a lot of sentences that don't end in 
> question marks in that new text.


Hey Dj,

Please use BBEdit 12 if you have macOS 10.12 or later.

Even when it reverted to lite mode after the 30 day trial it's way more 
powerful than TextWrangler.

Please provide an example of the text you're working with – making sure to 
include text that results in a failure with your patterns.

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


Re: Using grep to do a automatic numerotation

2018-12-22 Thread Christopher Stone
On 12/21/2018, at 14:16, Alex gat mailto:alex.garacot...@gmail.com>> wrote:
> I have that very long text file, made of several paragraphs. Each paragraphs 
> is separated by a double carriage return (\n\n).
> 
> What I'd like to do is to replace each \n\n by a number that automatically 
> increase for each occurrence.
> 
> What grep function should I be using in the replace text field.


Hey Alex,

Plain grep isn't up to doing the calculations for that little task.

Do I understand correctly?  You want to go from this:

one

two

three

four

five

To this:

1. one
2. two
3. three
4. four
5. five

Yes?

That's easy enough to do with a little bit of Perl in a BBEdit Text Filter:


#!/usr/bin/env perl -sw
use utf8;

$/ = "\n\n";
my $cntr = 0;

while (<>) {
   print ++$cntr.". ";
   chomp;
   print;
   print "\n";
}


For details on how to work with text filters look in the user manual, but 
here's the basics:

BBEdit text-filters operate on the selection if there is one, otherwise they 
operate on the whole front document.

Text filters are installed here:

~/Library/Application Support/BBEdit/Text Filters/

Text filters are run from:

BBEdit Menu Bar > Text > Apply Text Filter > 

And of course you can give them keyboard shortcuts in BBEdit's Menus & 
Shortcuts preferences.

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


Re: GREP help: dig into the report of the cash register

2018-12-07 Thread Christopher Stone
On 12/06/2018, at 13:44, Christopher Stone mailto:listmeis...@suddenlink.net>> wrote:
> Here's an updated script that produces cleaner output.
> From here I would probably turn the output into tab-delimited single lines.


Hey Marco,

The newest incarnation of the script (appended) produces output like this:

1   130,00  ABCDEF12G34H567I22-04-2017
2   100,00  ABCDEF12G34H567I22-04-2017
3   260,00  LMNOPQ89R01S234T22-04-2017
5   23,00   LMNOPQ89R01S234T22-04-2017

I can write another script that will parse these into variables that can be 
inserted into your web page.

Each pass will show a line item as processed like so:

[✓] 1   130,00  ABCDEF12G34H567I22-04-2017

If you set the windows of your web browser and BBEdit up just so, you can get 
realtime visual feedback on each pass.

--
Best Regards,
Chris

----
# Auth: Christopher Stone
# dCre: 2018/12/04 16:04
# dMod: 2018/12/07 02:43
# Appl: BBEdit
# Task: Extract Cash Register Info.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Extract, @Cash, @Register, @Info, 
@BBEdit-Talk
# Vers: 1.02


set AppleScript's text item delimiters to ""

tell application "BBEdit"
tell front text window's text

replace "^\\h+EURO\\h*\\n" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^\\h+$" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "\\h+$" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "\\n{2,}" using "\\n" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^N\\.SCONTR\\.FISCALE.*" using "&\\n" options {search 
mode:grep, case sensitive:false, starting at top:true}
replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}

set docText to its text
set AppleScript's text item delimiters to linefeed & linefeed
set recordList to text items of docText

repeat with i in recordList
if contents of i does not contain "C.F." then
set contents of i to missing value
end if
end repeat

set recordList to (text of recordList) as text
set its text to recordList

replace "^(?>(?:(?!(?:t_fiscale|C\\.F\\.|\\d{2}-\\d{2}-\\d{4}|TOTALE 
EURO)).)*)$\\R?" using "" options {search mode:grep, case sensitive:false, 
starting at top:true}

replace "^t_fiscale" using "\\n&" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}

replace "^t_fiscale \\d{8} \\d{4} *" using "" options {search 
mode:grep, case sensitive:false, starting at top:true}
replace "^TOTALE EURO\\h+" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "C\\.F\\.\\h*" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^(\\d{2}-\\d{2}-\\d{4})\\h+\\d{2}:\\d{2}" using "\\1" options 
{search mode:grep, case sensitive:false, starting at top:true}
replace "(?<=\\w)\\R(?=\\w)" using "\\t" options {search mode:grep, 
case sensitive:false, starting at top:true}
replace "^$\\R" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}

select insertion point before it

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: <https://www.twitter.com/bbedit>
--- 
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: GREP help: dig into the report of the cash register

2018-12-06 Thread Christopher Stone
On 12/06/2018, at 11:30, m.osti mailto:mk0...@gmail.com>> 
wrote:
> of course, this way the result is even cleaner and easier then to use


Hey Marco,

Here's an updated script that produces cleaner output.

>From here I would probably turn the output into tab-delimited single lines.

Because from there it's easy to write a macro to extract the data and insert it 
into your web page one line at a time.

--
Best Regards,
Chris

----
# Auth: Christopher Stone
# dCre: 2018/12/04 16:04
# dMod: 2018/12/06 13:37
# Appl: BBEdit
# Task: Extract Cash Register Info.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Extract, @Cash, @Register, @Info, 
@BBEdit-Talk
# Vers: 1.01


set AppleScript's text item delimiters to ""

tell application "BBEdit"
tell front text window's text

replace "^\\h+EURO\\h*\\n" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^\\h+$" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "\\n{2,}" using "\\n" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^N\\.SCONTR\\.FISCALE.*" using "&\\n" options {search 
mode:grep, case sensitive:false, starting at top:true}
replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}

set docText to its text
set AppleScript's text item delimiters to linefeed & linefeed
set recordList to text items of docText

repeat with i in recordList
if contents of i does not contain "C.F." then
set contents of i to missing value
end if
end repeat

set recordList to (text of recordList) as text
set its text to recordList

replace "^(?>(?:(?!(?:t_fiscale|C\\.F\\.|\\d{2}-\\d{2}-\\d{4}|TOTALE 
EURO)).)*)$\\R?" using "" options {search mode:grep, case sensitive:false, 
starting at top:true}

replace "^t_fiscale" using "\\n&" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}

replace "^t_fiscale \\d{8} \\d{4} *" using "" options {search 
mode:grep, case sensitive:false, starting at top:true}
replace "^TOTALE EURO\\h+" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "C\\.F\\.\\h*" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^(\\d{2}-\\d{2}-\\d{4})\\h+\\d{2}:\\d{2}" using "\\1" options 
{search mode:grep, case sensitive:false, starting at top:true}

select insertion point before it

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: <https://www.twitter.com/bbedit>
--- 
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: GREP help: dig into the report of the cash register

2018-12-04 Thread Christopher Stone
On 12/04/2018, at 04:19, m.osti mailto:mk0...@gmail.com>> 
wrote:
> Hello, every day when I have to close up my shop I get this report from the 
> cash register. I have the obligation to transmit some sales data through a 
> web page, and I have to insert one receipt at a time, sigh.
> Only sales that have the "C.F." are valid.


Hey M.,

This is a bit of a sticky problem, so I'm not surprised you had problems when 
relying on grep alone.

Run this AppleScript from the Applescript Editor against your register tape in 
BBEdit.

I believe I've extracted the relevant data from the tape.  If so then we need 
another pass to get just the values you want.

>From there it shouldn't be hard to pop those values into Keyboard Maestro 
>variables for insertion into your web page.

--
Best Regards,
Chris

--------
# Auth: Christopher Stone
# dCre: 2018/12/04 16:04
# dMod: 2018/12/04 16:04 
# Appl: BBEdit
# Task: Extract Cash Register Info.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Extract, @Cash, @Register, @Info, 
@BBEdit-Talk


set AppleScript's text item delimiters to ""

tell application "BBEdit"
tell front text window's text

replace "^\\h+EURO\\h*\\n" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^\\h+$" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "\\n{2,}" using "\\n" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "^N\\.SCONTR\\.FISCALE.*" using "&\\n" options {search 
mode:grep, case sensitive:false, starting at top:true}
replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}

set docText to its text
set AppleScript's text item delimiters to linefeed & linefeed
set recordList to text items of docText

repeat with i in recordList
if contents of i does not contain "C.F." then
set contents of i to missing value
end if
end repeat

set recordList to (text of recordList) as text
set its text to recordList

replace "^(?>(?:(?!(?:t_fiscale|C\\.F\\.|\\d{2}-\\d{2}-\\d{4}|TOTALE 
EURO)).)*)$\\R?" using "" options {search mode:grep, case sensitive:false, 
starting at top:true}
replace "^t_fiscale" using "\\n&" options {search mode:grep, case 
sensitive:false, starting at top:true}
replace "\\A\\s+|\\s+\\Z" using "" options {search mode:grep, case 
sensitive:false, starting at top:true}

select insertion point before it

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: <https://www.twitter.com/bbedit>
--- 
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: What about BBEdit attracts you to the program over others?

2018-11-27 Thread Christopher Stone
On 11/26/2018, at 18:59, Cerulean mailto:ceruleanf...@gmail.com>> wrote:
> I am just curious why someone may decide to choose BBEdit over other 
> programs, what draws does it have that others don't?


Hey Cerulean,

It's a solid editor with a large tool-set, and it's probably the most 
AppleScriptable application available for the Mac.

The developer is long-standing, reliable, and approachable.

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


Re: What about BBEdit attracts you to the program over others?

2018-11-27 Thread Christopher Stone
On 11/27/2018, at 08:15, Gauvins mailto:gauvi...@gmail.com>> wrote:
> Wrt to critical features... The ability to run Python in the terminal and 
> color schemes come to mind, but it mischaracterizes my appreciation.


Hey Gauvins,

Huh?

That's very vague.  Please be more specific.

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


Re: Assign shortcut to ctrl-Move to New Window?

2018-11-27 Thread Christopher Stone
On 11/20/2018, at 21:20, Gauvins mailto:gauvi...@gmail.com>> wrote:
> thanks. probably too obvious for my aging brain... :/


Hey Gauvins,

When looking for commands in Mac apps always try the search field in the Help 
Menu.

It will find any menu item whether or not it is active.

As of v12.5 BBEdit has it's own Commands menu item in the Go menu, so we have a 
more optimized way to find commands.

The only downside is that BBEdit's Commands menu won't find inactive 
(greyed-out) commands, so you have to keep that in mind when looking for things.

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


Re: Assigning BBEdit to be the editor for Xcode

2018-11-10 Thread Christopher Stone
On 11/09/2018, at 11:39, Michael Brian Bentley mailto:mercu...@gmail.com>> wrote:
> I'd like to be able to work from BBEdit, keying off of a finder window-like 
> pane. Just to shut my co-worker up. Am I a bad person to desire this? :)


Hey Michael,

Read up on Using Projects on page 66 of the User Manual (available from the 
Help menu).

Be sure not to overlook the Open File by Name command in the File menu.

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


Re: Remove Tooltip over file name

2018-11-10 Thread Christopher Stone
On 11/09/2018, at 12:18, Berny mailto:scouser.be...@gmail.com>> wrote:
> Is it possible to turn off the tooltip that pops up when the mouse hovers 
> over a file name in the "Currently Open Documents" column?


Hey Berny,

Not from BBEdit as far as I know.

But this method probably still works:

https://www.macworld.com/article/1055202/termtooltips.html 


TinkerTool  and Onyx can set them 
as well if you prefer a UI, but the timing options will be more limited.

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


Re: Easy way to open .html files in BBEdit vs. browser?

2018-10-28 Thread Christopher Stone
On 10/27/2018, at 11:51, Allen Watson mailto:watson.al...@gmail.com>> wrote:
> Thanks for the explanation. I had overlooked the double-tap settings in 
> BBEDit’s Preferences. I’m leaving “Instant Send” set to Double Control; I far 
> too offten double tap Cmd without meaning to. But I did not know at all about 
> the extra bonus of holding the key down. It works for me even though “B” 
> alone isn’t enough to select BBEdit, I have to type B-B. But holding the 
> second B, bingo! Instant open! Wonderful.


Hey Allen,

You can deliberately set the abbreviation for an item in LaunchBar by selecting 
it in the main UI and typing Cmd-Opt-A – so you can get “B” for BBEdit if you 
want it.

--
Take Care,
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.


Re: Easy way to open .html files in BBEdit vs. browser?

2018-10-28 Thread Christopher Stone
On 10/28/2018, at 02:57, Vlad Ghitulescu mailto:v...@ghitulescu.de>> wrote:
> I always wanted to ask: Doesn't Keyboard Maestro does already all what 
> FastScripts does? Or is it the "Fast"-part that matters (I read once 
> somewhere that FastScripts holds the compiled scripts in the memory)? Why 
> both?


Hey Vlad,

Why FastScripts?

I have nearly 600 AppleScripts that are mostly hotkey-driven.

FastScripts runs them faster than Keyboard Maestro – enough so I notice on my 
older hardware, although on newer hardware this may be less of an issue.

FastScripts is specifically designed to work with Apple's on-disk script 
hierarchy (similarly to Apple's own AppleScript menu), but FS adds global and 
app-specific keyboard shortcuts and a better user interface.

FastScripts has a keyboard shortcut for opening its menu, and this allows 
type-selecting scripts to run.

The FastScripts menu works more reliably with type-select than the Keyboard 
Maestro status menu.

I run AppleScripts from compiled-script-files rather than text-scripts, because 
there is a distinct performance advantage – FastScripts is a more convenient 
mechanism for managing AppleScripts than Keyboard Maestro.

I can open a script for editing by depressing the Option-key when selecting it 
from the FastScripts menu.

I can reveal the script in the Finder by depressing the Shift-key when 
selecting it from the FastScripts menu.

FastScripts uses a different mechanism to run AppleScripts than Keyboard 
Maestro, so I can use it to test with if Keyboard Maestro is choking on 
something and see whether KM is the problem or not.

Because of the different AppleScript-runner mechanism, FastScripts will run 
some AppleScriptObjC code that Keyboard Maestro won’t.

FastScripts gives me a second means of running AppleScripts and shell scripts, 
so I can offload jobs that take time on it (or KM) and still have the other 
unencumbered.

I do drive a very few pure AppleScript macros from Keyboard Maestro, because on 
occasion I get better performance – but I’m more likely to use AppleScripts 
with Keyboard Maestro when they are part of a larger macro.

FastScripts lets me work with the Keyboard Maestro Editor without involving 
Keyboard Maestro which is especially useful if I’ve quit the engine.

There are other reasons that have cropped up over the last 15 years, but I 
don’t remember all of them.

--
Take Care,
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.


Re: bbedit command line tools won't install

2018-10-26 Thread Christopher Stone
On 10/25/2018, at 19:18, Brandon Walter mailto:b...@macfaqulty.com>> wrote:
> I'm unable to install the Command Line tools from the app.


Hey Brandon,

What version of BBEdit?

What version of macOS?

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


Re: Easy way to open .html files in BBEdit vs. browser?

2018-10-26 Thread Christopher Stone
On 10/25/2018, at 17:50, @lbutlr mailto:krem...@kreme.com>> 
wrote:
> I find Typinator does what I need since it allows executing shell scripts.


Hey Lewis,

I've used Typinator for about 10 years and think it's the best text-expansion 
tool available for the Mac.

Typinator  (€24.99) will run shell 
scripts and AppleScripts in addition to doing boilerplate text expansion, so 
it's very flexible – but it has limitations that make me look to other 
utilities for other functionality.

Keyboard Maestro can do most anything Typinator can do, but Typinator does what 
it does more smoothly and has a better UI for snippet organization.

I think I'll keep it around for the foreseeable future.  :)

--
Take Care,
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.


Re: Easy way to open .html files in BBEdit vs. browser?

2018-10-25 Thread Christopher Stone
On 10/22/2018, at 19:34, Jean-Christophe Helary mailto:brandel...@gmail.com>> wrote:
> And Chris will probably jump in to talk about Fastscript or some other 
> wondermagical solution he has 


Hey David,

LaunchBar  is my go-to utility 
for this sort of trick.

FastScripts  ($9.95 U.S) is a 
flexible AppleScript/ShellScript runner menu that I have over 600 scripts for 
(and counting) – most of which have keyboard shortcuts.  (It allows for global 
and app-specific hotkeys -- The Demo mode restricts the number of hotkeys to 10 
but has no other handicap.)

I have several scripts that open selected files in the Finder in specific apps 
(I'd have more if it wasn't for LaunchBar).

Keyboard Maestro  ($36.00 U.S) is 900lb 
gorilla of automation utilities currently available for the Mac.

Since 2003-2004 I've used both FastScripts and Keyboard Maestro to save 
thousands of hours of time and much wear and tear on me.

And let's not forget BBEdit's own script menu – you can easily emplace an 
AppleScript with a keyboard shortcut to open selected files in the Finder.


tell application "Finder" to set finderSelectionList to selection as alias list

if finderSelectionList ≠ {} then
tell application "BBEdit"
open finderSelectionList
end tell
end if


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


Re: Auto-select search selected when text is selected

2018-10-25 Thread Christopher Stone
On 10/20/2018, at 11:31, John Springer mailto:jory...@gmail.com>> wrote:
> Just thought maybe I could do it with AppleScript, but apparently BBEdit has 
> no entry in the script dictionary for "search in selection".  It's the only 
> option not there.  :-(


Hey John,

You can search/replace in the only the selection with AppleScript:


tell application "BBEdit"
tell selection
replace ".+" using "" options {search mode:grep}
end tell
end tell


You cannot (un)set the checkbox in the Find dialog – at least not without an 
AppleScript-Runner utility like FastScripts or Keyboard Maestro.

(BBEdit's own script menu doesn’t like UI-Scripting BBEdit.)

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


Re: Applescript to replace selected text only using grep pattern

2018-10-19 Thread Christopher Stone
On 10/14/2018, at 23:04, Christian Boyce mailto:mac...@christianboyce.com>> wrote:
> I know you already have an answer but I think it's good to know how to 
> restrict an AppleScript "replace" in BBEdit to the selected text. I had this 
> problem myself once.
> 
> This is how I'd do it (and it works!)


Hey Christian,

That can be simplified a bit.  :)

tell application "BBEdit"
tell selection to replace using "calc(" & its text & " * .625)" options 
{search mode:grep, starting at top:true}
end tell

--
Take Care,
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.


Re: Grep: pattern_2 NOT preceded by pattern_1 (with pattern_1 not necessarily IMMEDIATELY to the left of pattern_2)

2018-10-19 Thread Christopher Stone
On 10/19/2018, at 17:14, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> P.S.
> Your previous suggestion had a slightly undesired side effect: It erased all 
> of my backups, locally and in the Cloud. Other than this minor inconvenience, 
> it was a good exercise ;-)


Hey Alfredo,

Eh

How?

In any case – never test on vital data files...

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


Re: Way to stop minimised windows appearing on app focus?

2018-10-19 Thread Christopher Stone
On 10/17/2018, at 13:18, Bruce Van Allen mailto:b...@cruzio.com>> wrote:
> I think that might be an OS thing, not unique to BBEdit. I tried two other 
> apps and they both did the same thing.


Bruce is right.

This even happens in the Finder.

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


Re: Grep: pattern_2 NOT preceded by pattern_1 (with pattern_1 not necessarily IMMEDIATELY to the left of pattern_2)

2018-10-19 Thread Christopher Stone
On 10/13/2018, at 12:26, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> Did you mean to use the same name for both patterns?


Hey Alfredo,

No.  That was a goof up.

I also misplaced a character.

Try this:

^(?>(?:(?!ostracized_string).))*wanted_string.*$

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


Re: Grep: pattern_2 NOT preceded by pattern_1 (with pattern_1 not necessarily IMMEDIATELY to the left of pattern_2)

2018-10-13 Thread Christopher Stone
On 10/12/2018, at 16:03, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> I would like to craft an expression to find lines that contain pattern_2 NOT 
> preceded by pattern_1
> (with pattern_1 not necessarily IMMEDIATELY to the left of pattern_2).


Hey Alfredo,

It's a best-practice to provide one or more real-world data-samples when making 
this sort of request.

In any case this is the sort of thing you're looking for:

^(?>(?:(?!pattern_1).)*)pattern_1$

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


Re: I believe that SOME non-greedy quantifier(s) SOMEWHERE might help

2018-10-05 Thread Christopher Stone
On 10/04/2018, at 10:09, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> After doing lots of exercises using your example, this greedy vs. non-greedy 
> challenge WILL be conquered. Once this concept is clear, everything becomes 
> clear.


Hey Alfredo,

Did you wrap your head around the Greedy vs Non-Greedy issue yet?

It's really very simple in concept.

First Possible Match vs. Last Possible Match.

Using this test data:


12345678901234567890123456789012345678901234567890


Greedy:

1.+0

Non-Greedy:

1.+?0


Using this test data:


/sbin/md5 ~/'test_directory/01_movie_test_file.mov' /sbin/md5 
~/'test_directory/02_movie_test_file.mov'


/sbin/md5 ~/'test_directory/03_movie_test_file.mov'


Non-Greedy:

^\S.+?movie_test_file\.mov

Greedy:

^\S.+movie_test_file\.mov


Adding other modifiers changes the constraints of what can be found.

(?s) allows . to match EOL characters and therefore span lines.

Non-Greedy:

(?s)^\S.+?movie_test_file\.mov

Greedy:

(?s)^\S.+movie_test_file\.mov


HTH.

--
Take Care,
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.


Re: wildcard search question

2018-09-27 Thread Christopher Stone
On 09/27/2018, at 16:18, Limore Ricciardi mailto:lim...@gmail.com>> wrote:
> I basically want to replace these two lines with one line, leaving the 
> variable in tact.
> 
> so it will look like this:


Hey Limore,

That's easy enough.


Find:

(item2)\.X-ABRELATEDNAMES;type=pref:(.+)\n\1.+

Replace:

CATEGORIES:\2


I'm suspecting though data is more complex than your sample implies, so this 
pattern might need an embellishment or two.

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


Re: Organizing Docs in a Notebook App and Editing in BBEdit

2018-09-24 Thread Christopher Stone
On 09/24/2018, at 13:15, Vlad Ghitulescu mailto:v...@ghitulescu.de>> wrote:
> I have discovered recently EagleFiler and I use it daily ever since
> for archived email messages;
> for scanned documents (= PDFs) and
> for TXT (and MD and TASKPAPER) documents
> and it has a context-menu "Open in BBEdit"
> 
> that does just this.
> 
> In addition to this I have created a local Git-repository with the folder 
> where EagleFiler stores the TXT-files so the versioning is now as easy as Git.
> 


Hey Vlad,

Thanks.

I've been looking for an excuse to buy EagleFiler for a while, and you just 
pushed me over the edge. 



--
Take Care,
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.


Re: Changed grep engine after update?

2018-09-24 Thread Christopher Stone
On 09/23/2018, at 13:04, Marek Stepanek mailto:ms...@podiuminternational.org>> wrote:
> A strange phenomenon happened:
> 
> In my Perl Script the pattern
> ...
> does not matches Umlauts. For example:


Hey Marek,

I'm observing something similar.

I'd suggest reporting the issue to support.

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


Re: Batch search-and-replace

2018-09-11 Thread Christopher Stone
On 09/11/2018, at 12:21, Andrew Brown mailto:li...@c18.org>> 
wrote:
> Hi Chris. version 12.1.5 (410102, 64-bit). Best — A.


Hey Andrew,

Then you are quite correct.

Canonize does not support grep.

You might consider making a formal feature request (see the message footer).

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


Re: Batch search-and-replace

2018-09-11 Thread Christopher Stone
On 09/11/2018, at 10:01, Andrew Brown mailto:li...@c18.org>> 
wrote:
> Have I understood correctly that Canonize will not handle grep ?


Hey Andrew,

What version of BBEdit are you using?

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


Re: Changing the contents of the new HTML file template?

2018-09-09 Thread Christopher Stone
On 09/09/2018, at 15:59, @lbutlr mailto:krem...@kreme.com>> 
wrote:
> The manual seems short not he directions on how to creat a stationery item, 
> btw. I saved a BBEdit file in the folder, doesn’t show up. I used the Finder 
> to mark the file as a stationary pad, doesn’t show up. I removed the .html 
> file extension, doesn’t show up.


Hey Lewis,

User manual: Templates p. 273

“A template is a simple text file that contains boilerplate text or HTML 
content that will form the foundation for the document you are creating. 
Template files must have the file name suffix “.tmpl” in order to be 
recognized.”

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


Re: Batch search-and-replace

2018-09-09 Thread Christopher Stone
On 09/09/2018, at 01:02, Andrew Brown mailto:li...@c18.org>> 
wrote:
> My BBEdit scripts went down with some earlier computer and I am looking for a 
> search-and-replace for grep and non-grep on multiple folders or files.


Hey Andrew,

That covers a lot of ground.

Disparate files and folders?

Files and folders in the same tree?

Here's one example:

----
# Auth: Christopher Stone
# dCre: 2014/10/29 07:10
# dMod: 2018/09/09 14:04
# Appl: BBEdit
# Task: Find and Replace in Files On-Disk.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Find, @Replace, @Files, @Disk

use AppleScript version "2.4"
use framework "Foundation"
use scripting additions


# The Search Folder reference can be either an alias or a posix path or a posix 
file.

set searchFolderPath to "~/test_directory/Find_and_Replace_It_Test/"

if searchFolderPath starts with "~" then
set searchFolderPath to ((current application's NSString's 
stringWithString:searchFolderPath)'s stringByExpandingTildeInPath) as text
end if



set findStr to "good men"
set replStr to "I want my MTV!"


tell application "BBEdit"
replace findStr using replStr searching in searchFolderPath ¬
options {search mode:grep, case sensitive:false, showing results:false} 
¬
saving true ¬
recursion true ¬
with text files only
end tell


> I also need to convert HTML to text in batch mode, with the options that 
> BBEdit offers for single file conversions.

If you want to do this in batch mode then a Text Factory is probably the way to 
go.

--
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: <https://www.twitter.com/bbedit>
--- 
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: Is there any way to ask BBEdit to use double-click to select "words" with embedded periods?

2018-09-09 Thread Christopher Stone
On 09/08/2018, at 12:34, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> I’ll study John Gruber’s notes and I’ll implement variatio(n) on his theme(s).


Hey Alfredo,

You can also use BBEdit find function via AppleScript to get very sophisticated.



tell application "BBEdit"
tell front text window's text
set findRec to find "public\\S+" options ¬
{search mode:grep ¬
, starting at top:false ¬
, case sensitive:false ¬
, backwards:false ¬
, returning results:true ¬
} ¬
with selecting match
end tell
end tell



I've used AppleScript's continuation character (¬) to make the option list 
vertical for easier reading, although because of the way the silly AppleScript 
compiler works it's not exactly pretty.

You can find forward and backward from the current cursor location and then 
make a selection based on your findings.

Gruber's script is elegantly simple for what it does, but you can go way beyond 
that if desired.

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


Re: Is there any way to ask BBEdit to use double-click to select "words" with embedded periods?

2018-09-08 Thread Christopher Stone
On 09/08/2018, at 08:13, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> I’m particularly interested in using a simple double-click to SELECT IP 
> addresses, such as one of the two in this line:
> 
>   IP Range: 87.76.32.0 - 87.76.63.255 (8,192) Kazakstan


Hey Alfredo,

As far as I know there isn't a means to do this via clicking with the mouse.

You can however use an AppleScript to select the current “word”, and this will 
work with IP addresses.

https://daringfireball.net/2003/09/select_word_script_for_bbedit 


You could also script the selection of an IP address:

* First IP address in the document.

* First IP address it the current line.

* Next IP address.

Etc.

BBEdit's own select-word command will not handle an IP address, but an 
AppleScripted select function can be made quite flexible.

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


Re: Error 12182 with grep search on large file

2018-09-03 Thread Christopher Stone
On 09/02/2018, at 11:27, Sam Hathaway mailto:list.bbe...@munkynet.org>> wrote:
> On 2 Sep 2018, at 10:26, Christopher Stone wrote:
> I think it will be much slower than Perl on a multi-GB file.
> 
> And it might choke
> 
> Can you say more about this? I thought grep was set up to work efficiently 
> with files of any size.
> 


Hey Sam,

I've personally had some issues grepping large files in the past, but it's been 
quite a while – and I don't recall all the details.

My best recollection is (with big files):

Grep is slow.

Grep can choke and completely fail.

https://www.networkworld.com/article/2706756/big-data/groping-through-big-data-with-grep.html
 
<https://www.networkworld.com/article/2706756/big-data/groping-through-big-data-with-grep.html>

In particular see:

“The other grep issue that you might not be expecting with grep is that it 
gives up when a file reaches a certain size and complexity.”

Google: grep bogs down with very large files 
<https://www.google.com/search?num=50=1=hp=J26NW4yFOM_2swXd54e4Dw=grep+bogs+down+with+very+large+files=Google+Search=grep+bogs+down+with+very+large+files_l=psy-ab.3...252.19448..19978...14.0..1.159.4600.50j5..01j2..gws-wiz.0..0j35i39j0i131j0i20i263j0i20i263i264j0i131i20i264j0i20i264j0i10j0i22i30j0i22i10i30j33i21j33i160.GBLdhnGnGVA>


If you must use grep then you really want to install gnu grep, because the 
stock version on macOS is somewhere around eight years old.

MacPorts and Homebrew both have it.

port info grep

brew info grep

But I make no guarantees about what size files they'll handle.

--
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: <https://www.twitter.com/bbedit>
--- 
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: Error 12182 with grep search on large file

2018-09-02 Thread Christopher Stone
On 09/01/2018, at 19:08, Dave mailto:dave.live...@gmail.com>> wrote:
> What's wrong with plain ol' grep?


Hey Dave,

Not much – I like it well and use it often – but I think it will be much slower 
than Perl on a multi-GB file.

And it might choke – but it's been too long since I tested such a scenario for 
me to say with certainty.

--
Take Care,
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.


Re: Running python script is locking windows

2018-08-30 Thread Christopher Stone
On 08/30/2018, at 09:09, Gauvins mailto:gauvi...@gmail.com>> wrote:
> When BEdit is used to run a script,  a modal window appears and the script 
> window is no longer accessible. Not a big deal in most cases, but I am now 
> working a scripts that run for hours and would like to be able to review/edit 
> while a script is running. Is there a setting to allow that behavior?


Hey Gauvins,

Have you tried “Run in Terminal”?

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


Re: Error 12182 with grep search on large file

2018-08-29 Thread Christopher Stone
On 08/28/2018, at 19:05, Elliott Balsley mailto:elliottbals...@gmail.com>> wrote:
> I'm trying to do a grep search in a large document and it fails with error 
> 12182, even for the simplest pattern like a plain word with no regex 
> characters.  Regular text search works.  This is a MySQL log file that's a 
> little over 3GB.  Search works on smaller documents, like 2GB.  Is there any 
> workaround for this?


Hey Elliott,

This sounds like something you should report to Bare Bones Support (see the 
footer of any given message).

In lieu of other solutions I'd try a Perl script.

It needs the file-to-be-searched to be selected in the Finder.

Presently it prints the entire line where the pattern is matched, but that can 
easily be changed to return 1 or more capture groups.

(If your regular expression spans more than 1 line then you need a different 
solution.)

Look for “Your regular expression goes here:” in the script and change the 
pattern as needed.

You can run this directly from a BBEdit text document, or you can install it in 
the Script Menu folder and run from the Script Menu directly or with an 
assigned keyboard shortcut.

~/Library/Application Support/BBEdit/Scripts/.pl


#!/usr/bin/env perl -sw
use v5.12;
# 
-----
# Auth: Christopher Stone
# dCre: 2018/08/29 22:08
# dMod: 2018/08/29 22:06 
# Task: Search a selected file in the Finder with Perl.
# Tags: @ccstone, @Shell, @Script, @Search, @Selected, @File, @Finder, @Perl
# 
-

# Your regular expression goes here: ''
my $rePattern = '^.*.*';

# 
-

# Get the POSIX Path of the selected file in the Finder.
my $filePath = `
read -r -d '' asCmdStr <<'EOF'
tell application "Finder" to set finderSelectionList to selection as alias 
list
if length of finderSelectionList = 0 then error "No files were selected in 
the Finder!"
set theItem to item 1 of finderSelectionList
return POSIX Path of theItem
EOF
osascript -e "\$asCmdStr"
`;

open ( MYFILE, $filePath ) or die $!;

while () {
if ( m/$rePattern/ ) {
say $&;
}
}

close (MYFILE);

# 
-

--
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: <http://www.twitter.com/bbedit>
--- 
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: Any way to search previous searches?

2018-08-24 Thread Christopher Stone
On 08/20/2018, at 15:15, F. Alfredo Rego <f.alfredor...@gmail.com> wrote:Rich will probably give me some grief but here is what I did, in case my fellow BBEdit users might find this useful.Hey Alfredo,Here's a live working solution.It's a bit quick and dirty, so the formatting isn't as precise as I'd like – but I don't have time to do better right now.I've provided the source and a compiled AppleScript which can be opened and run with the Script Editor.app (or Script Debugger -- SD-Lite is now free).Install here:~/Library/Application Support/BBEdit/Scripts/Give it a keyboard shortcut and go-to-town.--Best Regards,Chris# Auth: Christopher Stone# dCre: 2018/08/24 13:36# dMod: 2018/08/24 13:48# Appl: BBEdit, AppleScript & Perl# Task: Extract Recent Find Strings from BBEdit Preferences.# Libs: None# Osax: None# Tags: @Applescript, @Script, @Save, @Perl, @Extract, @Recent, @Find, @Strings, @Prefs, @Preferencesset scriptSrc to text 2 thru -1 of "#!/usr/bin/env perl -0777 -nswuse v5.010;$_ = `    plutil -convert xml1 ~/Library/Preferences/com.barebones.bbedit.plist -o - `;/FindDialog_SearchReplaceHistory.+FindDialog_SelectedSourceNodes<\\/key>/ms;$_ = $&;s!^\\h*(FindDialog_SearchReplaceHistory|FindDialog_SelectedSourceNodes)\\R?!!gm;s!^\\h*\\R?!!gm;s!^\\t\\t!!gm;s!^\\h*(CaseSensitive|EntireWord|GrepEnabled|SearchDate|WrapAround)\\R?!!gm;s!^\\h*<(true|false)/>\\R?!!gm;s!\\R?!!gm;s!\\R*\\Z!!gm;s!SearchString\\R?!Find:!gm;s!ReplaceString\\R?!Replace:!gm;s!!“!gm;s!!”!gm;s!!!gm;s!^\\h+!!gm;s!^\\h*Replace:!Repl:!gm;s!^(\\d+.+)Z!$1:!gm;my @array = split(/\\n+<\\/dict>\\n+/, $_);$, = \"\\n\";my $temp;my @temp;foreach ( @array ) {    @temp = split(\"\\n\", $_);    @temp = sort @temp; 	$temp = join \" \", @temp; 	$_ = $temp;}$_ = join \"\\n\", @array;s!\\h*(Repl:)!\\t\\t\\t$1!gm;print;"set dataStr to do shell script "perl -f <<< " & quoted form of scriptSrctell application "BBEdit"    activate    set newDoc to make new document with properties {text:dataStr, bounds:{0, 44, 1920, 1200}}    tell newDoc        select insertion point before its text        translate html to text with entity conversion without create new document    end tellend tell



-- 
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: <http://www.twitter.com/bbedit>
--- 
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: <http://www.twitter.com/bbedit>
--- 
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: Add all open files to a project?

2018-08-24 Thread Christopher Stone
On 08/23/2018, at 09:45, Christopher Stone mailto:listmeis...@suddenlink.net>> wrote:
> On 08/22/2018, at 18:06, Barbara Snyder  <mailto:barb...@signalfx.com>> wrote:
>> I have a bunch of open files. I'd like to create a project that includes all 
>> open files (without me having to add them individually). Is there a way to 
>> do this? Or do I have to enter a feature request?
> 
> Save this Bash script to a file here:


Hey Barbara,

Here's an AppleScript alternative to the shell script I posted.

Save as a compiled script using the Apple Script Editor.app to:

~/Library/Application Support/BBEdit/Scripts/

Similarly to the Bash script you can assign it a keyboard shortcut or just run 
it from the script menu.

--
Best Regards,
Chris

--------
# Auth: Christopher Stone
# dCre: 2018/08/24 12:35
# dMod: 2018/08/24 12:35 
# Appl: BBEdit
# Task: Create Synthic Project from Open Text Documents.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Create, @Synthic, @Project, @Open, 
@Text, @Documents


tell application "BBEdit"
set fileList to file of text windows whose on disk is true
set winList to text windows whose on disk is true
end tell

repeat with i in fileList
set contents of i to quoted form of (POSIX path of (contents of i))
end repeat

set AppleScript's text item delimiters to " "
set fileList to fileList as text

set shCMD to "
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:$PATH;
bbedit --project " & fileList & "&> /dev/null &"
do shell script shCMD without altering line endings

set closeOldWindows to true -- set to false if you don't want to close the old 
windows.

if closeOldWindows then

tell application "BBEdit"
repeat with theWin in winList
close theWin
end repeat
end tell

end if



-- 
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: <http://www.twitter.com/bbedit>
--- 
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 to Save, but only if file has been saved before (aka is not “untitled text”?

2018-08-23 Thread Christopher Stone
On 08/23/2018, at 13:39, Rich Siegel mailto:sie...@barebones.com>> wrote:
> On 8/23/18 at 2:06 PM, luo...@gmail.com  (TJ Luoma) 
> wrote:
> 
>> *set* docList *to* (*documents* *whose* on disk *is* *true* *and* modified
>> *is* *true*)
> 
> I recommend that you use "text documents" here, in order to avoid unintended 
> consequences.


Hey Rich,

I left that broad intentionally, because TJ didn't specify he wanted to avoid 
same, nevertheless you're probably right.  :)


I mostly use text documents and shell worksheets myself.

Where do you see the most likelihood of unintended consequences occurring?


One could take safety a step further and require an Auto-Save-ON setting in the 
document to be saved.



tell application "BBEdit"

set docList to (documents whose on disk is true and modified is true)

repeat with theDoc in docList
try
if (contents of lines 1 thru 5 of theDoc) contains "Auto-Save-ON" 
then
save theDoc
end if
end try
end repeat

end tell



I'm limiting the “header text” to the first 5 lines above, but that's easily 
adjusted.

One could automate the emplacement of the auto-save-setting:



tell application "BBEdit"
tell front text document
tell (first line whose contents is "")
set its contents to "# Auto-Save-ON" & linefeed
end tell
end tell
end tell



One could check the doc-type and use the appropriate comment character for that 
type.

Many things are possible with BBEdit and a little bit of AppleScript.

--
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 to Save, but only if file has been saved before (aka is not “untitled text”?

2018-08-23 Thread Christopher Stone
On 08/23/2018, at 10:21, TJ Luoma mailto:luo...@gmail.com>> 
wrote:
> (I use this with Keyboard Maestro so that when BBEdit “deactivates”, the file 
> will be saved. I have since learned that BBEdit has a feature to do this 
> itself, but I've been using Keyboard Maestro for a long time, so I figured 
> I'd stick with it.)
> 
> The problems with this are two-fold:
> 
> 1. If the file has not been saved before, BBEdit will (understandably) bounce 
> in the dock to tell me to name the file which it is trying to save. I would 
> rather not bother trying to save as-yet-unsaved documents when BBEdit 
> deactivates.
> 
> 2. Perhaps more significantly, this AppleScript only saves the front 
> document, and I'd really much prefer that it do an “Save All”… but, again, 
> only for files which can be saved without user-intervention.


Hey TJ,

Something like this should do the job:

--------
# Auth: Christopher Stone
# dCre: 2018/08/23 10:35
# dMod: 2018/08/23 10:35 
# Appl: BBEdit
# Task: Save modified on-disk documents.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Save, @Modified, @On-Disk, @OnDisk, 
@Documents


tell application "BBEdit"
set docList to (documents whose on disk is true and modified is true)
repeat with theDoc in docList
save theDoc
end repeat
end tell



NOTE – this has only had light testing.

--
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: <http://www.twitter.com/bbedit>
--- 
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: Add all open files to a project?

2018-08-23 Thread Christopher Stone
On 08/22/2018, at 18:06, Barbara Snyder mailto:barb...@signalfx.com>> wrote:
> I have a bunch of open files. I'd like to create a project that includes all 
> open files (without me having to add them individually). Is there a way to do 
> this? Or do I have to enter a feature request?


Hey Barbara,

Save this Bash script to a file here:

~/Library/Application Support/BBEdit/Scripts/


#!/usr/bin/env bash

read -r -d '' asCmdStr <<'EOF'

tell application "BBEdit" to set fileList to file of text windows whose on 
disk is true

repeat with i in fileList
set contents of i to quoted form of (POSIX path of (contents of i))
end repeat

set AppleScript's text item delimiters to linefeed
set fileList to fileList as text

return fileList

EOF

fileList=$(osascript -e "$asCmdStr");

shCMD="bbedit --project $fileList"
eval $shCMD


Give it a keyboard shortcut or run it by selecting it from the script menu.

Only windows that have been saved to disk will be placed in the new project.

The windows will NOT be closed after the project is created.  At this time 
that's an exercise for the user, although it's doable.

The project will NOT have been saved anywhere, so you'll have to do that 
manually.

> Also, the list of currently open documents near the bottom of the project 
> pane for a new project is blank, and the little clock icon at the bottom 
> (which I assume means recent documents) shows me a single random file that is 
> currently open. So even if I wanted to manually add all the currently open 
> files to the project, I have to do it from the + menu and just select them in 
> the finder, correct? I can't find any other way to add other currently open 
> files to the project. Is there a way?

You can drag files OR BBEdit windows into a project using their icon proxy.

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


Re: Preview pane?

2018-08-19 Thread Christopher Stone
On 08/19/2018, at 05:05, @lbutlr mailto:krem...@kreme.com>> 
wrote:
> This is what I do as well, but if I forget, or it I misskey, or if I click 
> some other preview window forward…
> 
> It would be really convenient to be bale to have have the preview attached to 
> the edit window.


Hey Lewis,

I don't think anyone is arguing against your proposal – just providing options 
that work now.

Remember that all serious feature requests need to be sent to the support 
address (see message footer).

Bare Bones Software mailto:supp...@barebones.com>>

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


Re: Preview pane?

2018-08-17 Thread Christopher Stone
On 08/17/2018, at 12:17, @lbutlr mailto:krem...@kreme.com>> 
wrote:
> User error, yes, but…
> 
> Having a preview PANE that could stcfik to the documents (maybe as a full 
> screen/scplit screen option?) would be, I think, super useful.


Hey Lewis,

I don't think there's any way to stick a preview window to its source document.

However you can use an AppleScript to arrange them to your liking.

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


Re: Applescript to change line breaks ?

2018-08-13 Thread Christopher Stone
On 08/13/2018, at 12:55, Bernardo mailto:issarf...@gmail.com>> wrote:
> OK, I reply to myself. It works with:


Hey Bernardo,

This works with BBEdit 12.1:

tell application "BBEdit"
set line breaks of every text document to DOS
end tell

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


Re: AppleScript to set the current file to: language = 'Unix Shell Script' ?

2018-08-13 Thread Christopher Stone
On 08/13/2018, at 10:39, TJ Luoma mailto:luo...@gmail.com>> 
wrote:
> 1. How can I tell BBEdit “If you open a file with no file extension, assume 
> it is a 'Unix Shell Script' file?
> 
> 2. Is there a way (presumably via AppleScript?) to tell BBEdit “Hey, this 
> document that you are currently showing, set its language to 'Unix Shell 
> Script'"?


Hey TJ,

Here's how to do that with the selected file in the Finder.


tell application "Finder"
set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in 
the Finder!"
set theFile to item 1 of finderSelectionList
set fileExtension to name extension of theFile
end tell

if fileExtension = "" then

tell application "BBEdit"
activate

set theDocument to open theFile

tell theDocument
set source language to "Unix Shell Script"
end tell

set bounds of front window to {303, 45, 1617, 1196}

end tell

end if


If you want BBEdit to automagically do this for any file then see the user 
manual:

Attaching Scripts to Events (p 300)

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


Re: Width of 'FTP Browser window'

2018-08-03 Thread Christopher Stone
On 08/03/2018, at 13:09, W.J. Llope mailto:wjll...@gmail.com>> wrote:
> One thing I liked about TextWrangler was that I could make the FTP Browser 
> window quite narrow, effectively showing only filenames in the pwd. BBEdit's 
> version of this window appears to have a (rather large) minimum value for 
> this width. Is there any 'defaults' I could change (i did RTFM), or some 
> other trick?


Hey Bill,

That does seem a little limiting.

You should make a feature-request to the support address mailto:supp...@barebones.com>> (see the message footer).

For now you can get around the problem with AppleScript:



tell application "BBEdit"
set bounds of front window to {0, 45, 300, 1196}
end tell



Bounds are upper-left-corner and lower-right-corner:

{x1,y1, x2,y2}

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


Re: Checkmark denoting current doc prevents knowing if the doc is dirty

2018-08-02 Thread Christopher Stone
On 07/31/2018, at 18:24, Barbara Snyder mailto:barb...@signalfx.com>> wrote:
>  Am I making this up (that I could always see the dot, even if I was looking 
> at the current doc)?


Hey Barbara,

It looks that way...  :)

> I can make a request to put the dot on the right or something, so as not to 
> interfere with the checkmark.

I think Rich mentioned that wasn't really possible.

> Yes I know I can look at the little icon at the upper right of a document to 
> see if it's dirty or not; that's not the point of this topic. The point is 
> being able to see if any doc is clean or dirty by glancing at the Window 
> dropdown.

 Try assigning the Window Palette a keyboard shortcut, so you can display/hide 
it at will.

The active document is highlighted with the system highlight color, and dirty 
documents have the normal dot indicator.

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


Re: Align = (equals) for assignments

2018-07-26 Thread Christopher Stone
On 07/26/2018, at 20:23, Simdude mailto:markmille...@gmail.com>> wrote:
> One of the plugins for vim I loved was Align. I used it to keep assignment 
> statements aligned. I didn't see a way to do this in BBedit so I threw 
> together a short Python script I thought I would share.


Hey Mark,

I'm quite happy to see how to do that in Python, but basic column alignment is 
simple to do in the shell:

#!/usr/bin/env bash
sed -E $'s! = !\\\t=\\\t!' | column -t -s$'\\\t'

I'm using c-string structures to enable expansion of the \t tokens, because 
Apple uses generally archaic versions of Unix executables -- and the token 
travels better in email than a literal tab.

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


Re: Insert missing closing tags

2018-07-25 Thread Christopher Stone
On 07/25/2018, at 15:28, Greg Raven mailto:gregra...@gmail.com>> wrote:
> Sorry I wasn't more clear. I know about that menu item, but I thought I used 
> to have a script that would go through the entire file and insert the missing 
> end tags. On the project I just finished, I had 1,400 HTML files, most of 
> them only with opening tags.


Hey Greg,

I'm not aware that BBEdit ever had the capacity to do that, but I don't do much 
web work – so I'm not the best authority.

As for a script – I'm not sure how that could be done unless the code was very, 
very structured.

I'd have to see some examples.

--
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: Need help with AppleScript to rename active document

2018-07-25 Thread Christopher Stone
On 07/25/2018, at 12:14, Rich Siegel mailto:sie...@barebones.com>> wrote:
> 
> BBEdit does not "lock the file". :-)


Hey Rich,

Eh?

Hmm...

Oh, the Finder is choking on the FURL returned by the document's file property.

I thought the Finder could handle FURLs now...

Oh, well.  This works:



tell application "BBEdit"
tell front text window
set f to its file
end tell
end tell

set f to f as alias

tell application "Finder"
set name of f to "WTF.txt"
end tell



--
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: Need help with AppleScript to rename active document

2018-07-25 Thread Christopher Stone
On 07/25/2018, at 09:32, TJ Luoma mailto:luo...@gmail.com>> 
wrote:
> I was searching for a way to rename the current BBEdit document today...


Hey TJ,

You're using BBEdit 12.x?

Use Cmd-Opt-I to change the name.

If you need it I can write you a script to automatically take you to the Text 
tab.

Gruber's AppleScript doesn't work for me either.  I believe BBEdit is locking 
the file these days, although you can manually change the name in the Finder.

Error -10006

CarbonCore  MacErrors.h errAEWriteDenied-10006
CarbonCore  MacErrors.h errOSACantAssign-10006
CarbonCore  MacErrors.h telCAUnavail-10006

https://osstatus.com 


--
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: Insert missing closing tags

2018-07-25 Thread Christopher Stone
On 07/25/2018, at 09:16, Greg Raven mailto:gregra...@gmail.com>> wrote:
> If I remember correctly, BBEdit used to come with a "built-in" script to 
> close open tags (such as, a paragraph that has an opening  tag but no 
> corresponding closing  tag).
> 
> Is there a way of replicating this function?


Hey Greg,

BBEdit > Menubar > Markup > Close Current Tag

--
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: Open your files in your editor of choice (BBEdit version :)

2018-07-24 Thread Christopher Stone
On 07/24/2018, at 17:35, @lbutlr mailto:krem...@kreme.com>> 
wrote:
> I have a script that does, I think, the same thing:


Hey Lewis,

It does.

> Is there a reason to return an error?

It's polite to provide at least basic error-handling in publicly posted 
scripts, although I'm guilty of not always doing so.  :)

I'm somewhat lax about error-handlers in AppleScripts I run on my own machine, 
because I nearly always run them from FastScripts – which has it's own error 
wrapper and error dialog.

BBEdit's script menu has a similar mechanism.

Giving a script more specific error messages helps unsophisticated users and 
can sometimes keep me from having too many "Huh!!??" moments.

My most generic error handler:



try

1 / 0 -- generate an error for testing.

on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set 
ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error 
Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try



--
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: Open your files in your editor of choice (BBEdit version :)

2018-07-24 Thread Christopher Stone
On 07/22/2018, at 04:20, Jean-Christophe Helary mailto:brandel...@gmail.com>> wrote:
> Some trivial AppleScript almost 100% provided by Chris Stone :)


Hey Jean-Christophe,

If you really want a one-size-fits-all approach then this is the way to go:


# Auth: Christopher Stone
# dCre: 2018/07/24 15:19
# dMod: 2018/07/24 15:19 
# Appl: Finder and any given application.
# Task: Open the Finder selection with a given app's bundle identifier.
# Libs: None
# Osax: None
# Tags: @ccstone, @Applescript, @Script, @Finder, @Open, @Finder, @Selection, 
@Bundle, @Identifier, @ID


# Bundle Identifier of the app you want to open the selected files.
set appID to "com.apple.TextEdit"

tell application "Finder"
set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in 
the Finder!"

open finderSelectionList using application file id appID

end tell



It should work with just about any application.

--
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: <http://www.twitter.com/bbedit>
--- 
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: Edit > Show Clipboard (BBEdit 10)

2018-07-20 Thread Christopher Stone
On 07/16/2018, at 16:27, Matt Kanninen mailto:mathias...@gmail.com>> wrote:
> Guess I'll have to.  Easy clipboard access was one of the main reasons I 
> decided to try BBEdit


Hey Matt,

It's about as easy as you want it to be.

See this link.

https://groups.google.com/d/msg/bbedit/gipy2Sp4R5k/SyQWt6Q5AQAJ 
<https://groups.google.com/d/msg/bbedit/gipy2Sp4R5k/SyQWt6Q5AQAJ>

The script creates a pop-up list of the various clipboard contents.

Here's another one that will dump all clipboards into new document.

----
# Auth: Christopher Stone
# dCre: 2018/07/20 07:32
# dMod: 2018/07/20 07:32 
# Appl: BBEdit
# Task: Dump BBEdit Clipboards to a new document.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Dump, @BBEdit, @Clipboards, @New, 
@Document


set _sep to linefeed & linefeed & 
"" & linefeed & 
linefeed

set clipList to {}

tell application "BBEdit"
repeat with i from 1 to 6
set end of clipList to (contents of clipboard i)
end repeat
end tell

set AppleScript's text item delimiters to _sep

bbeditNewDoc(clipList as text, true)


--» HANDLERS

on bbeditNewDoc(_text, _activate)
tell application "BBEdit"
set newDoc to make new document with properties {text:_text, bounds:{0, 
44, 1920, 1200}}
tell newDoc
select insertion point before its text
end tell
if _activate = true or _activate = 1 or _activate = "activate" then 
activate
end tell
end bbeditNewDoc


Personally I recommend a clipboard manager.  They are more full-featured and 
are a great productivity enhancement.

I use LaunchBar's clipboard manager and Keyboard Maestro's for different 
reasons.

I also have scripts for BBEdit that let me save the current clipboard to 1 of 
10 pseudo-clipboards and can copy to or paste from with 1 keystroke.

--
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: <http://www.twitter.com/bbedit>
--- 
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: AppleScripts: how to not have them work in the find window

2018-07-04 Thread Christopher Stone
On 07/02/2018, at 01:30, Jon B. mailto:nyc2...@gmail.com>> 
wrote:
> I set Smart Home to ⌘←. If I use this key in BBEdit's Find Window, I get an 
> error message.


Hey Jon,

In general it's a bad idea to hijack normal system-key functionality.

It tends to be too be impossible to manage all the possible exceptions.

Like:

The Find window.
The Find field in an editing window.
Text fields in dialog boxes.
Etcetera.

Usually it's better to select a similar keystroke like Opt-Cmd-.

> What's the best way to have that key perform normally if not in the BBEdit 
> text edit window?


As I mentioned there's no good way to manage all the possible exceptions, but 
many things are possible with Keyboard Maestro 
.

You can use System Events to press keystrokes, so you can do something like 
this:


tell application "BBEdit"
set windowExceptionList to {find_window}
if class of front window is in windowExceptionList then
pressKey() of me
else
# Run Smart Home Script ...
end if
end tell

on pressKey()
tell application "System Events"
tell application process "BBEdit"
key code 123 using command down
end tell
end tell
end pressKey


But once again that won't manage various text fields in windows and dialogs.

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


Re: AppleScript syntax colouring? How?

2018-06-23 Thread Christopher Stone
On 06/12/2018, at 00:41, 'Martin Petersen' via BBEdit Talk 
mailto:bbedit@googlegroups.com>> wrote:
> Played around with the Demo and I must say I am impressed by the support for 
> Regular Expressions in the find and replace dialogue. Yet I can not find 
> support (syntax coloring) for AppleScripts.


Hey Martin,

See this page.

http://bbeditextras.org/wiki/index.php?title=Codeless_Language_Modules 


The modules available won't have as comprehensive coloring as the Script Editor 
or Script Debugger, but they're better than nothing.

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


Re: selecting blocs of lines

2018-06-19 Thread Christopher Stone
On 06/10/2018, at 08:03, Jean-Christophe Helary mailto:brandel...@gmail.com>> wrote:
> If there was a way to separate point and mark. I could leave the mark where I 
> want, jump to some place in the document and I would have a selection.
> 
> I guess that's a valid feature request ?


Hey Jean-Christophe,

You can do that with two scripts.  (Appended.)

A script that records the current insertion location.

And a script that will select from the recorded “marker” to the current cursor 
location in the front document.

Save them as compiled scripts using the Script Editor.app.

Give them relevant keyboard shortcuts.

Go-to-town.

This line in script 2 is vitally important:

set scriptFile to alias ((path to application support from user domain as text) 
& "BBEdit:Scripts:Mark_01.scpt")

The script name MUST be correct.

The script will function correctly when moving either forward or backward in 
the document.

Once again I've provided no error-checking.  I added a very generic 
error-handler to script 2 as an example.

I have not provided multiple document support.

Presently the marker is stored in the Marker_01 script and has no specific 
linkage to the document, so it is very perishable.

If I was going to move beyond proof-of-concept I'd consider storing the marker 
in a text file on a per-document basis using the document name and character 
offset of the insertion location.  Reading, writing, and maintaining this would 
be a trivial exercise with `sed` and would be very fast.

--
Take Care,
Chris


The Mark Script


--------
# Auth: Christopher Stone
# dCre: 2018/06/10 22:19
# dMod: 2018/06/10 22:19 
# Appl: BBEdit
# Task: Create Marker 01 for use in other scripts.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Create, @Marker


property insertionLocation : ""

tell application "BBEdit"
tell front text window
set insertionLocation to selection
end tell
end tell





The Select-from-Cursor-Location-to-Marker Script


--------
# Auth: Christopher Stone
# dCre: 2018/06/10 22:19
# dMod: 2018/06/10 22:19 
# Appl: BBEdit
# Task: Select from Marker 01 to current cursor location.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Select, @Marker, @Current, @Cursor, 
@Location


try

set scriptFile to alias ((path to application support from user domain as 
text) & "BBEdit:Scripts:Mark_01.scpt")
set markScript to load script scriptFile

tell application "BBEdit"
tell front text window
set markedInsertionLocation to markScript's insertionLocation
set insertionLocation to selection

set markedCharacterOffset to (characterOffset of 
markedInsertionLocation)
set currentCharacterOffset to (characterOffset of insertionLocation)

if markedCharacterOffset < currentCharacterOffset then
set startChar to markedCharacterOffset
set endChar to currentCharacterOffset - 1
else
set startChar to currentCharacterOffset
set endChar to markedCharacterOffset - 1
end if

select (characters startChar thru endChar)

end tell
end tell

on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set 
ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error 
Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try





-- 
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: <http://www.twitter.com/bbedit>
--- 
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: selecting blocs of lines

2018-06-10 Thread Christopher Stone
On 06/10/2018, at 09:11, Rich Siegel mailto:sie...@barebones.com>> wrote:
> What's the easy way to select a block of lines specified by line numbers?
>> Like, I have a big text and want to select from line 57 to line 293?
> 
> Here is an excerpt from the 12.1 change notes:
> 
> *   "Go To Line" (either the menu command or the popover from the


Cool.

I was looking for that in the manual last night but around the emacs stuff and 
not the jump to line function.

--
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: selecting blocs of lines

2018-06-10 Thread Christopher Stone
On 06/10/2018, at 03:11, Jean-Christophe Helary mailto:brandel...@gmail.com>> wrote:
> Chris, thank you ! :)


Hey Jean-Christophe,

You're welcome.

I forgot to mention that I'm not doing any error checking in that script.

If I were to do the full production I'd make sure the user couldn't input 
impossible values.

The way things are now the script might or might not fail silently.  There are 
some circumstances that will throw an error and some that will not.

In any case it works if you input the right values, and it cannot harm your 
document.

--
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: selecting blocs of lines

2018-06-10 Thread Christopher Stone
On 06/09/2018, at 22:43, Jean-Christophe Helary mailto:brandel...@gmail.com>> wrote:
> What's the easy way to select a block of lines specified by line numbers?


Hey Jean-Christophe,

As far as I know there isn't one.

BBEdit does have a jump-to-line function (Cmd-J), but it doesn't allow for a 
selection

You can roll-your-own and get as sophisticated as you want.

The appended script will pop-up a dialog and will accept the following input:

  ==  A selection range from start-line to 
end-line.

  == Select current line + num

- == Select current line - num

.  ==  Select current line to absolute end-line-num.

That's as fancy as I'm willing to make it at this time, but with all the tools 
available you can get substantially more sophisticated.

--
Take Care,
Chris


# Auth: Christopher Stone
# dCre: 2018/06/10 00:08
# dMod: 2018/06/10 00:56
# Appl: BBEdit
# Task: Select Lines with User Input from Dialog
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Select, @Lines, @User, @Input, @Dialog


property defaultDialogText : ""

set AppleScript's text item delimiters to {" "}

set defaultDialogText to text returned of ¬
(display dialog "Current Line + ==#" & linefeed & ¬
"Current Line - ==  -#" & linefeed & ¬
"Line Range ==  # #" with title "Enter Line Range for 
Selection" default answer defaultDialogText)

copy defaultDialogText to lineRange

set dialogTextItems to text items of lineRange

tell application "BBEdit"
tell front text window
set currentLine to startLine of selection

if length of dialogTextItems = 1 then
set dialogText to item 1 of dialogTextItems

if dialogText starts with "-" then
set firstLine to currentLine + dialogText
set lastLine to currentLine
else
set firstLine to currentLine
set lastLine to currentLine + dialogText
end if

else if length of dialogTextItems = 2 then
set {firstLine, lastLine} to dialogTextItems
end if

if firstLine = "." then
set firstLine to currentLine
end if

select (lines firstLine thru lastLine)
end tell
end tell



-- 
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: <http://www.twitter.com/bbedit>
--- 
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: Including a Unix filter in a recorded script

2018-05-29 Thread Christopher Stone
On 05/28/2018, at 11:59, fgf mailto:ga...@jacqcad.com>> 
wrote:
> I have a very large file (a 20 MB Thunderbird .mbox mail file) which contains 
> many base64 sections interleaved in the text.  
> 
> I want to decode in-line the base64 sections back into readable text while 
> keeping the non-base64 text.
> 
> I made a Find pattern to select the base64 sections:


Hey There,

You could do something like this with AppleScript.

--------
# Auth: Christopher Stone
# dCre: 2018/05/29 15:00
# dMod: 2018/05/29 15:00 
# Appl: BBEdit
# Task: Decode Base64 Segments in front document.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Decode, @Base64, @Segments, @Front, 
@Document


set itemFound to true

tell application "BBEdit"
tell front text window's text

select insertion point before character 1

repeat while itemFound
set findRecord to find "(^[0-9a-zA-z+/]{76}\\r)+.*\\r" options 
{search mode:grep, case sensitive:false}

if found of findRecord ≠ true then
set itemFound to false
else
select found object of findRecord
set dataStr to contents of text of found object of findRecord
set decodedStr to decodeBase64(dataStr) of me
if decodedStr ≠ dataStr then set contents of selection to 
decodedStr
end if

end repeat

end tell
end tell


--» HANDLERS

on decodeBase64(dataStr)
set shCMD to "
base64 -D <<< " & quoted form of dataStr
do shell script shCMD
end decodeBase64


It will take your regex pattern, find the next match, transform it, and repeat 
until done.

You can run it from the Apple Script Editor.app, or BBEdit's script menu.

On a 20 MB file it will probably take quite a while to run.

I am concerned that some of your base64 blocks will be embedded images or 
files, so you may end up with some gibberish in the decoded material.


If I was doing this on any regular basis I'd take a careful look at this:

https://perldoc.perl.org/MIME/Base64.html 
<https://perldoc.perl.org/MIME/Base64.html>

It works well for simple cases, unfortunately I don't know offhand how to make 
it work in a big file with interspersed base64 sections.

Even so – someone has done this job before – and some research ought to bear 
fruit.

--
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: <http://www.twitter.com/bbedit>
--- 
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: Find and Replace help please

2018-05-20 Thread Christopher Stone
On 05/18/2018, at 11:10, Matthew London > wrote:
> Turns out there are sometimes multiple lines both within my KEEP text and in 
> my DELETE text.


Hey Matthew,

That's easy enough.

Let's start off by using a test string that provides better feedback:


&&&
TEXT STRING I WANT TO KEEP 1
&&&
TEXT STRING I WANT TO KEEP 2
Keep 2, Line 2
Keep 2, Line 3
###
TEXT STRING I WANT TO DELETE 1
&&&
TEXT STRING I WANT TO KEEP 3
Keep 3, Line 2
###
TEXT STRING I WANT TO DELETE 2
Delete 2, Line 2
Delete 2, Line 3
&&&
TEXT STRING I WANT TO KEEP 4
Keep 4, Line 2
###
TEXT STRING I WANT TO DELETE 3


To delete the “I want delete” strings:

Find (first pass with regex - keeping the ampersands):

(?s)^###.+?(?=^&&&|\z)

Replace with nothing.


A simple Perl Script text-filter to do the same as the above.

** The commented-out line removes the ampersands if uncommented.

Each line of this script (other than print) acts exactly like making making a 
find/replace pass with BBEdit's Find dialog.

Perl's canonical search/replace syntax looks like this:

s///

Personally I prefer to use exclamation points in place of the forward slashes, 
so I don't have to escape forward slashes in paths, etc.  (I find this syntax 
easier to read.)

s!!!


#!/usr/bin/env perl -0777 -nsw

s!^###.+?(?=^&&&|\z)!!igms;
# s!^&&&\n!!gm; # <-- Uncomment this line to remove the &&& lines.
print;


Uncomment means to remove the hash mark from the beginning of the line - i.e. 
remove the comment symbol.


A simple sed text-filter to remove the desired text and leave the ampersands.

It finds the range of text between ^&&& and ^### – deletes the line with the 
hash marks – and prints the rest.  The syntax looks scary at first, but (this 
pattern) breaks down to something very simple.


#!/usr/bin/env bash
# Keep the ampersands.
sed -En '/^&&&/,/^###/{ /^###/d; p; }'


A simple sed text-filter to remove the desired text and remove the ampersands.

It finds the range of text between ^&&& and ^### – deletes the line with the 
ampersands – deletes the line with the hash marks – and prints the rest.


#!/usr/bin/env bash
Delete the ampersands.
sed -En '/^&&&/,/^###/{ /^&&&/d; /^###/d; p; }'


Like many things using text-filters in BBEdit can be a bit scary at first, but 
after a while it becomes routine – and they become another valuable tool in the 
toolbox.

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


Re: Another Newbie GREP help request...

2018-05-19 Thread Christopher Stone
On 05/14/2018, at 22:15, Matthew London > wrote:
> PS.Grateful if someone can recommend a "GREP for non-programmers" written in 
> plain(er) English so I don't have to bother you very helpful people here.


Hey Matthew,

It takes a while to get good enough with regular expressions to manage anything 
but the basics without a hint or two, but don't let that worry you – Practice 
makes Progress.

It's been awhile, since I updated this – but all the links are current.

--
Best Regards,
Chris

---
Some Information on Learning Regular Expressions – by Christopher C. Stone
---

Learning basic regular expressions is relatively easy.  Becoming really good 
with them takes dedication, a lot of practice, and some tutelage.

The BBEdit Manual devotes a whole chapter to regular expressions: Searching 
with Grep (currently chapter 8).  It's a reference rather than a tutorial, but 
it does explain at least briefly many of the fundamentals.

My cheat-sheet for BBEdit is up on Gist:

https://gist.github.com/ccstone/5385334 


BBEdit uses PCRE (Perl Compatible Regular Expressions), so it's a pretty decent 
if not complete reference.

Regex neophytes are better off starting with a book specifically written for 
beginners.

I have these books (in addition to a couple of tomes on Perl):

"Sams Teach Yourself Regular Expressions in 10 Minutes" by Ben Forta
"Beginning Regular Expressions" by Andrew Watt
"Regular Expressions Cookbook"  by Jan Goyvaerts and Steven Levithan
"Mastering Regular Expressions" by Jeffrey Friedl (Advanced)

There's a decent little utility available on the App-Store called 'Patterns' 
that live-updates as you create your pattern. ($2.99)

https://itunes.apple.com/us/app/patterns-the-regex-app/id429449079?mt=12 


I've found it very handy to have live feedback when building a complex pattern 
and wish I'd had something like that when I started learning regex more than 20 
years ago.

Extracting a good working knowledge of regular expressions from the Internet is 
a serious chore.  There are many flavors of regex out there, such as Perl/PCRE, 
Java, Javascript, Ruby, Python, TCL...  They're all similar, but the 
differences can be very confusing and frustrating.

Nevertheless there are many useful online resources.  Here are a few:

http://www.agillo.net/regex-primer-part-1/ 

http://www.agillo.net/regex-primer-part-2/ 

http://www.codeproject.com/KB/dotnet/regextutorial.aspx 

http://www.regular-expressions.info/tutorial.html 


---
Tags: @Learning, @Regular, @Expressions, @Regular_Expressions, @RegEx, @GREP, 
@Info
---


-- 
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: How can I find all lines containing a pattern and then copy those lines?

2018-05-09 Thread Christopher Stone
On 05/08/2018, at 02:26, Doug Lerner > 
wrote:
> Using Find with grep checked on I'm looking for lines in a large file 
> containing this pattern: 
> 
> registeredTd="11/\d\d/2017
> 
> It stands for a registered date of November, 2017.
> 
> If I "find all" I get 69 occurrences of the pattern in the file.
> 
> But how, then, can I copy those found lines?


Hey Doug,

I took a quick look, and if you use Preview to view your PDF files then finding 
this in the manual is pretty easy.

Search for “find lines”, and the 4th item is “Process Lines Containing”.

This is the simplest of the available options (which Rich mentioned).

You discovered “Find All”, but you missed the “Extract” button in the Find 
dialog.  (Right after “Find All” in the manual.)

“Extract” takes just a little more work than “Process Lines Containing”, 
because it doesn't automatically return lines.  You have to add a little regex 
to pull up the whole line:

.*registeredTd="11/\d{2}/2017.*

Ctrl-Cmd-G is the keyboard shortcut on my machine for “Extract”.  (I don't 
think I changed the default but am not certain.)

NOTE - this feature is only available when the Find dialog is open.

There are a variety of scripted options available as well, and you can directly 
script “Process Lines Containing” via AppleScript.


tell application "BBEdit"
tell front text document
process lines containing matching string 
"registeredTd=\"11/\\d{2}/2017" matching with grep true ¬
output options {copying to new document:true} without case sensitive
end tell
end tell


So if you do this sort of operation frequently you can save the script, give it 
a keyboard shortcut, and go-to-town.

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


Re: Find and Replace help please

2018-05-03 Thread Christopher Stone
On 05/02/2018, at 12:25, Matthew London > wrote:
> I have a file with the following:
> 
> &&&
> TEXT STRING I WANT TO KEEP
> ###
> TEXT STRING I WANT TO DELETE
> &&&
> TEXT STRING I WANT TO KEEP
> etc,
> 
> Where there is a linebreak after &&&, ###, and all text strings


Hey Matthew,

You weren't clear about whether your source text contains strings other than 
&&&…keep and ###…delete, so for the moment I'll assume these two types are the 
only content in the file.


For information on installing and using BBEdit's text filters see (here 
).


This text-filter removes all but your keep text.  It does this by finding your 
keep symbol and printing the following line.

#!/usr/bin/env bash
sed -En '/^&&&/{n;p;}' # Print next line after found regex.


This text-filter prints the keep symbol and the following line.

#!/usr/bin/env bash
sed -En '/^&&&/,/[^[:blank:]]/{p;}' # Print found Regex and the next line after 
it.


Sed is very quick and efficient for this sort of job, but it's not the only 
game in town.


This text-filter uses egrep to find the regex and the line after it.  It then 
uses sed to delete any record separators “--” egrep places between found 
records.

#!/usr/bin/env bash

egrep -i -A1 "^&&&" | sed -E '/^--/d'

Output:

&&&
TEXT STRING I WANT TO KEEP
&&&
TEXT STRING I WANT TO KEEP


We can build on the above and also delete the keep symbol.

#!/usr/bin/env bash

egrep -i -A1 "^&&&" | sed -E '/^(--|&&&)/d'

Output:

TEXT STRING I WANT TO KEEP
TEXT STRING I WANT TO KEEP


Lastly I'll trot out the 900lb gorilla — Perl.

#!/usr/bin/env perl -sw

while (<>) {
print if $,; $, = /^&&&/
}

Output:

TEXT STRING I WANT TO KEEP
TEXT STRING I WANT TO KEEP


#!/usr/bin/env perl -sw

while (<>) {
print if /^&&&/;
print if $,; $, = /^&&&/
}

Output:

&&&
TEXT STRING I WANT TO KEEP
&&&
TEXT STRING I WANT TO KEEP


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


Re: Multiple replace of highlighted text

2018-05-03 Thread Christopher Stone
On 05/03/2018, at 22:20, Robert > 
wrote:
> If I have a word highlighted throughout my code, is there a key combo that 
> allows me to replace the one instance and it replaces them all?


Hey Bob,

Not at present.

You can use Cmd-E to “Use Selection for Find” though.

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


<    1   2   3   4   5   6   7   8   9   >