Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
bb8143d9
Commit
bb8143d9
authored
Jun 21, 1997
by
Karl Heuer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(untabify): Handle consecutive tabs all at once.
(tabify-regexp): New var. (tabify): Use it.
parent
f4ce0bd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
lisp/tabify.el
lisp/tabify.el
+11
-4
No files found.
lisp/tabify.el
View file @
bb8143d9
...
...
@@ -40,13 +40,20 @@ The variable `tab-width' controls the spacing of tab stops."
(
narrow-to-region
(
point-min
)
end
)
(
goto-char
start
)
(
while
(
search-forward
"\t"
nil
t
)
; faster than re-search
(
forward-char
-1
)
(
let
((
tab-beg
(
point
))
(
column
(
current-column
))
(
indent-tabs-mode
nil
))
(
skip-chars-backward
"\t"
start
)
(
indent-tabs-mode
nil
)
column
)
(
skip-chars-forward
"\t"
)
(
setq
column
(
current-column
))
(
delete-region
tab-beg
(
point
))
(
indent-to
column
))))))
(
defvar
tabify-regexp
"[ \t][ \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."
)
;;;###autoload
(
defun
tabify
(
start
end
)
"Convert multiple spaces in region to tabs when possible.
...
...
@@ -64,7 +71,7 @@ The variable `tab-width' controls the spacing of tab stops."
(
beginning-of-line
)
(
narrow-to-region
(
point
)
end
)
(
goto-char
start
)
(
while
(
re-search-forward
"[ \t][ \t][ \t]*"
nil
t
)
(
while
(
re-search-forward
tabify-regexp
nil
t
)
(
let
((
column
(
current-column
))
(
indent-tabs-mode
t
))
(
delete-region
(
match-beginning
0
)
(
point
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment