Git Product home page Git Product logo

tuareg's Introduction

NonGNU ELPA MELPA DebianBadge License GPL 3 Build Status

Tuareg: an Emacs OCaml mode

This archive contains files to help editing OCaml code, to highlight important parts of the code, to run an OCaml REPL (also called toplevel), and to run the OCaml debugger within Emacs.

Package Contents

  • README.md — This file.
  • HISTORY — Differences with previous versions.
  • tuareg.el — A major mode for editing OCaml code in Emacs.
  • ocamldebug.el — To run the OCaml debugger under Emacs.
  • sample.ml — Sample file to check the indentation engine.
  • compilation.txt — To check the compilation regexp tuareg--error-regexp.

Install

The easier way to install Tuareg is though the Emacs package system with NonGNU ELPA or MELPA (configuration).

You can also install it using OPAM:

opam install tuareg

and follow the instructions given at the end of the opam installation.

If you want to install from the Git checkout, just add to your Init File the line:

(load "path-to-git-checkout-dir/tuareg-site-file")

If you want to byte compile the files, issue make elc. If you do this in Darwin, make sure that the version of Emacs displayed at the end of make elc is the sole that you use (the .elc files may not be compatible with other versions of Emacs installed on your system).

Usage & Configuration

The Tuareg major mode is triggered by visiting a file with extension .ml, .mli, and .mlp or manually by M-x tuareg-mode. A Menhir mode, tuareg-menhir, supports .mly files. (A special mode for .mll has yet to be written.)

For the convenience of users of ocsigen, the extensions .eliom, .eliomi trigger tuareg-mode.

Start the OCaml REPL with M-x run-ocaml. To evaluate a phrase, simply type S-⟨return⟩ (shift and return). You can also evaluate a phrase in a different buffer by typing C-c C-e when the cursor is on it (it will start the OCaml REPL if needed).

Run the OCaml debugger with M-x ocamldebug FILE.

Tips & customization

  • You can comment/uncomment a single line with tuareg-comment-dwim which is bound to C-cC-;.

  • By default, Tuareg will align the arguments of functions as follows:

      function_name arg1
        arg2
    

    This is what most OCaml programmers expect and is convenient if you use the following style:

      function_name (fun x ->
          do_something
        )
        arg2
    

    If you prefer the “lisp style” indentation in which arguments on the second line are aligned with the arguments on the first line as in

      function_name arg1
                    arg2
    

    put (setq tuareg-indent-align-with-first-arg t) in your Init File.

    In both cases, if there are no argument on the line following the function name, the indentation will be:

      function_name
        arg1
        arg2
    
  • To make easier to distinguish pattern-match cases containing several patterns, sub-patterns are slightly indented as in

      match x with
      | A
        | B -> ...
      | C -> ...
    

    If you prefer all pipes to be aligned as

      match x with
      | A
      | B -> ...
      | C -> ...
    

    use (setq tuareg-match-patterns-aligned t).

  • Emacs ≥ 24.4 turned on electric-indent-mode mode by default. If you do not like it, call (electric-indent-mode 0) in tuareg-mode-hook.

  • Tuareg respects you default commenting style. However, in OCaml, commenting a region is usually done with a single multi-line comment and without leading stars on each line. You can have that behavior in OCaml buffers by setting:

      (add-hook 'tuareg-mode-hook
                (lambda()
                  (setq-local comment-style 'multi-line)
                  (setq-local comment-continue "   ")))
    
  • If you turn on show-paren-mode, the delimiters of comments will also be highlighted. If you do not like this behavior, set tuareg-comment-show-paren to nil.

  • Syntax highlighting has 3 levels. You can select the one you prefer by setting font-lock-maximum-decoration from 0 to 2. By default, font-lock-maximum-decoration is set to t which means that the maximum level of decoration will be used.

  • Fontifying all operators (as opposed to only non-standard ones) is a costly operation that slows down font-lock. This is why it is disabled by default. If you nonetheless want it, set tuareg-highlight-all-operators to t in your Init File (before tuareg-mode is initialized; in particular, not in a hook added to 'tuareg-mode-hook).

  • You can turn on and off the rendering of certain sequences of characters as symbols (such as and instead of +.and &&), use prettify-symbols-mode or use the check box in the Tuareg Options menu. To enable it by default when you start Tuareg, add the following to your Init File:

      (add-hook 'tuareg-mode-hook
                (lambda()
                  (when (functionp 'prettify-symbols-mode)
                    (prettify-symbols-mode))))
    

    If you want more symbols to be prettified (such as -> being displayed as ) at the expense of modifying the indentation in incompatible ways with those not using that option, add (setq tuareg-prettify-symbols-full t) to your Init File.

  • By default, constructors are highlighted with the default face because having too many colors is distracting. If you wish to customize the appearance of constructors, add to your Init File the following code adapted to your tastes.

      (face-spec-set
       'tuareg-font-lock-constructor-face
       '((((class color) (background light)) (:foreground "SaddleBrown"))
         (((class color) (background dark)) (:foreground "burlywood1"))))
    
  • To have a list of definitions in the buffer, use imenu. It is available by right clicking in the buffer. You can also launch the speedbar and click on file to have a list of definitions.

  • If you wish to have a nice 🐫 as the mode name, add

      (add-hook 'tuareg-mode-hook
                (lambda() (setq tuareg-mode-name "🐫")))
    

    to your Init File.

Thanks to the work of Stefan Monnier, a new indentation engine based on SMIE was written. This changes the indentation somewhat w.r.t. the previous versions of tuareg. If the indentation does not correspond to what you expect, please submit a motivated issue.

The standard Emacs customization tool can be used to configure Tuareg options. It is available from the Options menu and Tuareg's Customize sub-menu. Note that, at the moment, both customization options pertaining to the SMIE indentation mode and the old one are present.

You may also customize the appearance of OCaml code by twiddling the variables listed at the start of tuareg.el (preferably using tuareg-mode-hook, you should not patch the file directly). You should then add to your configuration file something like:

(add-hook 'tuareg-mode-hook
  (lambda () ... ; your customization code ))

For example:

(add-hook 'tuareg-mode-hook
          ;; Turn on auto-fill minor mode.
          #'auto-fill-mode)

See dot-emacs.el for some examples.

Additional packages

Merlin

It is recommended to install Merlin which is available in OPAM. Tuareg will automatically detect it and use some of its features (e.g. for imenu). Merlin offers auto-completion, the possibility to query the type with C-cC-t, to find the location of an identifier with C-cC-l, to go to the next (resp. previous) phrase with C-cC-n (resp. C-cC-p),... Highly recommended.

opam-switch-mode

If you happen to work with several switches, it is recommended to install opam-switch-mode (available in NonGNU ELPA and MELPA). This minor mode defines a command M-x opam-switch-set-switch as well as a menu-bar and a mode-bar menu "OPSW", to easily select another OPAM switch. Upon such a change, a hook kills the running OCaml toplevel, if any, so that the next eval command is run using the OCaml toplevel from the new switch.

Caml mode

caml-mode (available in NonGNU ELPA and MELPA) is used to display types (using the obsolete *.annot files), open a module for documentation,...

Reporting

The official Tuareg home page is located at: https://github.com/ocaml/tuareg.

Bug reports & patches: use the tracker: https://github.com/ocaml/tuareg/issues.

Thanks

Ian Zimmerman for the previous mode, compilation interface and debugger enhancement.

Jacques Garrigue enhanced Zimmerman's mode along with an adaptation to OCaml (and Labl) syntax. Although this work was performed independently, his useful test file and comments were of great help.

Michel Quercia for excellent suggestions, patches, and helpful emacs-lisp contributions (full, ready-to-work implementations, I should say), especially for Tuareg interactive mode, and browser capacities.

Denis Barthou, Pierre Boulet, Jean-Christophe Filliatre and Rémi Vanicat for intensive testing, useful suggestions, and help.

Ralf Treinen for maintaining the Debian GNU/Linux package.

Every people who sent me bug reports, suggestions, comments and patches. Nothing would have improved since version 0.9.2 without their help. Special thanks to Eli Barzilay, Josh Berdine, Christian Boos, Carsten Clasohm, Yann Coscoy, Prakash Countcham, Alvarado Cuihtlauac, Erwan David, Gilles Défourneaux, Philippe Esperet, Gilles Falcon, Tim Freeman, Alain Frisch, Christian Lindig, Claude Marché, Charles Martin, Dave Mason, Stefan Monnier, Toby Moth, Jean-Yves Moyen, Alex Ott, Christopher Quinn, Ohad Rodeh, Rauli Ruohonen, Hendrik Tews, Christophe Troestler, Joseph Sudish, Mattias Waldau and John Whitley.

Tuareg mode have been maintained by Albert Cohen until version 1.45.

Jane Street took over maintenance based on Albert Cohen's version 1.46 (later retracted by him), and released its first version as 2.0.

License

Tuareg is distributed under the GNU General Public License, version 3 or later.

tuareg's People

Contributors

bbatsov avatar bcc32 avatar chris00 avatar darren avatar drup avatar drvink avatar erikmd avatar ilankri avatar jake-87 avatar jgarte avatar joey-coleman avatar kit-ty-kate avatar kosh04 avatar loloicci avatar mattiase avatar monnier avatar mookid avatar musha68k avatar phikal avatar rgrinberg avatar rjbou avatar sam-s avatar seanmcl avatar skangas avatar skyskimmer avatar syohex avatar tarsius avatar tchajed avatar trishume avatar wilfred avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tuareg's Issues

It's not clear for the installation documents.

Im new to tuareg and Ocaml, and I found in file "tuareg.em", the comments said

;; Installation:
;; If you have permissions to the local site-lisp' directory, you ;; only have to copytuareg.el', tuareg_indent.el',ocamldebug.el'
;; and tuareg-site-file.el'. Otherwise, copy the previous files ;; to a local directory and add the following line to your.emacs':
;;
;; (add-to-list 'load-path "DIR")

My qstn is to install tuareg, don't we need to run "Makefile"? What does it mean by "copy the previous files to a local directory"? WHat's the name of local directory?

Menu display real name

Would like to see the the real command name displayed too in menu. Also have same docu. WDYT?

begin .. end Indentation

Version 2.08 indents begin .. end statements as follows:

match foo with
| bar -> begin
         print_endline "new indentation"
       end
| baz -> ...

if test then begin
            print_endline "new indentation"
          end
else ...

whereas older versions would indent the above expressions as

match foo with
| bar -> begin
  print_endline "old indentation"
end
| baz -> ...

if test then begin
  print_endline "old indentation"
end
else ...

Is there a nice way to revert back to the old indentation style?

Add .eliom and .eliomi

Add .eliom and .eliomi as file extensions that trigger tuareg-mode.

.eliom and .eliomi are source files with ocaml code that use Eliom's syntax extension for ocsigen.

Ocaml specific navigation commands

Suggest to introduce:

  • tuareg-forward-top-level
  • tuareg-backward-top-level
  • tuareg-forward-block
  • tuareg-backward-block
  • tuareg-forward-linewise
  • tuareg-backward-linewise

where cursor travels indents, resp. end of line

Tuareg loops on re-flowing unclosed comments

Tuareg loops on re-flowing (M-q) unclosed comments, bringing the whole emacs down. The only thing that saves it afterwards is xkill. For now I've been getting this with version 20141026.743, but I'll try to update to the most recent version to see if it still happens. Screenshot attached.
screenshot from 2015-05-04 09-20-55

tuareg-indent begin match end

now tuareg-indent is

begin match a with
| A(a) -> a
| B(a) -> a
end

but, I hope

begin match a with
| A(a) -> a
| B(a) -> a
end

or

begin match a with
| A(a) -> a
| B(a) -> a
end

If you please change begin match indent.
I am sorry my english is poor.
Thanks.

ocamldebug arguments when run from Emacs

Is ocamldebug able to take arguments to the program it's stepping through when run from Emacs?

I modified it slightly to do so (using read-from-minibuffer) but am not sure if there's an existing/better way. If there isn't, I would also be happy to open a PR.

Invalid function: tuareg-with-internal-syntax

With emacs 24.3, I get Invalid function: tuareg-with-internal-syntax in the minibuffer when indenting on both master and 2.0.8. No functionality seems to be lost (but I haven't searched for brokenness very far).

Respect user key bindings

Key bindings prefixed with "C-c" are reserved for user definitions.

The bindings currently on "C-c" in Tuareg mode should be bound to a new keymap. Users can then easily bind this new map to "C-c" (or anything else) using define-prefix-command.

Support exception branches in match

In OCaml 4.02, match expressions have been extended to allow exception branches. This isn't recognized yet, and using the syntax throws off font-lock and indentation.

let n = match List.find ((=) 3) [1;2] with
  | x -> x
  | exception Not_found -> 0
              in n               (* Should be at leftmost indentation *)

tuareg-use-syntax-ppss running into error

It makes no sense introducing a boolean

tuareg-use-syntax-ppss

if alternatively an error is sent:

(defalias 'tuareg-in-literal-or-comment
[ ... ](eval-and-compile %28if tuareg-use-syntax-ppss
'tuareg-ppss-in-literal-or-comment
'tuareg-!ppss-in-literal-or-comment)))
and than:

(defun tuareg-ppss-in-literal-or-comment () (error "tuareg uses PPSS"))

"module type" and "begin" don't use hanging indentation

The module type and begin constructs seem to be left out of the set of things that can be written in a "hanging" style. This is what I'm getting:

module M = struct (* OK *)
  thing
end

module type M = sig (* Compare with the above *)
    thing
  end

if test then begin
            thing
          end

This is what I'd like to get:

module M = struct
  thing
end

module type M = sig
  thing
end

if test then begin
  thing
end

As far as I can tell this is simply due to sig and begin missing from the list of hanging keywords in tuareg-smie-rules. Please see #12.

Incorrect highlighting of 'let' with show-paren-mode

With emacs 24.4 and tuareg 2.0.8, enabling show-paren-mode results in somewhat strange highlighting. For a buffer containing only the code:

let f () =
  let x = 0 in
  ()

putting the point at in correctly highlights the matching let, but putting the point at that let highlights it as unmatched. For reference, the behavior of forward-sexp and backward-sexp is consistent, moving from in to let, but not back. The highlighting of parens, brackets, etc. as well as begin and end seems to work as expected.

tuareg-mode 2.0.8 freezes with specific code

I open a new empty file, type the following code, and then emacs freezes just after typing | key.

let f = function
A -> true
|

I don't know whether this really comes from tuareg 2.0.8 or not, but 2.0.6 seems to be fine (not freezes). I try emacs 23.4.1 and 24.4.1. Will you have any idea?

opam needs depexts on `emacs`

The build fails if Emacs is not installed:

# make[1]: Entering directory `/home/opam/.opam/system/build/caml-mode.4.02'
# Installing in /home/opam/.opam/system/share/emacs/site-lisp...
# if test -d /home/opam/.opam/system/share/emacs/site-lisp; then : ; else mkdir -p /home/opam/.opam/system/share/emacs/site-lisp; fi
# cp caml-font.el caml-hilit.el caml.el camldebug.el inf-caml.el caml-compat.el caml-help.el caml-types.el caml-xemacs.el caml-emacs.el /home/opam/.opam/system/share/emacs/site-lisp
# if [ -z "" ]; then \
#     cd /home/opam/.opam/system/share/emacs/site-lisp; emacs --batch --eval '(progn (setq load-path (cons "." load-path)) (byte-compile-file "caml-xemacs.el") (byte-compile-file "caml-emacs.el") (byte-compile-file "caml.el") (byte-compile-file "inf-caml.el") (byte-compile-file "caml-help.el") (byte-compile-file "caml-types.el") (byte-compile-file "caml-font.el") (byte-compile-file "camldebug.el"))'; \
#   fi
# make[1]: Leaving directory `/home/opam/.opam/system/build/caml-mode.4.02'
### stderr ###
# [...]
# grep: opam/opam: No such file or directory
# grep: opam/opam: No such file or directory
# grep: opam/opam: No such file or directory
# grep: opam/opam: No such file or directory
# grep: opam/opam: No such file or directory
# grep: opam/opam: No such file or directory
# grep: opam/opam: No such file or directory
# /bin/sh: 2: emacs: not found
# make[1]: *** [simple-install] Error 127
# make: *** [install] Error 2

http://www.recoil.org/~avsm/opam-bulk/logs/local-ubuntu-14.04-ocaml-4.02.1/raw/caml-mode.html#bottom

tuareg-indent-phrase inside unclosed comment

The following .ml file:

(* this is an unclosed comment

Using tuareg, if you position the cursor inside the comment, and call ESC-q (tuareg-indent-phrase), the emacs process uses 100% CPU and becomes unresponsive, and then has to be killed and restarted.

This is clearly a bug. Can someone confirm this behaviour?

tuareg-cache-stop wrong definition

(defvar tuareg-cache-stop (point-min))

can't be right, as the result of (point-min) is not predictable - due to buffer-narrowing.
This this value gets initialized at hazard.

Installing from MELPA causes errors

Well, one error, anyway. When installing tuareg from MELPA, I get the following message:

Compiling file /home/fs/.emacs.d/elpa/tuareg-20150316.1247/ocamldebug.el at Mon May  4 14:50:40 2015
Entering directory `/home/fs/.emacs.d/elpa/tuareg-20150316.1247/'
ocamldebug.el:42:1:Error: Cannot open load file: no such file or directory, /home/fs/.emacs.d/tuareg

This is on Emacs 24.4, with the spacemacs configuration setup.

bug with easy menu when smie off

Hi! I found a bug when smie is off on the current github version of tuareg. Here is a patch to solve it:

--- a/tuareg.el
+++ b/tuareg.el
@@ -333,7 +333,7 @@ Valid names are browse-url',browse-url-firefox', etc."
`(("Automatic indentation of leading keywords" . 'tuareg-use-abbrev-mode)
("Automatic indentation of ), ] and }" . 'tuareg-electric-indent)
,@(unless tuareg-use-smie

  •    '("Automatic matching of [| and {<" . 'tuareg-electric-close-vector))
    
  •    '(("Automatic matching of [| and {<" . 'tuareg-electric-close-vector)))
    

    "---"
    ,@(unless tuareg-use-smie
    '(("Indent body of comments" . 'tuareg-indent-comments)

New string syntax

OCaml 4.02 supports a new syntax for string literals like this {eof|this is a string|eof} which are great for multi line strings, etc. As far as I've seen they are not getting highlighted by Tuareg, yet (checked behavior of release 2.0.8 and quickly skimmed the git repo).

See list of 4.02 changes, documentation

New release

I'm wondering when is the next release panned ?
I'm using the dev version for quite some time now because it includes a fix for an infinite loop I had quite a few times so it would be great to have a release I think.

Cheers,

interactive mode: eval-phrase determines wrong region for modules with both structure and signature

(I am "porting" this from the OCaml Forge bug, since I am still seeing this behavior in tuareg-mode from MELPA, and I am not sure if OCaml Forge bugs are being monitored; the kludge I describe in my comment still "fixes" the behavior for me, but it's pretty ugly)

Date: 2011-04-24 06:17
Priority:3
State:Open
Submitted by:Gabriel Scherer (bluestorm)
Assigned to:Nobody (None)
Hardware:None
Resolution: None
Severity: None
Version: None
Component: None
Operating System: None
Product: None
URL:

Summary:

interactive mode: eval-phrase determines wrong region for modules with both structure and signature

Detailed description

Both the following code snippets fail when I try to send them to the toplevel using tuareg-eval-phrase :

module A : sig
val x : int
end = struct
let x = 0
end
module A = (
struct
let x = 0
end
:
sig
val x : int
end)

In both cases, Tuareg only send the phrase upto the first end, which results in syntax errors.

Followups

Message

Date: 2013-11-27 22:09
Sender: Evgeny Roubinchtein

I hit this also. As a stop-gap measure, I replaced the uses of tuareg-discover-phrase with caml-find-phrase: so far, my experience seems to be an overall improvement ( tuareg-eval-phrase uses tuareg-discover-pharse to find the portion of the buffer it needs to send to OCaml toplevel). The specific Elisp code I used appears below:

(defadvice tuareg-discover-phrase (around use-caml-find-phrase)
"Replace uses of `tuareg-discover-phrase' with `caml-find-phrase'"
(save-excursion
   (let ((begin (caml-find-phrase)))
      (setq ad-return-value (list begin (point) (point))))))
(ad-activate 'tuareg-discover-phrase t)

The above does assume that caml.el is avaliable: I used Emacs package.el to install tuareg, and tuareg package depends on the caml package, so, things "work for me."

Pre-compiling on OSX may break

See discussion at: http://lists.ocaml.org/pipermail/teaching/2015-January/000062.html

The issue is that OSX comes with an older, console version of Emacs, which will be used for the compilation at tuareg installation time; whilst most users will then be using a newer, graphic version, bundled as an app. The .elc that are generated with the older version generate strange problems (uncolored buffer, that can be colored by font-lock-fontify-buffer but then prints an error at every insert).

The easiest would be to not run the compilation by default in the OPAM package.

Remove !ppss

Providing a workaround for the absence of syntax-ppss (supported since the 15 years old Emacs 21 with the syntax.el add on) leads to code duplication for no good reason nowadays. Syntax-ppss is currently not supported on the 6½ years old XEmacs 21.4.22 but the beta XEmacs 21.5.32, released in 2012, has syntax-ppss.el. I think it should be removed.

Cannot write array literals

If I try to evaluate

let y = [| 1; 2 |] ;;

I get this

# let y = [| 1; 2 |;;
Characters 16-17:
  let y = [| 1; 2 |;;
                  ^
Error: Syntax error

For some reason the last ] is not passed to the ocaml process, resulting in a syntax error.

Missing newlines in source

From line 504 on a bunch of top-level definitions --defvar and defun-- are missing a newline between.
This makes the source difficult to read.

Function indentation

Version 2.0.8 indents function bodys the following way

let g x = h x ~f:(fun y ->
                  y + 1
                 )

while olders versions used to indent it this way:

let g x = h x ~f:(fun y ->
  y + 1
)

Is there a simple way to revert to the old behavior? Thanks!

Functor indentation

Tuareg indents functor declarations like this:

module Set =
  functor (Elt: ORDERED_TYPE) ->
          struct
          end

Shouldn't it be more like this:

module Set =
  functor (Elt: ORDERED_TYPE) ->
    struct
    end

At least, that's the style used in the manual

Are the “new” indentation functions ready?

Tuareg mode completely changed its auto indentation functions, resulting in a quite different user experience. Taste matters left aside, I do not feel that these “new” indentation functions are ready.

There is two serious problems with these new indentation functions:

  • They seem to ignore the tuareg-*-indent variables.
  • They are stubbornly automatic.

About tuareg-*-indent variables. If the variables are not used anymore, they should be removed, their mere existence induces the user in error. If these variables are currently not used anymore but should soon be used again, it is an objective sign that the feature is not terminated and should live in a development branch.

About stubbornness. It seems that the RETURN key calls the automatic indentation functions on the current line. In the cases where these functions are wrong, this is very annoying, as the user must quote most of its input. There is an important case where these functions are almost always wrong: when editing a codebase prepared with other indentation settings. In this case, it is important to preserve the structure to avoid introducing artificial code changes in the repository.


Suggested resolution

  • Revert the change bringing new indentation functions in in the main branch.
  • Start a development branch using the new indentation functions.
  • Prepare an automatic test suite to help debugging indentation functions.
  • Arrange so that a user can choose between the two indentation function sets.

I know very little elisp, but I think I can help for the three first points above.

Infinite loop

Hello, it seems that tuareg causes my emacs to fall into infinite loop when I try to press tab in a .mll file, more precisely when I try to indent the parsing rules.

I hope this is a real bug and not just my computer being weird, and that I won't loose your time.

Thx a lot.

top-level indentation

Hello! I am new to OCaml, but have been using Emacs for a few years now.

When I try to indent the following code in an otherwise empty source file in tuareg-mode:

let print_world () = print_endline "hello world" ;;
print_world () ;;

I get:

let print_world () = print_endline "hello world" ;;
  print_world () ;;

That seems strange to me. What is the logic behind indenting the second line. Shouldn't it be the same as the first?

circular dependencies

At the end of tuareg.el:

;; Pre-SMIE indentation functions.
;; Load it after providing `tuareg' to avoid circular dependencies.
(require 'tuareg_indent)

However in tuareg_indent.el resides:

(require 'tuareg)

So the circular is already there.

Will fix this alongside with in-string/comment re-write

Font-lock fails for type expressions

Font-lock rules seems to be failing to apply to type expressions in many cases.

These cases fail for me:

(* type signatures never work *)
val x : int
val f : int -> int
(* inline function type signatures - parameters seem to break it *)
let f x : int = x + 1

Only non-function values declared with let and type definitions work.

What about changelog?

I met an issue yesterday. When I upgrade from tuareg 2.0.6 to 2.0.7 my keywords change colors from orange to some strange color.. I have tried to study HISTORY file but it seems that changes for 2.0.5 are last in it. Can you upgrade it, please?

cyclic-function-indirection tuareg-fontify

Activating trace messages this:

Debugger entered--Lisp error: (cyclic-function-indirection tuareg-fontify)
indirect-function(tuareg-fontify)
ad-real-orig-definition(tuareg-fontify)
ad-make-advised-definition(tuareg-fontify)
ad-activate-advised-definition(tuareg-fontify nil)
ad-activate(tuareg-fontify nil)
trace-function-internal(tuareg-fontify nil nil)
trace-function(tuareg-fontify)
[ ... ]

Struct indentation

Tuareg indents module definitions as follows currently:

module Foo =
  struct
  end

Notice that the struct is indented relative to module.

How can I get Tuareg to not indent struct relative to module, i.e.

module Foo =
struct
end

Extremely slow font-lock

I've been having a few cases where tuareg freezes for a long time since I upgraded to emacs 24.3.1 and a recent tuareg mode (currently 20141026.743 from one of the ELPAs).

A simple reproduction case (tested with emacs -Q) is:

class bar = (foo object method private foo : int end

If I place the cursor on the o in object and type : it takes about 30 seconds to respond. If I then press space it freezes entirely (possibly an infinite loop but probably just such a long time that I give up and kill emacs).

If I run the profiler on the 30 second example, it says that 90+% of the time was in some jit-lock functions, so I assume that's where the problem is.

Module return with signature indentation

Consider the following:

module Make_comp(C : Comparitor) : Comparitor_intf with type t := C.t =
                                                                    struct
                                                                      type t = C.t
                                                                      let ret = C.comp
                                                                    end

The struct portion should not be indented all the way over there :)

"let _" is needed to for `tuareg-eval-phrase`

If I have the following buffer, with the point after the last ;;

let x = 12;;

print_endline "hello word!";;

when I type C-x C-e I get this as output:

# let x = 12;;
val x : int = 12

To actually evaluate the last phrase, I need to prefix it with let _.

Is this a misconfiguration on my side?

Is this the official repo now?

I'm slightly confused at the state of Tuareg Mode.

Is this project now the “official home” of Tuareg Mode? Where should I report issues now, and from where should I install Tuareg Mode?

There's also a project on OCaml Forge, but it's repository is some commits behind this one. However, issues seem to be handled, that is, there some recent issues and people comment on them. On the other hand, this repo has just one issue (which a collaborator commented on, though).

Tuareg hangs emacs after inputing `for i = `

The problem could be reproduced by:

  1. Open a new file in Tuareg mode.
  2. Input for i = at the start of the file.
  3. Input a space after for i = by pressing the space key.

Then emacs hangs.

The emacs version is 24.4.1; caml package version is 3.12.0.1; tuareg version is 2.0.8.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.