[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/tabify.el,v
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/tabify.el,v |
Date: |
Tue, 25 Jul 2006 18:05:57 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 06/07/25 18:05:54
Index: tabify.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/tabify.el,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- tabify.el 6 Feb 2006 14:33:35 -0000 1.19
+++ tabify.el 25 Jul 2006 18:05:54 -0000 1.20
@@ -50,10 +50,10 @@
(delete-region tab-beg (point))
(indent-to column))))))
-(defvar tabify-regexp "[ \t][ \t]+"
+(defvar tabify-regexp " [ \t]+"
"Regexp matching whitespace that tabify should consider.
-Usually this will be \"[ \\t][ \\t]+\" to match two or more spaces or tabs.
-\"^[ \\t]+\" is also useful, for tabifying only initial whitespace.")
+Usually this will be \" [ \\t]+\" to match two or more spaces or tabs.
+\"^\\t* [ \\t]+\" is also useful, for tabifying only initial whitespace.")
;;;###autoload
(defun tabify (start end)
@@ -72,13 +72,24 @@
(beginning-of-line)
(narrow-to-region (point) end)
(goto-char start)
+ (let ((indent-tabs-mode t))
(while (re-search-forward tabify-regexp nil t)
- (let ((column (current-column))
- (indent-tabs-mode t))
+ ;; The region between (match-beginning 0) and (match-end 0) is just
+ ;; spacing which we want to adjust to use TABs where possible.
+ (let ((end-col (current-column))
+ (beg-col (save-excursion (goto-char (match-beginning 0))
+ (skip-chars-forward "\t")
+ (current-column))))
+ (if (= (/ end-col tab-width) (/ beg-col tab-width))
+ ;; The spacing (after some leading TABs which we wouldn't
+ ;; want to touch anyway) does not straddle a TAB boundary,
+ ;; so it neither contains a TAB, nor will we be able to use
+ ;; a TAB here anyway: there's nothing to do.
+ nil
(delete-region (match-beginning 0) (point))
- (indent-to column))))))
+ (indent-to end-col))))))))
(provide 'tabify)
-;;; arch-tag: c83893b1-e0cc-4e57-8a09-73fd03466416
+;; arch-tag: c83893b1-e0cc-4e57-8a09-73fd03466416
;;; tabify.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/tabify.el,v,
Stefan Monnier <=