Last active
July 2, 2019 08:30
-
-
Save myui/6fa2abce6b54b0ca8d8ce45b2d6138af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set my_coment to "#" --コメント文字 | |
tell application "mi" | |
tell document 1 | |
set p_count to (count paragraphs of selection object 1) | |
set start_p to index of paragraph 1 of selection object 1 | |
set end_p to start_p + p_count - 1 | |
repeat with i from start_p to end_p | |
set tmp_str to quoted form of (paragraph i as Unicode text) | |
try | |
do shell script "echo " & tmp_str & " | grep -E '^[[:space:]]*" & my_coment & "'" | |
set paragraph i to (do shell script "echo " & tmp_str & "| sed -e 's/^\\([[:space:]]*\\)" & my_coment & "/\\1/;'") & return | |
on error errMsg number errNum | |
if errNum is 1 then | |
set paragraph i to (do shell script "echo " & tmp_str & "| sed -e 's/^/" & my_coment & "/;'") & return | |
else | |
activate | |
display dialog "Error!" | |
end if | |
end try | |
end repeat | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment