unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* my-calculate-indent function
@ 2007-04-17  0:02 Pietro Giorgianni
  0 siblings, 0 replies; 4+ messages in thread
From: Pietro Giorgianni @ 2007-04-17  0:02 UTC (permalink / raw)
  To: help-gnu-emacs

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

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

end of thread, other threads:[~2007-04-20  2:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2156.1176768900.7795.help-gnu-emacs@gnu.org>
2007-04-17  3:06 ` my-calculate-indent function Stefan Monnier
2007-04-20  2:21   ` Tim X
2007-04-20  2:18 ` Tim X
2007-04-17  0:02 Pietro Giorgianni

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 read-only IMAP folder(s) and NNTP newsgroup(s).