Skip to content

Commit a8d17f3

Browse files
author
Alan Mackenzie
committed
Make uncomment-region remove obtrusive spaces before tabs.
These spaces were typically inserted earlier by comment-region. This patch makes these two complementary functions closer to inverses. * lisp/newcomment.el (uncomment-region-default-1): Remove spaces before a tab where the comment opener has just been removed.
1 parent eda8ea6 commit a8d17f3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lisp/newcomment.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,15 @@ This function is the default value of `uncomment-region-function'."
10011001
(re-search-forward sre (line-end-position) t))
10021002
(replace-match "" t t nil (if (match-end 2) 2 1)))))
10031003
;; Go to the end for the next comment.
1004-
(goto-char (point-max))))))
1004+
(goto-char (point-max)))
1005+
;; Remove any obtrusive spaces left preceding a tab at `spt'.
1006+
(when (and (eq (char-after spt) ?\t) (eq (char-before spt) ? )
1007+
(> tab-width 0))
1008+
(save-excursion
1009+
(goto-char spt)
1010+
(let* ((fcol (current-column))
1011+
(slim (- (point) (mod fcol tab-width))))
1012+
(delete-char (- (skip-chars-backward " " slim)))))))))
10051013
(set-marker end nil))
10061014

10071015
(defun uncomment-region-default (beg end &optional arg)

0 commit comments

Comments
 (0)