changeset 8037:fd5fb80a940d

(move-to-tab-stop): Delete unnecessary spaces before the old point if a tab followed or follows the old point.
author Richard M. Stallman <rms@gnu.org>
date Thu, 23 Jun 1994 23:57:33 +0000
parents e242731ffc05
children bffab6b07862
files lisp/indent.el
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/indent.el	Thu Jun 23 23:56:06 1994 +0000
+++ b/lisp/indent.el	Thu Jun 23 23:57:33 1994 +0000
@@ -260,6 +260,29 @@
 		(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)