summaryrefslogtreecommitdiff
path: root/lisp/indent.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-06-23 23:57:33 +0000
committerRichard M. Stallman <rms@gnu.org>1994-06-23 23:57:33 +0000
commita1d0da069911aa3b0ca5212f3eaac8f476ad8467 (patch)
tree4fc6c2cfef48fbcf9189a4f8bfe08f54504cdc82 /lisp/indent.el
parent1bb2f9f3c01db936327c2695a10b28fa8deb52a3 (diff)
downloademacs-a1d0da069911aa3b0ca5212f3eaac8f476ad8467.tar.gz
(move-to-tab-stop): Delete unnecessary spaces
before the old point if a tab followed or follows the old point.
Diffstat (limited to 'lisp/indent.el')
-rw-r--r--lisp/indent.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/indent.el b/lisp/indent.el
index 2713be3b51f..ef63db81932 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -260,6 +260,29 @@ Use \\[edit-tab-stops] to edit them interactively."
(delete-region (point) opoint)))
(move-to-column (car tabs) t)))))
+(defun move-to-tab-stop ()
+ "Move point to next defined tab-stop column.
+The variable `tab-stop-list' is a list of columns at which there are tab stops.
+Use \\[edit-tab-stops] to edit them interactively."
+ (interactive)
+ (let ((tabs tab-stop-list))
+ (while (and tabs (>= (current-column) (car tabs)))
+ (setq tabs (cdr tabs)))
+ (if tabs
+ (let ((before (point)))
+ (move-to-column (car tabs) t)
+ (save-excursion
+ (goto-char before)
+ ;; If we just added a tab, or moved over one,
+ ;; delete any superfluous spaces before the old point.
+ (if (and (eq (preceding-char) ?\ )
+ (eq (following-char) ?\t))
+ (let ((tabend (* (/ (current-column) tab-width) tab-width)))
+ (while (and (> (current-column) tabend)
+ (eq (preceding-char) ?\ ))
+ (forward-char -1))
+ (delete-region (point) before))))))))
+
(define-key global-map "\t" 'indent-for-tab-command)
(define-key esc-map "\034" 'indent-region)
(define-key ctl-x-map "\t" 'indent-rigidly)