how to continue the citation-mark on the next line after pressing enter

96 views
Skip to first unread message

Vlad Ghitulescu

unread,
Jan 19, 2016, 8:58:34 AM1/19/16
to bbe...@googlegroups.com
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


Jason Davies

unread,
Jan 20, 2016, 2:52:02 AM1/20/16
to bbe...@googlegroups.com

I don't know if it's the most efficient way but Applescript could sort this out (eg strip the quotes, rewrap, add quotes, all just before sending it back). Add to a keystroke that also sends the text back to MlMT

I've not got this command bundle to work so can't test - what does Mailmate do with the text once it's got it, in terms of rewrapping?

On 19 Jan 2016, at 13:58, 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
"sup...@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+un...@googlegroups.com.
To post to this group, send email to bbe...@googlegroups.com.

Vlad Ghitulescu

unread,
Jan 20, 2016, 3:05:43 AM1/20/16
to bbe...@googlegroups.com
Hi, Jason!


Perhaps I should have explained more specifically: MailMate does this (=
continuation of the quotation mark) like a breeze, but I'm in BBEdit
while editing and *come back* to MailMate only to send the message.

So what I was looking for was a solution in BBEdit for the continuation
of the quotation marks.


Regards,
Vlad




On 20 Jan 2016, at 8:51, Jason Davies wrote:

> I don't know if it's the most efficient way but Applescript could sort
> this out (eg strip the quotes, rewrap, add quotes, all just before
> sending it back). Add to a keystroke that also sends the text back to
> MlMT
>
> I've not got this command bundle to work so can't test - what does
> Mailmate do with the text once it's got it, in terms of rewrapping?
>
>
> On 19 Jan 2016, at 13:58, 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*

Kendall Conrad

unread,
Jan 22, 2016, 6:20:49 PM1/22/16
to BBEdit Talk
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

Vlad Ghitulescu

unread,
Jan 23, 2016, 8:11:55 AM1/23/16
to BBEdit Talk
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

Kendall Conrad

unread,
Jan 23, 2016, 10:01:41 AM1/23/16
to BBEdit Talk
I know the old script doesn't work and isn't suppose to for what you wanted, which is why I wrote the new one, which works very differently.

You didn't describe what happened with the new script so I can't say what happened. You'll need to give more information and try messing with the script. Can't magically know what's wrong.

~aw

Vlad Ghitulescu

unread,
Jan 23, 2016, 10:36:33 AM1/23/16
to BBEdit Talk
Hello again,


and sorry for being not clear enough!
I try to improve :-) below…

On 23 Jan 2016, at 16:01, Kendall Conrad wrote:

> I know the old script doesn't work and isn't suppose to for what you
> wanted, which is why I wrote the new one, which works very
> differently.

Yes, I understood this.
I thought initially that the new script will be an extended version of
the old one, that's why I expected that the old functions will continue
to work as usual.


> You didn't describe what happened with the new script so I can't say
> what
> happened.

With the new script the old KBM-trigger (CMD-Return) doesn't triggers
any visible change in the editor.

Please see the attached short screenrecord (ca. 26 seconds long and ca.
3.8 MB big).
You'll see the old, disabled KBM-macro (for the Smart New Line) and the
new one (for Smart Quote), using the same trigger (CMD-Return) and doing
nothing (when you see that in the final the BBEdit-window doesn't change
at all I'm actually pressing CMD-Return repeatedly).


> You'll need to give more information and try messing with the
> script. Can't magically know what's wrong.

:-)
I realize this, sorry once again


> ~aw


Regards,
Vlad
>>> "sup...@barebones.com <javascript:>" 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+un...@googlegroups.com <javascript:>.
>>> To post to this group, send email to bbe...@googlegroups.com
>> <javascript:>.
Smart Quote doesn't work.mp4

Kendall Conrad

unread,
Jan 23, 2016, 11:09:25 AM1/23/16
to BBEdit Talk
Try setting the keyboard shortcut from within BBEdit and not using keyboard maestro. I don't use that program so not sure what side effects it could be causing. You can also try running the script from Script Editor. It may provide some output if it is hitting any errors. You can also add log messages in the script to see if values are being set correctly e.g., log "wleng = " & wleng

I'm using BBEdit 11.1.4.
It also works in TextWrangler 5.0.2.

Vlad Ghitulescu

unread,
Jan 23, 2016, 11:13:51 AM1/23/16
to BBEdit Talk


On 23 Jan 2016, at 17:09, Kendall Conrad wrote:

> You can also try running the script from Script Editor. It may
> provide some output if it is hitting any errors.

I did and got promptly a syntax-error (see attachment).

I have a fresh installed El Capitan & BBEdit (version 11.1.4 (3780)).
Bildschirmfoto 2016-01-23 um 17.11.41.png

Kendall Conrad

unread,
Jan 23, 2016, 11:41:10 AM1/23/16
to BBEdit Talk
Well, I can't read the exact error message since it's not English, but I believe I may see the problem. I think there's an extra line break after the word "searching". Make it so the next line is on the same line. That's the problem with posting code online, can't always control how it gets formatted. Later parts of the script had long lines as well so be sure they don't have extra new lines.

Vlad Ghitulescu

unread,
Jan 23, 2016, 11:52:14 AM1/23/16
to BBEdit Talk
I've got them right now, compiled the script, saved it in BBEdit's
script-folder and started from there (with the cursor in line 3). I've
got another error saying: BBEdit got an error: Can’t get searching of
line 3 of window 1. (see also the attached screenshots)
Bildschirmfoto 2016-01-23 um 17.48.12.png
Bildschirmfoto 2016-01-23 um 17.48.00.png

Kendall Conrad

unread,
Jan 23, 2016, 12:28:41 PM1/23/16
to BBEdit Talk
I don't see any obvious reason why it shouldn't be working. My example document looks like yours and I can't reproduce any errors. You might want to compare what you have with what I originally posted to make sure the script wasn't modified in any other ways while copying and pasting, especially the regular expression parts.

The block of code that's commented with "-- Define a tab ..." is not being used in the script so you can remove it. There's 3 spots that use the "searching" piece and can't tell which one was causing the error. You can try placing log statements around each one to see when it hits an error.

Vlad Ghitulescu

unread,
Jan 23, 2016, 2:14:07 PM1/23/16
to BBEdit Talk
Hello!


On 23 Jan 2016, at 18:28, Kendall Conrad wrote:

> I don't see any obvious reason why it shouldn't be working. My example
> document looks like yours and I can't reproduce any errors. You might
> want
> to compare what you have with what I originally posted to make sure
> the
> script wasn't modified in any other ways while copying and pasting,
> especially the regular expression parts.

I've checked now with the version from Safari (browsing the
BBEdit-Talk-discussion) and it looks the same.
I've then put both versions in two separate BBEdit-text-files and made a
diff… and found a different tab-length.
So I copied once again the new script, this time from browser and…
boom! This time it works!

The only little error is that it doesn't put a space on the new line
after > (see the attachment).


Gruß,
Vlad


Bildschirmfoto 2016-01-23 um 20.13.25.png

Kendall Conrad

unread,
Jan 23, 2016, 2:48:36 PM1/23/16
to BBEdit Talk
Yeah, I thought there may have been some weird white space issue. Glad that worked.

To get the extra space modified this following line near the end of the script.


        set selection to return & white & _char

and add the extra space there like so,


        set selection to return & white & _char & " "


~aw

Vlad Ghitulescu

unread,
Jan 23, 2016, 3:45:06 PM1/23/16
to BBEdit Talk


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

> Yeah, I thought there may have been some weird white space issue. Glad
> that
> worked.

Me too! Thanks again!


> To get the extra space modified this following line near the end of
> the
> script.
>
> set selection to return & white & _char
>
> and add the extra space there like so,
>
> set selection to return & white & _char & " "

That does it!
Thanks!


> ~aw


Regards,
Vlad



>
>
>
>
> On Saturday, January 23, 2016 at 2:14:07 PM UTC-5, Vlad Ghitulescu
> wrote:
>>
>> Hello!
>>
>>
>> On 23 Jan 2016, at 18:28, Kendall Conrad wrote:
>>
>>> I don't see any obvious reason why it shouldn't be working. My
>>> example
>>> document looks like yours and I can't reproduce any errors. You
>>> might
>>> want
>>> to compare what you have with what I originally posted to make sure
>>> the
>>> script wasn't modified in any other ways while copying and pasting,
>>> especially the regular expression parts.
>>
>> I've checked now with the version from Safari (browsing the
>> BBEdit-Talk-discussion) and it looks the same.
>> I've then put both versions in two separate BBEdit-text-files and
>> made a
>> diff… and found a different tab-length.
>> So I copied once again the new script, this time from browser and…
>> boom! This time it works!
>>
>> The only little error is that it doesn't put a space on the new line
>> after > (see the attachment).
>>
>>
>> Gruß,
>> Vlad
>>
>>
>>
>
Reply all
Reply to author
Forward
0 new messages