diff options
author | Juanma Barranquero <lekktu@gmail.com> | 2011-07-13 20:12:05 +0200 |
---|---|---|
committer | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2011-07-13 20:12:05 +0200 |
commit | febee3d609d559a1677f48886454a1d304f6b7b4 (patch) | |
tree | 464b88775ddbffab3e59791b7f2a92b7b1248863 /lisp/tabify.el | |
parent | 8b6a2f35774bcbb469ddd96275479085b4f82e4f (diff) | |
download | emacs-febee3d609d559a1677f48886454a1d304f6b7b4.tar.gz |
Preserve point when doing untabify
* tabify.el (untabify): Preserve the current column so that point
doesn't move.
Diffstat (limited to 'lisp/tabify.el')
-rw-r--r-- | lisp/tabify.el | 28 |
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 START and END, rather than by the position of point and mark. The variable `tab-width' controls the spacing of tab stops." (interactive "r") - (save-excursion - (save-restriction - (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)) - (indent-tabs-mode nil) - column) - (skip-chars-forward "\t") - (setq column (current-column)) - (delete-region tab-beg (point)) - (indent-to column)))))) + (let ((c (current-column))) + (save-excursion + (save-restriction + (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)) + (indent-tabs-mode nil) + column) + (skip-chars-forward "\t") + (setq column (current-column)) + (delete-region tab-beg (point)) + (indent-to column))))) + (move-to-column c))) (defvar tabify-regexp " [ \t]+" "Regexp matching whitespace that tabify should consider. |