- Subject: Suggestion (patch) for folding.sl
- From: <Jens.Wulf@xxxxxxxxxxxxxxxx>
- Date: Fri, 5 May 2006 08:35:44 +0200
Dear jed users,
I suggest to extend folding mode so that it allows to have marks which are recognized as folding marks, but to prefix new marks with a prefix string when using fold_fold_region().
Why?
I use folding at lot at home, but at work I don't, as I am the only one using jed and don't want to pollute my and other's files with folding marks.
Fortunately, using "{" and "}" as folding marks is quite a good idea for [C, C++, java, C#, ...].
You get structured folds when working with other's files for free.
But when I want to create an additional fold, I need to prefix "//" in order to not change the code.
The patch allows to use
mode_set_mode_info ("C", "fold_info", "/*{{{\r/*}}}\r*/\r*/");
like we are used to (four arguments). The behaviour is unchanged (prefix is an empty string).
But it does also allow something like
mode_set_mode_info ("C", "fold_info", "{\r}\r\r\r//");
with five arguments: start, end, end_of_start, end_of_end, prefix.
The patch is made against folding.sl of 0.99.16.
Best regards,
Jens
--- folding.sl_alt Fri May 05 07:56:11 2006
+++ folding.sl Fri May 05 08:15:16 2006
@@ -24,16 +24,23 @@
define fold_get_marks_for_mode () %{{{
{
- variable mode, fold_marks;
+ variable mode, fold_marks, count=0;
fold_marks = mode_get_mode_info ("fold_info");
if (fold_marks == NULL)
- return ("{{{", "}}}", "", "");
+ return ("{{{", "}}}", "", "", "");
% push the marks on stack
foreach (strchop (fold_marks, '\r', 0))
- ;
+ {
+ count++;
+ };
+ while (count < 5)
+ {
+ strtrim("");
+ count++;
+ }
}
%}}}
@@ -50,6 +57,7 @@
get_blocal_var ("fold_end");
get_blocal_var ("fold_end_of_start");
get_blocal_var ("fold_end_of_end");
+ get_blocal_var ("fold_prefix");
#else
fold_get_marks_for_mode ();
#endif
@@ -161,7 +169,7 @@
fold_open_buffer ();
bob ();
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
fold_level = prefix_argument (-1);
if (fold_level <= 0) fold_level = 1;
@@ -206,7 +214,7 @@
{
variable start, end, end_of_start, end_of_end;
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
push_spot ();
if (is_line_hidden ())
skip_hidden_lines_backward (1);
@@ -223,7 +231,7 @@
variable start, end, end_of_start, end_of_end;
variable h;
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
push_spot ();
@@ -255,7 +263,7 @@
{
variable start, end, end_of_start, end_of_end;
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
!if (fold_find_marker_line (start, end_of_start))
error ("Unable to find fold-start");
@@ -273,7 +281,7 @@
variable not_in_a_fold = "Not in a fold.";
variable end_line;
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
orig_mark = create_user_mark ();
@@ -342,7 +350,7 @@
variable not_in_a_fold = "Not in a fold.";
variable end_line;
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
push_spot();
@@ -425,10 +433,10 @@
define fold_fold_region () %{{{
{
- variable start, end, end_of_start, end_of_end;
+ variable start, end, end_of_start, end_of_end, prefix;
check_region (0);
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, prefix) = fold_get_marks ();
% We have a canonical region with point at end. See if this line
% is the start of a fold. If so, extend it to cover all of fold.
@@ -443,6 +451,7 @@
narrow ();
eob ();
newline ();
+ insert (prefix);
insert (end);
insert (end_of_end);
newline ();
@@ -453,7 +462,8 @@
skip_white ();
if (eolp ())
{
- bol ();
+ bol ();
+ insert (prefix);
insert (start);
push_spot ();
insert (end_of_start);
@@ -464,6 +474,7 @@
eol ();
trim ();
insert_single_space ();
+ insert (prefix);
insert (start);
insert (end_of_start);
bol ();
@@ -554,7 +565,7 @@
skip_hidden_lines_backward (1);
}
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
if (fold_is_fold (start, end_of_start))
fold_enter_fold ();
@@ -572,7 +583,7 @@
variable start, end, end_of_start, end_of_end;
if (but == 1)
{
- (start, end, end_of_start, end_of_end) = fold_get_marks ();
+ (start, end, end_of_start, end_of_end, ) = fold_get_marks ();
mouse_goto_position (col, line);
ERROR_BLOCK
@@ -636,7 +647,7 @@
define folding_mode () %{{{
{
- variable s, s1, e, e1;
+ variable s, s1, e, e1, p;
if (Fold_Mode_Ok == 0)
{
@@ -646,12 +657,13 @@
}
#ifdef HAS_BLOCAL_VAR
- (s, e, s1, e1) = fold_get_marks_for_mode ();
+ (s, e, s1, e1, p) = fold_get_marks_for_mode ();
define_blocal_var ("fold_start", s);
define_blocal_var ("fold_end_of_start", s1);
define_blocal_var ("fold_end", e);
define_blocal_var ("fold_end_of_end", e1);
+ define_blocal_var ("fold_prefix", p);
define_blocal_var ("bookmark_narrow_hook", ".fold_goto_bookmark_hook");
#endif
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]