unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [Proposal] M-x tabify to indent only when needed.
@ 2006-07-24 17:30 Michaël Cadilhac
  2006-07-24 20:40 ` Michaël Cadilhac
  2006-07-24 21:50 ` Richard Stallman
  0 siblings, 2 replies; 15+ messages in thread
From: Michaël Cadilhac @ 2006-07-24 17:30 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 384 bytes --]


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. ».


[-- Attachment #1.1.2: tabify.patch --]
[-- Type: text/x-patch, Size: 1593 bytes --]

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  <michael.cadilhac@lrde.org>
+ 
+ 	* tabify.el (tabify): Check if not already tabified before indenting.
+ 

[-- Attachment #1.1.3: Type: text/plain, Size: 331 bytes --]


TIA!

-- 
 |      Michaël `Micha' Cadilhac   |    Le copillage-collage                |
 |         Epita/LRDE Promo 2007   |       tue le programmeur.              |
 | http://www.lrde.org/~cadilh_m   |           -- Dictons LRDE              |
 `--  -   JID: micha@amessage.be --'                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2006-07-26 11:32 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-24 17:30 [Proposal] M-x tabify to indent only when needed Michaël Cadilhac
2006-07-24 20:40 ` Michaël Cadilhac
2006-07-24 21:30   ` Stefan Monnier
2006-07-25  3:09     ` Richard Stallman
2006-07-25 13:55       ` Stefan Monnier
2006-07-25 14:09         ` Michaël Cadilhac
2006-07-25 15:07           ` Stefan Monnier
2006-07-25 15:28             ` Michaël Cadilhac
2006-07-25 16:21               ` Stefan Monnier
2006-07-25 17:09                 ` Michaël Cadilhac
2006-07-24 21:50 ` Richard Stallman
2006-07-25 11:38   ` Michaël Cadilhac
2006-07-25 22:15     ` Richard Stallman
2006-07-26 11:29       ` Michaël Cadilhac
2006-07-26 11:32         ` Michaël Cadilhac

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).