jed-users mailing list

[2007 Date Index] [2007 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [jed] help for diff mode (syntax color via dfa)


On  9.05.07, SANGOI DINO LEONARDO wrote:
> > From: Jörg Sommer Sent: Tuesday, May 08, 2007 1:09 AM
> > "G. Milde" <milde@xxxxxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > My suggestion for the mapping of "standard" to "diffmode" colours is:
> > >
> > >   custom_color("diff_cmd",     get_color("operator"));    % diff
> > >   custom_color("diff_oldfile", get_color("bold"));        % ---
> > >   custom_color("diff_newfile", get_color("number"));      % +++
> > >   custom_color("diff_block",   get_color("preprocess"));  % @@
> > >   custom_color("diff_deleted", get_color("error"));       % - or <
> > >   custom_color("diff_added",   get_color("keyword"));     % + or >
> > >   custom_color("diff_junk",    get_color("comment"));     % Only /Binary
> > >
> > > Could we agree on such a colour setup?
> > Yes.

> The problem with this setup is that diff and block markers will not be in
> reverse... as those are "section delimiters", I prefer to be clearly
> visible.

Are there "standard colours" in your scheme that have reversed background?

I use non-default background for "status", "region", "menu*" and "linenum".
The problem with reversed background is, that it does not continue until the
right edge of the buffer (unless you fill the line with spaces) which looks
very ragged for e.g. comments. OTOH, I thought that "preprocess" lines
are (at least sometimes) also some kind of "section delimiters".

> And on my color scheme it looks not so well [...] I feel that we can't
> please everyone, so people will need to create a custom color scheme.

> But I want a default color scheme that:
> - is able to cope with any background color.
> - doesn't scare people away.

So do I. However, I find the *mapping-method* (custom_color() with
get_color() defaults) simpler and saver for working "out of the box"
than my intermediate solution with light and dark colour schemes.

IMO, we should look for a good mapping to put in diffmode.sl -- one that
works nice with (all?) standard colour schemes (as people with home-made
schemes should find it easyier to customize diff highlight as well).

> Anyways, I didn't have time to put this on jedmodes as promised (can someone
> make the days 36 hours long?)

No, I can't. But I could upload diffmode.sl if you agree.

> , so there is my latest version. 

Thanks.

Attached a pathc with my remaining suggestions:

%  * set default colors re-using existing color definitions
%    (better defaults for non-black color schemes but still customisable)
%  * diff_top_of_file(), diff_top_of_block(): try below if there is no top 
%    above -> lets diff_jump_to() also work from the top of the diff buffer
%  * new: diff_jump() (after a patch by Lechee Lai)


Günter
--- /home/milde/.jed/contribs/Dino/diffmode.sl	2007-05-09 11:24:52.000000000 +0200
+++ /home/milde/.jed/lib/diffmode.sl	2007-05-09 16:58:46.000000000 +0200
@@ -78,22 +78,6 @@
 % 
 %        set_color("diff_deleted", "blue", "red"); 
 %
-% If the "normal" background color is dark but not "black", you can choose the
-% default dark color scheme with
-% 
-%        diff_set_colors_dark(<bg>);
-%
-% where <bg> is the background color. 
-% 
-% Changed color settings will only take effect after deleting the DFA
-% cache file "diffmode.dfa" and restarting Jed!
-%
-% Requirements
-% ------------
-
-% Jed >= 0.99.16     % custom_color()
-% SLang 2          % "raw string literal"R
-
 % Thanks to
 % ---------
 % 
@@ -104,6 +88,11 @@
 %                 a lot of slang code I'm using)
 %}}}
 
+% Requirements
+% ------------
+
+% Jed >= 0.99.16     % custom_color()
+% SLang 2          % "raw string literal"R
 require("keydefs");  % standard mode, not loaded by default
 require("treemode");
 require("walk");
@@ -117,37 +106,13 @@
 
 % Colours
 
-% default color schemes for dark and light background
-define diff_set_colors_dark(bg)
-{
-	custom_color("diff_cmd",     "lightgray", "blue");  % diff
-	custom_color("diff_oldfile", "red",       "blue");  % ---
-	custom_color("diff_newfile", "green",     "blue");  % +++
-	custom_color("diff_block",   "lightgray", "cyan");  % @@
-	custom_color("diff_deleted", "red",       bg);      % -
-	custom_color("diff_added",   "green",     bg);      % +
-	custom_color("diff_junk",    "lightgray", "red");   % Only / Binary
-}
-
-define diff_set_colors_light(bg)
-{
-	custom_color("diff_cmd",     "blue",      bg);      % diff
-	custom_color("diff_oldfile", "red",       "cyan");  % ---
-	custom_color("diff_newfile", "blue",      "cyan");  % +++
-	custom_color("diff_block",   "black", 	"magenta");  % @@
-	custom_color("diff_deleted", "red",       bg);      % -
-	custom_color("diff_added",   "blue" ,     bg);      % +
-	custom_color("diff_junk",    "gray", 	   bg);      % Only / Binary
-}
-
-% set matching colour scheme
-private variable bg;
-( , bg) = get_color("normal");
-if (bg == "black" or bg == "blue")
-  diff_set_colors_dark(bg);
-else
-  diff_set_colors_light(bg);
-
+custom_color("diff_cmd",     get_color("menu"));        	% diff
+custom_color("diff_oldfile", get_color("menu_selection"));      % ---
+custom_color("diff_newfile", get_color("menu_selection_char")); % +++
+custom_color("diff_block",   get_color("preprocess"));  	% @@
+custom_color("diff_deleted", get_color("error"));       	% -
+custom_color("diff_added",   get_color("keyword1"));     	% +
+custom_color("diff_junk",    get_color("comment"));     % Only / Binary
   
 %%%% Diff low level helpers %{{{
 
@@ -227,7 +192,7 @@
 {
 	push_mark();
 	% search the diff marker.
-	if (bol_bsearch("--- ") == 0) {
+	if (andelse{bol_bsearch("--- ") == 0}{bol_fsearch("--- ") == 0}) {
 		pop_mark(1);
 		error("start of file not found.");
 	}
@@ -589,6 +554,24 @@
 
 %%%%}}}
 
+%%%% Jump to "right" source, ('+' to new, '-' to old) %{{{
+define diff_jump()
+{
+   variable ch;
+   push_spot();
+   bol();
+   ch = what_char();
+   pop_spot();
+   switch (ch)
+     { case '-': diff_jump_to(0); }
+     { case '+': diff_jump_to(1); }
+   % { message ("not on a -/+ marked line"); }
+     { diff_jump_to(0); } % there is a binding for jump_to(1)
+   % TODO: ask in minibuffer for new/old?
+}
+%%%%}}}
+
+
 %%%% Menu %{{{
 %%%%
 

[2007 date index] [2007 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]