emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 db94916: Handle single-line comments correctly (B


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 db94916: Handle single-line comments correctly (Bug#26049)
Date: Mon, 6 Nov 2017 19:04:51 -0500 (EST)

branch: emacs-26
commit db949166ecb9aeaa15aa41369a55b3ea6ceaa3b0
Author: Antonin Houska <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Handle single-line comments correctly (Bug#26049)
    
    * 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
---
 lisp/newcomment.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 2a0f8a8..66296b8 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -69,6 +69,9 @@
 
 ;;; Code:
 
+(eval-when-compile
+  (require 'subr-x))
+
 ;;;###autoload
 (defalias 'indent-for-comment 'comment-indent)
 ;;;###autoload
@@ -1141,6 +1144,9 @@ the region rather than at left margin."
 
          ;; 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)))
@@ -1211,7 +1217,7 @@ changed with `comment-style'."
           (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))



reply via email to

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