[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
my-calculate-indent function
From: |
Pietro Giorgianni |
Subject: |
my-calculate-indent function |
Date: |
Tue, 17 Apr 2007 02:02:41 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) |
hi,
i'm working on a major mode for a simple script language.
blocks are enclosed in {}, and i wrote this function:
(defun tintin-calculate-indent ()
(let ((opened (count-matches "{" 0 (point)))
(closed (count-matches "}" 0 (point))))
(max 0
(if (equal (char-after) 125)
(* tintin-indentation-step (- (- opened closed) 1))
(* tintin-indentation-step (- opened closed))))))
which works, but is ugly.
questions:
1) is there already a function that does this?
2) if not, how can i do it better?
thanks
giorgian
- my-calculate-indent function,
Pietro Giorgianni <=