jed-users mailing list

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

Re: java mode comment string


On Mon, 3 Jun 2002 09:29:24 -0400 wrote Nathan Smith <nsmith@xxxxxxxxxxxx>:

> I ran into an interesting issue in java mode.
> 
> I attempted to do a comment_region, however I would get an error message
> saying that the comment string for java_mode has not been defined.
> 
> It appears that a line needs to be added to comments.sl:
>         set_comment_info ("java", "/* ", " */", 0);
> 
> I don't know if this is the Right Way (TM) to go about doing this, but it
> seems to work.
>   .nathan.

When writing comments.sl, the main issue was to offer a "mode-designers
tool" that 
   gives a common interface to  comment handling, and 
   can be easily used by new modes. 
(I did this by "outsourcing" code from Guido's ide_mode with some (and later
more) adaptions with help from JED.)

The basic idea is that a mode that wants to implement comment handling,
simply needs to do something like

    % do commenting with comments.sl
    require("comments");  % from jed's standard library
    set_comment_info (modename, "# ", "", 7);

in the mode-defining script. Advantage: there is no need to modify
comments.sl in order to get "color commenting" for a new mode.

The only reason for the set_comment_info commands for various modes inside
comments.sl is backward compatibility (actually, I would prefer them all
inside the modename.sl files).


The clean and "update save" way to implement comment handling for java
would be (IMHO)

 a) if you are the java.sl developer: in java.sl
 
      require("comments");  % from jed's standard library
      set_comment_info ("java", "/* ", " */", 0);

 b) otherwise: in your .jedrc (or jed.rc on non-Unix)
  
      define java_mode_hook()
      {
        require("comments");  % from jed's standard library
        set_comment_info ("java", "/* ", " */", 0);
      }

BTW: a TODO would be to reuse the information given in the define_syntax
command as comment info. Still, I don't know how to get it out of jed...
Also, there might be more than one comment string for one language.

      
Sincerely

Guenter      

--
G.Milde@xxxxxxxxxxxxxxxxxxxx


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


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