caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocaml+twt v0.81
@ 2006-02-19  6:20 Mike Lin
  2006-02-21  0:56 ` [Caml-list] " Till Varoquaux
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Lin @ 2006-02-19  6:20 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

Hi all,

Here's a small bugfix update to "The Whitespace Thing" for OCaml, a
preprocessor that uses indentation instead of parenthesization to group
multi-line expressions, like in Python and Haskell. Although the
implementation approach I used has some limitations, I now use ocaml+twt for
all my new code and I recommend it, if you like this code style.

http://people.csail.mit.edu/mikelin/ocaml+twt/

Mike


--
Mike Lin
mikelin@mit.edu
CSAIL CompBio group, http://compbio.mit.edu/
32-G536 x3-3434

[-- Attachment #2: Type: text/html, Size: 695 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] ocaml+twt v0.81
  2006-02-19  6:20 ocaml+twt v0.81 Mike Lin
@ 2006-02-21  0:56 ` Till Varoquaux
  0 siblings, 0 replies; 2+ messages in thread
From: Till Varoquaux @ 2006-02-21  0:56 UTC (permalink / raw)
  To: Mike Lin; +Cc: caml-list

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 ()
     (save-excursion
       (beginning-of-line)
       (if (bobp)
	   ;;If this is the first line then it should be set to 0
	   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))
       (current-indentation)
       )
       ))

;;Ripped of python.el hopefully we will be able to circle through tab
indentation
;;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))
	    (back-to-indentation))
      (beginning-of-line)
      (delete-horizontal-space)
      (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))

Cheers,
Till Varoquaux

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-21  0:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-19  6:20 ocaml+twt v0.81 Mike Lin
2006-02-21  0:56 ` [Caml-list] " Till Varoquaux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).