On 08/20/2018, at 15:15, F. Alfredo Rego <[email protected]> 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, @Preferences
----------------------------------------------------------------

set scriptSrc to text 2 thru -1 of "
#!/usr/bin/env perl -0777 -nsw
use v5.010;

$_ = `
    plutil -convert xml1 ~/Library/Preferences/com.barebones.bbedit.plist -o - 
`;

/<key>FindDialog_SearchReplaceHistory.+<key>FindDialog_SelectedSourceNodes<\\/key>/ms;

$_ = $&;

s!^\\h*<key>(FindDialog_SearchReplaceHistory|FindDialog_SelectedSourceNodes)</key>\\R?!!gm;
s!^\\h*</?array>\\R?!!gm;
s!^\\t\\t!!gm;
s!^\\h*<key>(CaseSensitive|EntireWord|GrepEnabled|SearchDate|WrapAround)</key>\\R?!!gm;
s!^\\h*<(true|false)/>\\R?!!gm;
s!<dict>\\R?!!gm;
s!</dict>\\R*\\Z!!gm;
s!<key>SearchString</key>\\R?!<key>Find:</key>!gm;
s!<key>ReplaceString</key>\\R?!<key>Replace:</key>!gm;
s!<string>!“!gm;
s!</string>!”!gm;
s!</?(?:date|key)>!!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 scriptSrc

----------------------------------------------------------------

tell 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 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
"[email protected]" 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

<<attachment: Extract_Recent_Find_Strings_from_BBEdit_Preferences.scptd.zip>>

--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"[email protected]" 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to