[Divunal-devel] Indentation fixes/update your code now/emacs
James Knight
jknight@MIT.EDU
Fri, 25 Jun 1999 01:59:25 -0400
Everything in twisted.* is now indented properly (as far as I know), so
it'd be a good idea to update your code now so you don't get stuck with
massive conflcts. :) In this case, properly means 4 character tabs, 1 tab
indentation (4 column), tabs used everywhere they can be (ie not 4 spaces
anywhere). I would do the same to divunal.* but I'm a little hesitant to do
that because I suspect its being more heavily developed upon and I don't
want to make people's lives TOO hard. :) So anyways, if the people who are
writing that code would be so kind, it is possible to reindent in emacs
with 1 easy command (after you've copied all the code below into your
.emacs file that is):
Just type control-C r in the buffer you want to reindent. Wasn't that easy? :)
(defun reindent-buffer ()
"Reindent the whole buffer in the currently active style."
(interactive)
(indent-region (point-min) (point-max) nil)
(tabify (point-min) (point-max)))
(global-set-key "\C-cr" 'reindent-buffer)
(require 'cc-mode)
(defun c-indent-region (start end)
(save-excursion
(goto-char start)
(beginning-of-line)
(let ((endmark (copy-marker end))
(c-tab-always-indent t))
(while (and (bolp) (not (eobp)) (< (point) endmark))
;; Indent one line as with TAB.
(c-indent-line)
(forward-line 1))
(set-marker endmark nil))))
Note that the reindent-buffer calls tabify, because indent-region will
leave four spaces instead of a tab if it didn't have to move the line.
One problem i ran into is that the c-indent-region that comes with emacs is
buggy (if you have a javadoc comment with a blank line it fails to reindent
that line at all, it probably messes up other things as well) So i made a
new one. That's why that code is in there. Now it works. :)
And just in case you missed the previous email, here's what you have to do
to make the indentation style pretty. :) (if anyone else is using an
indentation style that is different (glyph?) maybe you could send it to me).
(c-add-style "james" '((c-basic-offset . 4)
(tab-width . 4)
(c-comment-only-line-offset . 0)
(c-offsets-alist . (
(statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(label . 0)
(statement-cont . +)
(inline-open . 0)
))
))
(if (= emacs-major-version 19)
(c-set-style "james"))
(add-hook 'c-mode-common-hook '(lambda () (c-set-style "james")))
-James
(okay, that's enought emacs-hacking for one day)
--
You are in a maze of testy little Java VMs, all subtly different.