[Python-Dev] Reindenting unicodedata.c (original) (raw)

Barry A. Warsaw barry@python.org
Mon, 11 Nov 2002 10:14:15 -0500


"MvL" == Martin v Loewis <martin@v.loewis.de> 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.

C-x h M-x untabify RET

MvL> In my revised patch for unicodedata.c, I put just

| /* 
| Local variables:
| c-basic-offset: 4
| End:
| */

+1

MvL> unicodedata.c is inconsistent in this respect: it sometimes
MvL> uses tabs, and sometimes spaces.

Dang.

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.

-Barry

-------------------- snip snip -------------------- ;; untabify and clean up lines with just whitespace (defun baw-whitespace-normalization () "Like untabify, but also cleans up lines with trailing whitespace." (interactive) (save-excursion (save-restriction (untabify (point-min) (point-max)) (goto-char (point-min)) (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) ?\ )) (forward-char 1)) (skip-chars-backward " \t" bol) (delete-region (point) eol) )) ))) (defalias 'baw-normalize-whitespace 'baw-whitespace-normalization)