# HG changeset patch # User Glenn Morris # Date 1196227221 0 # Node ID e947df5d708b45c9c0c3da519cb4a4fb3cf45ea2 # Parent d2a6a038b41d90a1d05dbf8638a7513ce4051122 Martin Rudalics (comment-region-internal): Fix newline insertion in `block' case. diff -r d2a6a038b41d -r e947df5d708b lisp/newcomment.el --- a/lisp/newcomment.el Wed Nov 28 05:12:33 2007 +0000 +++ b/lisp/newcomment.el Wed Nov 28 05:20:21 2007 +0000 @@ -969,9 +969,11 @@ the region rather than at left margin." ;;(assert (< beg end)) (let ((no-empty (not (or (eq comment-empty-lines t) - (and comment-empty-lines (zerop (length ce))))))) + (and comment-empty-lines (zerop (length ce)))))) + ce-sanitized) ;; Sanitize CE and CCE. (if (and (stringp ce) (string= "" ce)) (setq ce nil)) + (setq ce-sanitized ce) (if (and (stringp cce) (string= "" cce)) (setq cce nil)) ;; If CE is empty, multiline cannot be used. (unless ce (setq ccs nil cce nil)) @@ -988,7 +990,7 @@ (goto-char end) ;; If the end is not at the end of a line and the comment-end ;; is implicit (i.e. a newline), explicitly insert a newline. - (unless (or ce (eolp)) (insert "\n") (indent-according-to-mode)) + (unless (or ce-sanitized (eolp)) (insert "\n") (indent-according-to-mode)) (comment-with-narrowing beg end (let ((min-indent (point-max)) (max-indent 0))