aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2019-05-10 07:28:54 +0000
committerAlan Mackenzie2019-05-10 07:28:54 +0000
commita8d17f35a29d9875e94e28c8405d350b57fd1e80 (patch)
treea98b6eccb273b79325ffc6b653c3b70412bf5ace
parenteda8ea685802e4e07e28351f65b5e24661a384fe (diff)
downloademacs-a8d17f35a29d9875e94e28c8405d350b57fd1e80.tar.gz
emacs-a8d17f35a29d9875e94e28c8405d350b57fd1e80.zip
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.
-rw-r--r--lisp/newcomment.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 9d919ccbbea..ab2be080a33 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1001,7 +1001,15 @@ This function is the default value of `uncomment-region-function'."
1001 (re-search-forward sre (line-end-position) t)) 1001 (re-search-forward sre (line-end-position) t))
1002 (replace-match "" t t nil (if (match-end 2) 2 1))))) 1002 (replace-match "" t t nil (if (match-end 2) 2 1)))))
1003 ;; Go to the end for the next comment. 1003 ;; 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)))))))))
1005 (set-marker end nil)) 1013 (set-marker end nil))
1006 1014
1007(defun uncomment-region-default (beg end &optional arg) 1015(defun uncomment-region-default (beg end &optional arg)