From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: michael@cadilhac.name (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) Newsgroups: gmane.emacs.devel Subject: Whitespace cleanup, tab-width and religion. Date: Wed, 20 Dec 2006 15:11:07 +0100 Organization: Epita/LRDE Message-ID: <87fybafyis.fsf@lrde.org> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0964612136==" X-Trace: sea.gmane.org 1166623807 16524 80.91.229.10 (20 Dec 2006 14:10:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 20 Dec 2006 14:10:07 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 20 15:10:04 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1Gx28m-0007M4-Ca for ged-emacs-devel@m.gmane.org; Wed, 20 Dec 2006 15:09:53 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gx28l-0002XD-7f for ged-emacs-devel@m.gmane.org; Wed, 20 Dec 2006 09:09:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gx28W-0002Wy-8m for emacs-devel@gnu.org; Wed, 20 Dec 2006 09:09:36 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gx28U-0002Wl-B1 for emacs-devel@gnu.org; Wed, 20 Dec 2006 09:09:35 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gx28U-0002Wi-6b for emacs-devel@gnu.org; Wed, 20 Dec 2006 09:09:34 -0500 Original-Received: from [62.39.139.2] (helo=kualalumpur.lrde.epita.fr) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Gx28S-0005zA-Sc for emacs-devel@gnu.org; Wed, 20 Dec 2006 09:09:33 -0500 Original-Received: from mahaena.lrde.epita.fr ([192.168.101.66] helo=mahaena.lrde) by kualalumpur.lrde.epita.fr with esmtp (Exim 4.50) id 1Gx28R-0001qw-Ob for emacs-devel@gnu.org; Wed, 20 Dec 2006 15:09:31 +0100 Original-To: emacs-devel@gnu.org Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEVWPh+Tai+5r5YKBAEU CQQzGAtiq7gjAAACR0lEQVQ4jW2UzW7lIAyFzVW8BzTZX5DmCZLuU2H2pMXv/ypzbK7aSh2kRCRf /HNsE0q7Sg+RQ7JFKaqtrRNAl5AIIKe6D5DBqgbmUAe5hBI1wIRFAHjeM0RKtZi7XVVEpb0BSNfA IddChChT5DildSLWOWhY5IEItMnncZgFcUAc/5jjwCMsDosRNdfKPDTFEdVBW8C+RebDb4N5Orio RhM1+11IJyx0ng2+LryFHBMPDQDYHrY6IfGuU3ouiXTQNE8LIJDKOWpNxERTFrggQwRPd7USUsTW fJ0XbR3bdj5KgBYy4SACpxDeUYEUAzLmtJ1iIrD2gczPq8Qomjhsh/RjGIgKIO8p7NITjwlx7WID nsnQe5NeuTvoBpi8LX6vLLOh5icjOHqBypgnuSp7M+RE1agbQKHQr5E2z1WObhYW4gMqeGQL7joM jCf2DxSk5ApADSYHfFF4igNfJZL1z0GKP0FN02s4XiDXr7V5P94W6I9v8MfBOQDmfwAaVYt+x8Da v4DJvX8BAdin3Knm5yMZYAO4ABDkDniZLLfi4P40gP1F0TPGZOu0CGwA1lcowxwlGy6A9705mD0V jHCxwVZT/hYdRJVUGZNlx6l7ScQBTluof6Wj6bsPYlvpwoTvXFD9gHPn2TZPF3ntI2ecxVrW5MrV XiCie5EeNa7BlWu/HNSkprDUva163PHxAv5jyGV7gVzyAghSKOTnat85UIYFICXbD2NV9rRiv0BS tKQsg6OHH4A15F1WW+UHKHHa32h6aPnAm3/pUcWp+WYnTQAAAABJRU5ErkJggg== User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64001 Archived-At: --===============0964612136== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Well, this discussion has probably been made a few times, but I can't find a thread. First, some facts: =2D Whitespace cleanup considers 8 (and only 8) spaces to be a tabulation, and discards the fact that `tab-width' could have been changed. =2D On the contrary, `tabify' uses `tab-width'. And this is inconsistent, as I see whitespace-cleanup as a super tabify.delete-trailing-whitespace.do-some-magic function. Second, a =AB mylife =BB part: My company uses =AB tab =BB as indentation char. Not two spaces, not whatever, but tabs. And it looks, well, IMHO, awful. For MY (very own) eyes, I wish I could see tabs as 2 spaces, and this is hopefully possible in the Mighty Editor by setting `tab-width' to 2. Is it completely politically incorrect (or simply wrong) to consider such a patch : --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename=whitespace.patch Content-Transfer-Encoding: quoted-printable Index: lisp/whitespace.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/whitespace.el,v retrieving revision 1.50 diff -c -r1.50 whitespace.el *** lisp/whitespace.el 5 Dec 2006 06:55:48 -0000 1.50 =2D-- lisp/whitespace.el 20 Dec 2006 13:50:35 -0000 *************** *** 32,39 **** ;; ;; 1. Leading space (empty lines at the top of a file). ;; 2. Trailing space (empty lines at the end of a file). ! ;; 3. Indentation space (8 or more spaces at beginning of line, that shou= ld be ! ;; replaced with TABS). ;; 4. Spaces followed by a TAB. (Almost always, we never want that). ;; 5. Spaces or TABS at the end of a line. ;; =2D-- 32,39 ---- ;; ;; 1. Leading space (empty lines at the top of a file). ;; 2. Trailing space (empty lines at the end of a file). ! ;; 3. Indentation space (`tab-width' or more spaces at beginning of ! ;; line, that should be replaced with TABS). ;; 4. Spaces followed by a TAB. (Almost always, we never want that). ;; 5. Spaces or TABS at the end of a line. ;; *************** *** 51,60 **** ;; If any of the whitespace checks is turned off, the modeline will displ= ay a ;; !. ;; ! ;; (since (3) is the most controversial one, here is the rationale: M= ost ! ;; terminal drivers and printer drivers have TAB configured or even ! ;; hardcoded to be 8 spaces. (Some of them allow configuration, but = almost ! ;; always they default to 8.) ;; ;; Changing `tab-width' to other than 8 and editing will cause your c= ode to ;; look different from within Emacs, and say, if you cat it or more i= t, or =2D-- 51,57 ---- ;; If any of the whitespace checks is turned off, the modeline will displ= ay a ;; !. ;; ! ;; (For (3), here is a warning: ;; ;; Changing `tab-width' to other than 8 and editing will cause your c= ode to ;; look different from within Emacs, and say, if you cat it or more i= t, or *************** *** 62,68 **** ;; ;; Almost all the popular programming modes let you define an offset = (like ;; c-basic-offset or perl-indent-level) to configure the offset, so y= ou ! ;; should never have to set your `tab-width' to be other than 8 in all ;; these modes. In fact, with an indent level of say, 4, 2 TABS will= cause ;; Emacs to replace your 8 spaces with one \t (try it). If vi users = in ;; your office complain, tell them to use vim, which distinguishes be= tween =2D-- 59,65 ---- ;; ;; Almost all the popular programming modes let you define an offset = (like ;; c-basic-offset or perl-indent-level) to configure the offset, so y= ou ! ;; probably never have to set your `tab-width' to be other than 8 in = all ;; these modes. In fact, with an indent level of say, 4, 2 TABS will= cause ;; Emacs to replace your 8 spaces with one \t (try it). If vi users = in ;; your office complain, tell them to use vim, which distinguishes be= tween *************** *** 205,213 **** :type 'boolean :group 'whitespace) =20=20 ! (defcustom whitespace-indent-regexp "^\t*\\( \\)+" ! "Regexp to match multiples of eight spaces near line beginnings. ! The default value ignores leading TABs." :type 'regexp :group 'whitespace) =20=20 =2D-- 202,211 ---- :type 'boolean :group 'whitespace) =20=20 ! (defcustom whitespace-indent-regexp "^\t*\\( \\{%d\\}\\)+" ! "Regexp to match multiples of an amount of spaces near line beginnings. ! The default value ignores leading TABs. ! If a `%d' is in the string, it is replaced by the value of `tab-width'." :type 'regexp :group 'whitespace) =20=20 *************** *** 378,384 **** (message "Will%s check for indentation space in buffer." (if whitespace-check-buffer-indent "" " not")) (if whitespace-check-buffer-indent ! (whitespace-buffer-search whitespace-indent-regexp)))) =20=20 ;;;###autoload (defun whitespace-toggle-spacetab-check () =2D-- 376,382 ---- (message "Will%s check for indentation space in buffer." (if whitespace-check-buffer-indent "" " not")) (if whitespace-check-buffer-indent ! (whitespace-buffer-search (whitespace-indent-regexp))))) =20=20 ;;;###autoload (defun whitespace-toggle-spacetab-check () *************** *** 410,416 **** These are: 1. Leading space \(empty lines at the top of a file\). 2. Trailing space \(empty lines at the end of a file\). ! 3. Indentation space \(8 or more spaces, that should be replaced with TAB= S\). 4. Spaces followed by a TAB. \(Almost always, we never want that\). 5. Spaces or TABS at the end of a line. =20=20 =2D-- 408,415 ---- These are: 1. Leading space \(empty lines at the top of a file\). 2. Trailing space \(empty lines at the end of a file\). ! 3. Indentation space \(`tab-width' or more spaces, that should be replaced ! with TABS\). 4. Spaces followed by a TAB. \(Almost always, we never want that\). 5. Spaces or TABS at the end of a line. =20=20 *************** *** 440,446 **** nil)) (whitespace-indent (if whitespace-check-buffer-indent (whitespace-buffer-search ! whitespace-indent-regexp) nil)) (whitespace-spacetab (if whitespace-check-buffer-spacetab (whitespace-buffer-search =2D-- 439,445 ---- nil)) (whitespace-indent (if whitespace-check-buffer-indent (whitespace-buffer-search ! (whitespace-indent-regexp)) nil)) (whitespace-spacetab (if whitespace-check-buffer-spacetab (whitespace-buffer-search *************** *** 531,543 **** ;; If this buffer really contains a file, then run, else quit. (whitespace-check-whitespace-mode current-prefix-arg) (if (and buffer-file-name whitespace-mode) ! (let ((whitespace-any nil) ! (whitespace-tabwith 8) ! (whitespace-tabwith-saved tab-width)) !=20 ! ;; since all printable TABS should be 8, irrespective of how ! ;; they are displayed. ! (setq tab-width whitespace-tabwith) =20=20 (if (and whitespace-check-buffer-leading (whitespace-buffer-leading)) =2D-- 530,536 ---- ;; If this buffer really contains a file, then run, else quit. (whitespace-check-whitespace-mode current-prefix-arg) (if (and buffer-file-name whitespace-mode) ! (let ((whitespace-any nil)) =20=20 (if (and whitespace-check-buffer-leading (whitespace-buffer-leading)) *************** *** 552,558 **** (setq whitespace-any t))) =20=20 (if (and whitespace-check-buffer-indent ! (whitespace-buffer-search whitespace-indent-regexp)) (progn (whitespace-indent-cleanup) (setq whitespace-any t))) =2D-- 545,551 ---- (setq whitespace-any t))) =20=20 (if (and whitespace-check-buffer-indent ! (whitespace-buffer-search (whitespace-indent-regexp))) (progn (whitespace-indent-cleanup) (setq whitespace-any t))) *************** *** 578,585 **** (if region-only (message "The region is now clean") (message "%s is now clean" buffer-file-name))) ! (whitespace-update-modeline))) ! (setq tab-width whitespace-tabwith-saved)))) =20=20 ;;;###autoload (defun whitespace-cleanup-region (s e) =2D-- 571,578 ---- (if region-only (message "The region is now clean") (message "%s is now clean" buffer-file-name))) ! (whitespace-update-modeline)))))) !=20 =20=20 ;;;###autoload (defun whitespace-cleanup-region (s e) *************** *** 647,661 **** (while (re-search-forward regexp nil t) (replace-match newregexp)))) =20=20 (defun whitespace-indent-cleanup () ! "Search for 8/more spaces at the start of a line and replace it with ta= bs." (save-excursion (goto-char (point-min)) ! (while (re-search-forward whitespace-indent-regexp nil t) ! (let ((column (current-column)) ! (indent-tabs-mode t)) ! (delete-region (match-beginning 0) (point)) ! (indent-to column))))) =20=20 (defun whitespace-unchecked-whitespaces () "Return the list of whitespaces whose testing has been suppressed." =2D-- 640,660 ---- (while (re-search-forward regexp nil t) (replace-match newregexp)))) =20=20 + (defun whitespace-indent-regexp () + "Give the actual regexp that matches spaces to be replaced by tabs." + (format whitespace-indent-regexp tab-width)) +=20 (defun whitespace-indent-cleanup () ! "Search for `tab-width'/more spaces at line starts and replace it with = tabs. ! See `whitespace-indent-regexp' for how these spaces are searched." (save-excursion (goto-char (point-min)) ! (let ((indent-regexp (whitespace-indent-regexp))) ! (while (re-search-forward indent-regexp nil t) ! (let ((column (current-column)) ! (indent-tabs-mode t)) ! (delete-region (match-beginning 0) (point)) ! (indent-to column)))))) =20=20 (defun whitespace-unchecked-whitespaces () "Return the list of whitespaces whose testing has been suppressed." Index: lisp/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.10462 diff -C0 -r1.10462 ChangeLog *** lisp/ChangeLog 20 Dec 2006 05:57:40 -0000 1.10462 =2D-- lisp/ChangeLog 20 Dec 2006 13:50:44 -0000 *************** *** 0 **** =2D-- 1,12 ---- + 2006-12-20 Micha=EBl Cadilhac +=20 + * whitespace.el: Change comments to say that `tab-width' is used + instead of 8. + (whitespace-indent-regexp): (Variable) Use a `%d' that will be + replaced by `tab-width'. + (whitespace-indent-regexp): (Function) New. Compute the actual + value of `whitespace-indent-regexp' and return it. + (whitespace-toggle-indent-check, whitespace-buffer) + (whitespace-cleanup-internal, whitespace-indent-cleanup): Use it. + (whitespace-buffer): Doc change. +=20 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable TIA! =2D-=20 /!\ My mail address has changed, please update your files accordingly. | Micha=EBl `Micha' Cadilhac | ... KVim is cited in the talk. = | | Epita/LRDE Promo 2007 | "I can't tell if I am more sorry = | | http://michael.cadilhac.name | for vim or for KDE." = | `--JID: michael.cadilhac@gmail.com--' -- RMS - = --' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFiUSGUJhDmOfFA3URAv8pAJ94wzFlduPLxFMkKV+fLy761qyJMgCcCfgL JOk12jHrV1fULAZj1hbvl9s= =EIwo -----END PGP SIGNATURE----- --==-=-=-- --===============0964612136== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0964612136==--