Version française
Home     About     Download     Resources     Contact us    
Browse thread
Wishes for an easy install of Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <Christophe.Troestler@u...>
Subject: Re: tuareg-mode v.s. caml-mode (was: Wishes for an easy install of Ocaml)
On Sun, 02 Jan 2005, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
> 
> Having never tried Tuareg (mostly out of inertia, since I'm
> satisfied with the core mode), could you be more precise about what
> is better in Tuareg.

For me essentially
- font-lock
- more customizable

Caml-mode font-lock is not bad but it has some shortcomings and is
difficult to tailor to one likes [1] -- as far as I know (please,
correct me if I am wrong), one cannot change the font-lock colors on a
per-mode basis.  Granted, this is a convenience issue but when you get
used to comfort...

On the other hand, the caml-mode has also strong points: it has the
ability to display the "definitions" in the speedbar -- at least if
you add

(speedbar-add-supported-extension '(".ml" ".mli" ".mll" ".mly"))

in ~/.emacs -- and tuareg currently does not. :(

> Ditching the core mode would indeed save time for some people.

Note that tuareg uses some files of the caml-mode.  What about some
collaboration to merge the better of the two modes into a unique one??

> (But note that in order to replace the core mode, you have to be
> able to indent in exactly the same way.)

I do not know all params of the core mode but here is my config and it
is pretty close:

          (setq tuareg-in-indent 0)
          (setq tuareg-let-always-indent t)
          (setq tuareg-let-indent 2)
          (setq tuareg-with-indent 0)
          (setq tuareg-function-indent 0)
          (setq tuareg-fun-indent 0)
          (setq tuareg-parser-indent 0)
          (setq tuareg-match-indent 0)
          (setq tuareg-begin-indent 2)
          (setq tuareg-parse-indent 2); .mll
          (setq tuareg-rule-indent 2)

Here is an example where it is not exactly the same but tuareg mode
behavior seems more reasonable to me:

caml-mode:

    Hashtbl.iter (fun id buf ->
      output_string fcgi_stdout fd id (Buffer.contents buf);
      Buffer.clear buf
		 ) outputs_stdout;

tuareg-mode:

    Hashtbl.iter (fun id buf ->
		    output_string fcgi_stdout fd id (Buffer.contents buf);
		    Buffer.clear buf
		 ) outputs_stdout;

Happy new year,
ChriS

---
[1] Some examples to give you an idea:

- [data: string] and [data : string] get highlighted differently
  (yes, there is only a non-significant space difference);

- "|" and "->" are set to font-lock-constant-face (too bright for me)
  but I cannot change their colors without affecting other symbols and
  other modes.  Moreover in "[|" both or none should be highlighted.

- Constructors get the font-lock-function-name-face (which I would do
  without personally) but the real functions [let f x =...] do not.
  Tuareg is much better at highlighting functions and variables.

- The main thing that bother me basically is that the faces are not
  set in a way that reflects their semantic : for example

  * [open] is colored with font-lock-variable-name-face (sic),
  * [raise] is with font-lock-comment-face,
  * [for] and [if] are keywords and should be treated as such!
  * font-lock-doccomment-face should be replaced with font-lock-doc-face

  and so caml-mode colors do not have the same meaning as in other
  buffers...

- Here is a doc comment not which is not highlighted:

  (** [decode_range s low up] decodes the substring [s.[low .. up-1]]
      i.e., in the returned string the '%XX' and '+' are converted
      into their chars.  The range [s.[low .. up-1]] is overwritten.
      It returns the decoded string.

      [decode_range_strip] does the same, except that the decoded
      strings are stripped of heading and trailing spaces.

      It is ASSUMED that the range is valid i.e., [0 <= low] and [up <=
      String.length s].  Invalid '%XX' are left unchanged. *)

- Here is a normal comment which is not highlighted:

(* File: cgi_common.ml

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details; it is available at
   <http://www.fsf.org/copyleft/gpl.html>, or by writing to the Free
   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
*)