aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/tabify.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/tabify.el')
-rw-r--r--lisp/tabify.el28
1 files changed, 15 insertions, 13 deletions
diff --git a/lisp/tabify.el b/lisp/tabify.el
index da1038a2164..0b2411d0316 100644
--- a/lisp/tabify.el
+++ b/lisp/tabify.el
@@ -34,19 +34,21 @@ Called non-interactively, the region is specified by arguments
34START and END, rather than by the position of point and mark. 34START and END, rather than by the position of point and mark.
35The variable `tab-width' controls the spacing of tab stops." 35The variable `tab-width' controls the spacing of tab stops."
36 (interactive "r") 36 (interactive "r")
37 (save-excursion 37 (let ((c (current-column)))
38 (save-restriction 38 (save-excursion
39 (narrow-to-region (point-min) end) 39 (save-restriction
40 (goto-char start) 40 (narrow-to-region (point-min) end)
41 (while (search-forward "\t" nil t) ; faster than re-search 41 (goto-char start)
42 (forward-char -1) 42 (while (search-forward "\t" nil t) ; faster than re-search
43 (let ((tab-beg (point)) 43 (forward-char -1)
44 (indent-tabs-mode nil) 44 (let ((tab-beg (point))
45 column) 45 (indent-tabs-mode nil)
46 (skip-chars-forward "\t") 46 column)
47 (setq column (current-column)) 47 (skip-chars-forward "\t")
48 (delete-region tab-beg (point)) 48 (setq column (current-column))
49 (indent-to column)))))) 49 (delete-region tab-beg (point))
50 (indent-to column)))))
51 (move-to-column c)))
50 52
51(defvar tabify-regexp " [ \t]+" 53(defvar tabify-regexp " [ \t]+"
52 "Regexp matching whitespace that tabify should consider. 54 "Regexp matching whitespace that tabify should consider.