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

2016-01-23 Thread Vlad Ghitulescu

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 	if (leng - wleng) > 2 and (characters (wleng + 1) through (wleng + 3) 
of line lineNum as string) is equal to "]*>" options {search mode:grep} searching 
in (line lineNum)

if found of liResult then
set selection to return & white & (found text of liResult) & 
""
else
-- just use a plain li tag
set selection to return & white & ""
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

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

2016-01-23 Thread Kendall Conrad
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.



On Saturday, January 23, 2016 at 10:36:33 AM UTC-5, Vlad Ghitulescu wrote:
>
> 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 
>
>
>
> > 
> > 
> > 
> > 
> > On Saturday, January 23, 2016 at 8:11:55 AM UTC-5, Vlad Ghitulescu 
> > wrote: 
> >> 
> >> 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 

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

2016-01-23 Thread Kendall Conrad
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




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

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


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

2016-01-23 Thread Kendall Conrad
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




On Saturday, January 23, 2016 at 8:11:55 AM UTC-5, Vlad Ghitulescu wrote:
>
> 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  if (leng - wleng) > 2 and (characters (wleng + 1) through (wleng + 
> 3) 
> of line lineNum as string) is equal to " -- Capture the whole li tag including attributes 
> set liResult to find "]*>" options {search 
> mode:grep} searching 
> in (line lineNum) 
> if found of liResult then 
> set selection to return & white & (found text of 
> liResult) & "" 
> else 
>  

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

2016-01-23 Thread Kendall Conrad
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.



On Saturday, January 23, 2016 at 11:13:51 AM UTC-5, Vlad Ghitulescu wrote:
>
>
>
> 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)).

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


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

2016-01-23 Thread Kendall Conrad
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.



On Saturday, January 23, 2016 at 11:52:14 AM UTC-5, Vlad Ghitulescu wrote:
>
> 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) 
>
> On 23 Jan 2016, at 17:41, Kendall Conrad wrote: 
>
> > 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. 
> > 
> > 
> > 
> > On Saturday, January 23, 2016 at 11:13:51 AM UTC-5, Vlad Ghitulescu 
> > wrote: 
> >> 
> >> 
> >> 
> >> 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)). 
> > 
> > -- 
> > 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:  
> > 
> > --- 
> > 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 
> . 
>

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


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

2016-01-23 Thread Vlad Ghitulescu



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





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


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