From 7be272f43c5e7d8fbfb47e8e1a7ce49d83a94ff2 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Fri, 8 Jan 1999 04:29:20 +0000 Subject: [PATCH] (comment-region): Delete spaces only if we deleted a comment starter. --- lisp/simple.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index ce6f31d1fff..c0be05d9e18 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2804,18 +2804,21 @@ not end the comment. Blank lines do not get comments." (goto-char beg) (if (or (eq numarg t) (< numarg 0)) (while (not (eobp)) - (progn + (let (found-comment) ;; Delete comment start from beginning of line. (if (eq numarg t) (while (looking-at (regexp-quote cs)) + (setq found-comment t) (delete-char (length cs))) (let ((count numarg)) (while (and (> 1 (setq count (1+ count))) (looking-at (regexp-quote cs))) + (setq found-comment t) (delete-char (length cs))))) ;; Delete comment padding from beginning of line - (when (and comment-padding (looking-at (regexp-quote cp))) - (delete-char comment-padding)) + (when (and found-comment comment-padding + (looking-at (regexp-quote cp))) + (delete-char comment-padding)) ;; Delete comment end from end of line. (if (string= "" ce) nil -- 2.39.2