Hello

and thanks for the quick reply **BUT** it doesn't work.

I had this script of yours:

--
(*
  Author: Kendall Conrad of Angelwatt.com
  Name: Smart Newline
  Created: 2010-01-23
  Updated: 2012-04-21
Description: Based on the current line it will generate different text for the context. It knows about indentation, code doc syntax, function starts, lists, HTML li
*)
tell application "BBEdit" to tell front window
        activate
        set lineNum to startLine of selection
        set leng to length of line lineNum
        -- Move cursor to end of line
        if leng > 0 then
                select insertion point after (character (leng) of line lineNum)
        end if
        
        -- Find leading whitespace
set theResult to find "(^[\\s]*)" options {search mode:grep} searching in line (lineNum)
        -- Set text to the white space found
        set white to ""
        if found of theResult then
                set white to found text of theResult
        end if
        set wleng to length of white
        
        -- Define a tab based on user settings
        set aTab to tab
        if expand tabs then
                set spaceTab to ""
                repeat tab width times
                        set spaceTab to spaceTab & space
                end repeat
                set aTab to spaceTab
        end if
        
        -- Are we starting a code doc?
        if (leng - wleng) ≥ 3 then
if (characters (wleng + 1) through (wleng + 3) of line lineNum as string) is equal to "/**" then
                        set selection to return & white & " * " & return & white & " 
*/"
                        select insertion point after line (lineNum + 1)
                        return
                end if
        end if
        
        -- Are we starting a code doc?
        if (leng - wleng) ≥ 2 then
if (characters (wleng + 1) through (wleng + 2) of line lineNum as string) is equal to "/*" then
                        set selection to return & white & " * " & return & white & " 
*/"
                        select insertion point after line (lineNum + 1)
                        return
                end if
        end if
        
        -- Check for lists
set theResult to find "^\\s*[\\*#>\\+\\-]+([\\w ]*)" options {search mode:grep} searching in (line lineNum)
        if found of theResult then
set preFind to find "[\\*#>\\+\\-]+" options {search mode:grep} searching in (line lineNum)
                set _char to found text of preFind
                set selection to return & white & _char & " "
                select insertion point after line (lineNum + 1)
                return
        end if
        
        -- Check for numbered list: (1. goes to 2.), (2.5 goes to 2.6)
set theResult to find "^\\s*([\\d]+\\.)" options {search mode:grep} searching in (line lineNum)
        if found of theResult then
                set preNum to ""
set preNumResult to find "([\\d]+\\.)+\\d" options {search mode:grep} searching in (line lineNum)
                if found of preNumResult then
                        set preNum to characters 1 thru -2 of (found text of 
preNumResult)
                end if
set numResult to find "[\\d]+\\. " options {search mode:grep} searching in (line lineNum)
                if found of numResult then
set nextNum to ((characters 1 thru -3 of (found text of numResult)) as text) + 1
                        set selection to return & white & preNum & nextNum & ". 
"
                        select insertion point after line (lineNum + 1)
                        return
                end if
        end if
        
        -- Check for <li
if (leng - wleng) > 2 and (characters (wleng + 1) through (wleng + 3) of line lineNum as string) is equal to "<li" then
                -- Capture the whole li tag including attributes
set liResult to find "<li[^>]*>" options {search mode:grep} searching in (line lineNum)
                if found of liResult then
                        set selection to return & white & (found text of liResult) & 
"</li>"
                else
                        -- just use a plain li tag
                        set selection to return & white & "<li></li>"
                end if
                select (insertion point before character -5 of line (lineNum + 
1))
                return
        end if
        
        -- Check for code block ({});
if (leng - wleng) > 1 and (characters -2 thru -1 of line lineNum as string) is equal to "({" then
                set selection to return & white & aTab & return & white & "});"
                select insertion point after line (lineNum + 1)
                return
        end if
        
        -- Check for code block {}
if (leng - wleng) ≥ 1 and (character -1 of line lineNum as string) is equal to "{" then
                set selection to return & white & aTab & return & white & "}"
                select insertion point after line (lineNum + 1)
                return
        end if
        
        -- Check for code block ();
if (leng - wleng) ≥ 1 and (character -1 of line lineNum as string) is equal to "(" then
                set selection to return & white & aTab & return & white & ");"
                select insertion point after line (lineNum + 1)
                return
        end if
        
        -- Check for code block : (Python)
if (leng - wleng) ≥ 1 and (character -1 of line lineNum as string) is equal to ":" then
                set selection to return & white & aTab
                select insertion point after line (lineNum + 1)
                return
        end if
        
        -- Default: Insert a return plus the white space
        set selection to return & white
        select insertion point after selection
end tell
--

that I've started with a KeyboardMaestro-macro (living in the KBM-Macros for BBEdit) triggered by CMD-Return.

I replaced the above script with the new one and… nothing worked anymore: nor the previous *Smart Newline*, neither the new *Smart Prefixed Newline*.

What went wrong?


Regards,
Vlad




On 23 Jan 2016, at 0:20, Kendall Conrad wrote:

What you wanted was a bit different than what Smart Newlines was for, but it was easy enough to create a modified version. I only did a small amount
of testing, but seemed OK.

(*
Author: Kendall Conrad of Angelwatt.com
Name: Smart Prefixed Newline
Created: 2016-01-22
Updated: 2016-01-22
Description: Starts new line with the same line prefix as the current
line and keeps the text
  from the current cursor position to the end of the line
*)
tell application "BBEdit" to tell front window
activate
set lineNum to startLine of selection
set leng to length of line lineNum
-- Find leading whitespace
set theResult to find "(^[\\s]*)" options {search mode:grep} searching
in line (lineNum)
-- Set text to the white space found
set white to ""
if found of theResult then
    set white to found text of theResult
end if
set wleng to length of white

-- Define a tab based on user settings
set aTab to tab
if expand tabs then
    set spaceTab to ""
    repeat tab width times
        set spaceTab to spaceTab & space
    end repeat
    set aTab to spaceTab
end if

-- Check for list style lines
set theResult to find "^\\s*[\\*#>\\+\\-]+([\\w ]*)" options {search
mode:grep} searching in (line lineNum)
if found of theResult then
    set preFind to find "[\\*#>\\+\\-]+" options {search mode:grep}
searching in (line lineNum)
    set _char to found text of preFind
    set selection to return & white & _char
    select insertion point after selection
    return
end if

-- Default: Insert a return plus the white space
set selection to return & white
select insertion point after selection
end tell


~aw




On Tuesday, January 19, 2016 at 8:58:34 AM UTC-5, Vlad Ghitulescu wrote:

Hello!


While testing MailMate as an alternative to Apple's Mail.app I edit my
mails now in BBEdit.
That brings all the joy BBEdit makes :-)… and a question.

Replying to an email generates first text like this:

---
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
---

When I put the cursor let's say in the first line, between *(…) amet,* and * consetetur (…)* and press ENTER, the cited text looks like this:

---
Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy
eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
---

instead of what I would like:

---
Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy
eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
---

that is, the citation mark *> * is not continued.

I'm using already the Smart Newline - script
(http://www.angelwatt.com/words/2011/04/11/bbedit-smart-newline-open-line/),

but it doesn't do it's magic here.

Do you have an idea, how could I convince the citation mark to *jump* on
the next line when inserting something in the middle of a line?

Thanks!


Regards,
Vlad




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

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

Reply via email to