• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Export BBEdit Find History
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Export BBEdit Find History


  • Subject: Export BBEdit Find History
  • From: Christopher Stone <email@hidden>
  • Date: Sun, 26 Aug 2018 23:43:30 -0500

Hey Folks,

I think most longtime BBEdit users know you can assign a keyboard shortcut to the Find History button in the Find dialog.

Unfortunately it's not searchable and is difficult to read.

So I took up the challenge of exporting those suckers from a request on the BBEdit list.

The script produces a dated table of search history items and puts a regex in line one that will find each bracketed string and then selects it.

Cmd-Shift-E to enter the regular _expression_ into the Find dialog behind the scenes if so desired.

Cmd-G to find the next bracketed string.

I'm using dark Unicode brackets to clearly delimit the search and replace strings.

I've provided the source text and a compiled AppleScript.

Enjoy.

--
Take Care,
Chris



-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/08/26 22:00
# dMod: 2018/08/26 23:13
# Appl: BBEdit, System Events
# Task: Export Find History to a BBEdit Text Document.
#     : Includes a regular _expression_ for entry into Find via Cmd-Shift-E
#     : to enable finding bracketed search strings via Cmd-G.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @System_Events, @Export, @Find, @History, @Text, @Document
-------------------------------------------------------------------------------------------

try

    

    set shCMD to "
    export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:$PATH;
    plutil -convert xml1 ~/Library/Preferences/com.barebones.bbedit.plist -o - 
    "
    set thePlist to do shell script shCMD without altering line endings

    

    tell application "System Events"
        set bbeditPlist to make new property list item with properties {text:thePlist}
        tell bbeditPlist to set plistValue to value of property list items of property list items

        

        set collatorList to {}

        

        tell bbeditPlist
            set FindDialog_SearchReplaceHistory_Value to value of property list item "FindDialog_SearchReplaceHistory"

            

            tell FindDialog_SearchReplaceHistory_Value
                repeat with theRecord in FindDialog_SearchReplaceHistory_Value

                    

                    tell theRecord

                        

                        set srchDate to (its SearchDate as «class isot») as string
                        set srchDate to findReplTIDS("T", " ", srchDate) of me

                        

                        set srchStr to its SearchString

                        

                        try
                            set replStr to its ReplaceString
                        on error
                            set replStr to ""
                        end try

                        

                        set end of collatorList to srchDate & tab & "FIND: ❰" & srchStr & "❱" & tab & "REPL: ❰" & replStr & "❱"

                        

                    end tell

                    

                end repeat
            end tell

            

        end tell

        

    end tell

    

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

    

    set shCMD to "
    export LANG=\"en_US.UTF-8\"
    column -t -s$'\\t' <<< " & quoted form of collatorList
    set collatorList to do shell script shCMD without altering line endings

    

    bbeditNewDoc(collatorList, true) of me

    

    tell application "BBEdit"
        tell front text window
            set before its text to "(?<=❰)\\S.*?(?=❱)" & linefeed & linefeed
            select characters 1 thru -1 of line 1
        end tell
        # open find window
        # tell find window
        # set selection to "(?<=❰)\\S.*?(?=❱)"
        # # close
        # 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

-------------------------------------------------------------------------------------------
--» 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
-------------------------------------------------------------------------------------------
on findReplTIDS(_find, _replace, _string)
    set oldTIDS to AppleScript's text item delimiters
    set AppleScript's text item delimiters to _find
    set _string to text items of _string
    set AppleScript's text item delimiters to _replace
    set _string to _string as text
end findReplTIDS
-------------------------------------------------------------------------------------------

Attachment: Export Find History to a BBEdit Text Document.scptd.zip
Description: Zip archive

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Formatting Cell Values in Numbers 5.1
  • Next by Date: Re: Formatting Cell Values in Numbers 5.1
  • Previous by thread: Re: Formatting Cell Values in Numbers 5.1
  • Next by thread: Problematic Mail Attachments FYI and Question
  • Index(es):
    • Date
    • Thread