Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
ocaml+twt v0.81
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-02-21 (00:56)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Re: [Caml-list] ocaml+twt v0.81
Thank you for this great utility!

I'd like to know what emac configuration users have. Hopefully we can
work towards a good sample file which could be included in the
distribution. Currently I use:

;;behaves like vim's autoindent
(defun caml+twt-calculate-indentation ()
       (if (bobp)
	   ;;If this is the first line then it should be set to 0
       (forward-line -1)
	 ;;Begin navigating to find the first previous non blank line...
       (while (and (not (bobp)) (looking-at "[:blank:]*\n"))
	 (forward-line -1))

;;Ripped of python.el hopefully we will be able to circle through tab
;;level someday
(defun caml+twt-indent-line ()
  (let ((target (caml+twt-calculate-indentation))
	(pos (- (point-max) (point))))
    (if (= target (current-indentation))
	(if (< (current-column) (current-indentation))
      (indent-to target)
      (if (> (- (point-max) pos) (point))
	  (goto-char (- (point-max) pos))))))

(define-derived-mode caml+twt-mode tuareg-mode "tuareg twt mode"
  (setq indent-line-function 'caml+twt-indent-line)
  (setq indent-tabs-mode 'nil)

;;(autoload 'caml+twt-mode "caml+twt" "Major mode for editing Ocaml+twt code" t)
(add-to-list 'auto-mode-alist '("\\.twt" . caml+twt-mode))

Till Varoquaux

P.S.: please be tolerant these are my first elisp lines ever...