[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Proposal] M-x tabify to indent only when needed.
From: |
Michaël Cadilhac |
Subject: |
[Proposal] M-x tabify to indent only when needed. |
Date: |
Mon, 24 Jul 2006 19:30:31 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) |
M-x tabify has an unexpected behavior with files that are already
tabified: once it is called, the file is set to be modified. In fact,
the regions of spaces are removed and then re-added.
Can the following patch be applied to change this behavior?
It checks that the region we are going to delete is not already of the
form « tabs then spaces less than a tab. ».
Index: lisp/tabify.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/tabify.el,v
retrieving revision 1.19
diff -c -r1.19 tabify.el
*** lisp/tabify.el 6 Feb 2006 14:33:35 -0000 1.19
--- lisp/tabify.el 24 Jul 2006 17:21:48 -0000
***************
*** 75,82 ****
(while (re-search-forward tabify-regexp nil t)
(let ((column (current-column))
(indent-tabs-mode t))
! (delete-region (match-beginning 0) (point))
! (indent-to column))))))
(provide 'tabify)
--- 75,90 ----
(while (re-search-forward tabify-regexp nil t)
(let ((column (current-column))
(indent-tabs-mode t))
! ;; Whether already tabified.
! (unless (save-match-data
! (save-excursion
! (goto-char (match-beginning 0))
! (string-match
! (format "^\t* \\{0,%d\\}$"
! (- tab-width (1+ (mod (current-column)
tab-width))))
! (match-string 0))))
! (delete-region (match-beginning 0) (point))
! (indent-to column)))))))
(provide 'tabify)
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.9820
diff -c -r1.9820 ChangeLog
*** lisp/ChangeLog 17 Jul 2006 04:07:48 -0000 1.9820
--- lisp/ChangeLog 24 Jul 2006 17:21:50 -0000
***************
*** 1,0 ****
--- 1,4 ----
+ 2006-07-24 Michaël Cadilhac <address@hidden>
+
+ * tabify.el (tabify): Check if not already tabified before indenting.
+
TIA!
--
| Michaël `Micha' Cadilhac | Le copillage-collage |
| Epita/LRDE Promo 2007 | tue le programmeur. |
| http://www.lrde.org/~cadilh_m | -- Dictons LRDE |
`-- - JID: address@hidden --' - --'
pgpLbsslGhXQB.pgp
Description: PGP signature
- [Proposal] M-x tabify to indent only when needed.,
Michaël Cadilhac <=
- Re: [Proposal] M-x tabify to indent only when needed., Michaël Cadilhac, 2006/07/24
- Re: [Proposal] M-x tabify to indent only when needed., Stefan Monnier, 2006/07/24
- Re: [Proposal] M-x tabify to indent only when needed., Richard Stallman, 2006/07/24
- Re: [Proposal] M-x tabify to indent only when needed., Stefan Monnier, 2006/07/25
- Re: [Proposal] M-x tabify to indent only when needed., Michaël Cadilhac, 2006/07/25
- Re: [Proposal] M-x tabify to indent only when needed., Stefan Monnier, 2006/07/25
- Re: [Proposal] M-x tabify to indent only when needed., Michaël Cadilhac, 2006/07/25
- Re: [Proposal] M-x tabify to indent only when needed., Stefan Monnier, 2006/07/25
- Re: [Proposal] M-x tabify to indent only when needed., Michaël Cadilhac, 2006/07/25
Re: [Proposal] M-x tabify to indent only when needed., Richard Stallman, 2006/07/24