Mercurial > emacs
annotate lisp/tabify.el @ 705:c7d478752305
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 10 Jun 1992 01:34:51 +0000 |
parents | 7cbd4fcd8b0f |
children | 1ca26ccad38e |
rev | line source |
---|---|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
1 ;;; tabify.el --- tab conversion commands for Emacs |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
2 |
36 | 3 ;; Copyright (C) 1985 Free Software Foundation, Inc. |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 1, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | |
21 | |
258 | 22 ;;;###autoload |
36 | 23 (defun untabify (start end) |
24 "Convert all tabs in region to multiple spaces, preserving columns. | |
25 The variable tab-width controls the action." | |
26 (interactive "r") | |
27 (save-excursion | |
28 (save-restriction | |
29 (narrow-to-region start end) | |
30 (goto-char start) | |
31 (while (search-forward "\t" nil t) ; faster than re-search | |
32 (let ((start (point)) | |
33 (column (current-column)) | |
34 (indent-tabs-mode nil)) | |
35 (skip-chars-backward "\t") | |
36 (delete-region start (point)) | |
37 (indent-to column)))))) | |
38 | |
258 | 39 ;;;###autoload |
36 | 40 (defun tabify (start end) |
41 "Convert multiple spaces in region to tabs when possible. | |
42 A group of spaces is partially replaced by tabs | |
43 when this can be done without changing the column they end at. | |
44 The variable tab-width controls the action." | |
45 (interactive "r") | |
46 (save-excursion | |
47 (save-restriction | |
48 (narrow-to-region start end) | |
49 (goto-char start) | |
50 (while (re-search-forward "[ \t][ \t][ \t]*" nil t) | |
51 (let ((column (current-column)) | |
52 (indent-tabs-mode t)) | |
53 (delete-region (match-beginning 0) (point)) | |
54 (indent-to column)))))) | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
55 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
56 ;;; tabify.el ends here |