1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

(move-to-tab-stop): Delete unnecessary spaces

before the old point if a tab followed or follows the old point.
This commit is contained in:
Richard M. Stallman 1994-06-23 23:57:33 +00:00
parent 0b6ac15043
commit fbf8f564cf

View 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)