[ 1731384 ] problems with default macros

Joerg Fischer jf505 at gmx.de
Sun Jun 10 21:52:17 CEST 2007


Hi,

I can't find the button to attache a fix for this bug report, so I
attache the diff file here.

Cheers,
Jörg
-------------- next part --------------
--- source/preferences.c	Mon Mar 05 00:26:04 2007
+++ source/preferences-new.c	Sun Jun 10 17:18:08 2007
@@ -560,22 +560,13 @@
 		select(selStart, selEnd + 6)\n\
 	}\n\
 	Comments>/* Uncomment */@C at C++@Java at CSS@JavaScript at Lex:::R: {\n\
-		sel = get_selection()\n\
-		selStart = $selection_start\n\
-		selEnd = $selection_end\n\
-		commentStart = search_string(sel, \"/*\", 0)\n\
-		if (substring(sel, commentStart + 2, commentStart + 3) == \" \")\n\
-		    keepStart = commentStart + 3\n\
-		else\n\
-		    keepStart = commentStart + 2\n\
-		keepEnd = search_string(sel, \"*/\", length(sel), \"backward\")\n\
-		commentEnd = keepEnd + 2\n\
-		if (substring(sel, keepEnd - 1, keepEnd) == \" \")\n\
-		    keepEnd = keepEnd - 1\n\
-		replace_range(selStart + commentStart, selStart + commentEnd, \\\n\
-			substring(sel, keepStart, keepEnd))\n\
-		select(selStart, selEnd - (keepStart-commentStart) - \\\n\
-			(commentEnd - keepEnd))\n\
+		pos = search(\"(?n\\\\s*/\\\\*\\\\s*)\", $selection_start, \"regex\")\n\
+		start = $search_end\n\
+		end = search(\"(?n\\\\*/\\\\s*)\", $selection_end, \"regex\", \"backward\")\n\
+		if (pos != $selection_start || end == -1 )\n\
+		    return\n\
+		replace_selection(get_range(start, end))\n\
+		select(pos, $cursor)\n\
 	}\n\
 	Comments>// Comment at C@C++ at Java@JavaScript:::R: {\n\
 		replace_in_selection(\"^.*$\", \"// &\", \"regex\")\n\
@@ -601,12 +592,12 @@
 	Comments>! Uncomment at X Resources:::R: {\n\
 		replace_in_selection(\"(^[ \\\\t]*!)(.*)$\", \"\\\\2\", \"regex\")\n\
 	}\n\
-        Comments>% Comment at LaTeX:::R: {\n\
-                replace_in_selection(\"^.*$\", \"%&\", \"regex\")\n\
-                }\n\
-        Comments>% Uncomment at LaTeX:::R: {\n\
-                replace_in_selection(\"(^[ \\\\t]*%)(.*)$\", \"\\\\2\", \"regex\")\n\
-                }\n\
+	Comments>% Comment at LaTeX:::R: {\n\
+		replace_in_selection(\"^.*$\", \"%&\", \"regex\")\n\
+	}\n\
+	Comments>% Uncomment at LaTeX:::R: {\n\
+		replace_in_selection(\"(^[ \\\\t]*%)(.*)$\", \"\\\\2\", \"regex\")\n\
+	}\n\
 	Comments>Bar Comment at C:::R: {\n\
 		if ($selection_left != -1) {\n\
 		    dialog(\"Selection must not be rectangular\")\n\
@@ -623,8 +614,14 @@
 	Comments>Bar Uncomment at C:::R: {\n\
 		selStart = $selection_start\n\
 		selEnd = $selection_end\n\
-		newText = get_range(selStart+3, selEnd-4)\n\
-		newText = replace_in_string(newText, \"^ \\\\* \", \"\", \"regex\")\n\
+		pos = search(\"/\\\\*\\\\s*\\\\n\", selStart, \"regex\")\n\
+		if (pos != selStart) return\n\
+		start = $search_end\n\
+		end = search(\"\\\\n\\\\s*\\\\*/\\\\s*\\\\n?\", selEnd, \"regex\", \"backward\")\n\
+		if (end == -1 || $search_end < selEnd) return\n\
+		newText = get_range(start, end)\n\
+		newText = replace_in_string(newText,\"^ *\\\\* ?\", \"\", \"regex\", \"copy\")\n\
+		if (get_range(selEnd, selEnd - 1) == \"\\n\") selEnd -= 1\n\
 		replace_range(selStart, selEnd, newText)\n\
 		select(selStart, selStart + length(newText))\n\
 	}\n\


More information about the Develop mailing list