emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master a8d17f3: Make uncomment-region remove obtrusive spa


From: Alan Mackenzie
Subject: [Emacs-diffs] master a8d17f3: Make uncomment-region remove obtrusive spaces before tabs.
Date: Fri, 10 May 2019 03:31:33 -0400 (EDT)

branch: master
commit a8d17f35a29d9875e94e28c8405d350b57fd1e80
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    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.
---
 lisp/newcomment.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 9d919cc..ab2be08 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1001,7 +1001,15 @@ This function is the default value of 
`uncomment-region-function'."
                       (re-search-forward sre (line-end-position) t))
                (replace-match "" t t nil (if (match-end 2) 2 1)))))
          ;; Go to the end for the next comment.
-         (goto-char (point-max))))))
+         (goto-char (point-max)))
+        ;; Remove any obtrusive spaces left preceding a tab at `spt'.
+        (when (and (eq (char-after spt) ?\t) (eq (char-before spt) ? )
+                   (> tab-width 0))
+          (save-excursion
+            (goto-char spt)
+            (let* ((fcol (current-column))
+                   (slim (- (point) (mod fcol tab-width))))
+              (delete-char (- (skip-chars-backward " " slim)))))))))
   (set-marker end nil))
 
 (defun uncomment-region-default (beg end &optional arg)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]