]> git.eshelyaron.com Git - emacs.git/commitdiff
(move-to-tab-stop): Delete unnecessary spaces
authorRichard M. Stallman <rms@gnu.org>
Thu, 23 Jun 1994 23:57:33 +0000 (23:57 +0000)
committerRichard M. Stallman <rms@gnu.org>
Thu, 23 Jun 1994 23:57:33 +0000 (23:57 +0000)
before the old point if a tab followed or follows the old point.

lisp/indent.el

index 2713be3b51f9b0c194961f4431d3b00c54464491..ef63db81932c5bc9da64dc758651efcb2e6301c9 100644 (file)
@@ -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)