* lisp/newcomment.el (comment-region-internal): Previously, the
comment text had to contain at least one line break character for the
ending extra line to be added. Make the behavior more consistent by
looking for end of line instead.
(comment-region-internal): Remove trailing white space from the
comment's initial line.
Copyright-paperwork-exempt: yes
;;; Code:
+(eval-when-compile
+ (require 'subr-x))
+
;;;###autoload
(defalias 'indent-for-comment 'comment-indent)
;;;###autoload
;; make the leading and trailing lines if requested
(when lines
+ ;; Trim trailing whitespace from cs if there's some.
+ (setq cs (string-trim-right cs))
+
(let ((csce
(comment-make-extra-lines
cs ce ccs cce min-indent max-indent block)))
(progn (goto-char end) (end-of-line) (skip-syntax-backward " ")
(<= (point) end))
(or block (not (string= "" comment-end)))
- (or block (progn (goto-char beg) (search-forward "\n" end t)))))
+ (or block (progn (goto-char beg) (re-search-forward "$" end t)))))
;; don't add end-markers just because the user asked for `block'
(unless (or lines (string= "" comment-end)) (setq block nil))