[Python-Dev] Reindenting unicodedata.c
Barry A. Warsaw
Mon, 11 Nov 2002 10:14:15 -0500
>>>>> "MvL" == Martin v Loewis <email@example.com> writes:
> * Local Variables:
> * c-basic-offset: 4
> * indent-tabs-mode: nil
MvL> Does that have the effect of expanding all tabs?
Ah, no it doesn't.
MvL> unicodeobject.c does use tabs for indenting multiple levels.
M-x untabify RET
MvL> In my revised patch for unicodedata.c, I put just
| Local variables:
| c-basic-offset: 4
MvL> unicodedata.c is inconsistent in this respect: it sometimes
MvL> uses tabs, and sometimes spaces.
BTW, for the Emacsen in the audience, here's a little elisp I use to
normalize whitespace. I mostly use this in Python code so YMMV. It
frst untabifies the buffer, and then it deletes bogus trailing
whitespace. I think it mostly works. ;) The defalias is just because
I can never remember what I called the function and don't have it
bound to a keychord.
-------------------- snip snip --------------------
;; untabify and clean up lines with just whitespace
(defun baw-whitespace-normalization ()
"Like untabify, but also cleans up lines with trailing whitespace."
(untabify (point-min) (point-max))
(while (re-search-forward "[ \t]+$" nil t)
(let ((bol (save-excursion (beginning-of-line) (point)))
(eol (save-excursion (end-of-line) (point))))
(goto-char (match-beginning 0))
(if (and (bolp)
(eq (char-after) ?\))
(skip-chars-backward " \t" bol)
(delete-region (point) eol)
(defalias 'baw-normalize-whitespace 'baw-whitespace-normalization)