caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Till Varoquaux" <till.varoquaux@gmail.com>
To: "Mike Lin" <mikelin@mit.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] ocaml+twt v0.81
Date: Tue, 21 Feb 2006 01:56:28 +0100	[thread overview]
Message-ID: <9d3ec8300602201656m2e81bf82xf16a0298c2e744ac@mail.gmail.com> (raw)
In-Reply-To: <2a1a1a0c0602182220r71236921q5245e21812bffc75@mail.gmail.com>

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...


      reply	other threads:[~2006-02-21  0:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-19  6:20 Mike Lin
2006-02-21  0:56 ` Till Varoquaux [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d3ec8300602201656m2e81bf82xf16a0298c2e744ac@mail.gmail.com \
    --to=till.varoquaux@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=mikelin@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).