From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Antonin Houska Newsgroups: gmane.emacs.bugs Subject: bug#26049: 25.2; Extra lines not added to comment Date: Mon, 06 Nov 2017 11:14:22 +0100 Message-ID: <7456.1509963262@localhost> References: <29145.1489153275@localhost> <87r31i2i5a.fsf@users.sourceforge.net> <7171.1490705541@localhost> <87h92c3jl8.fsf@users.sourceforge.net> <20705.1490770493@localhost> <17405.1506152497@localhost> <877ewpo50c.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1509963314 15367 195.159.176.226 (6 Nov 2017 10:15:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Nov 2017 10:15:14 +0000 (UTC) Cc: 26049@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 06 11:15:06 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBeQr-0003an-QC for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Nov 2017 11:15:06 +0100 Original-Received: from localhost ([::1]:47325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBeQx-0001rp-I8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Nov 2017 05:15:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBeQr-0001rS-U3 for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 05:15:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBeQo-0001ac-AV for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 05:15:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44323) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBeQo-0001aV-6s for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 05:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eBeQn-0006Iz-US for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 05:15:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Antonin Houska Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Nov 2017 10:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26049 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 26049-submit@debbugs.gnu.org id=B26049.150996324324148 (code B ref 26049); Mon, 06 Nov 2017 10:15:01 +0000 Original-Received: (at 26049) by debbugs.gnu.org; 6 Nov 2017 10:14:03 +0000 Original-Received: from localhost ([127.0.0.1]:53004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBePr-0006HQ-9e for submit@debbugs.gnu.org; Mon, 06 Nov 2017 05:14:03 -0500 Original-Received: from mx2.mailbox.org ([80.241.60.215]:43458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBePo-0006Gl-GC for 26049@debbugs.gnu.org; Mon, 06 Nov 2017 05:14:01 -0500 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 274654CA19; Mon, 6 Nov 2017 11:13:52 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id OF3d4Vj0O8II; Mon, 6 Nov 2017 11:13:50 +0100 (CET) In-reply-to: <877ewpo50c.fsf@users.sourceforge.net> Comments: In-reply-to Noam Postavsky message dated "Sat, 23 Sep 2017 10:37:23 -0400." X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:139497 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Noam Postavsky wrote: > tags 26049 + patch > quit >=20 > Antonin Houska writes: >=20 > > The next version of the patch (with string-trim replaced with > > string-trim-right) is below. Is there anything else I should do? >=20 > Could you please add a commit message (see CONTRIBUTE under "Commit > messages" for conventions) and post a version produced via 'git > format-patch' (that way I can grab the patch + commit message > automagically). See below. --=20 Antonin Houska Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH Gr=C3=B6hrm=C3=BChlgasse 26 A-2700 Wiener Neustadt Web: http://www.postgresql-support.de, http://www.cybertec.at --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Handle-single-line-comments-correctly-Bug-26049.patch >From e782404ce76c05076b794e9506049d7ed4c55663 Mon Sep 17 00:00:00 2001 From: Antonin Houska Date: Mon, 6 Nov 2017 09:59:07 +0100 Subject: [PATCH] Handle single-line comments correctly (Bug#26049) * lisp/newcomment.el: the comment text had to contain at least one line break for the ending extra line to be added. The behavior seems more consistent if the end of the comment text is also considered a line break. While fixing this, also removed trailing white space from the comment 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 2e644c3a99..950f3c85b4 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 @@ comment-region-internal ;; 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 @@ comment-region-default (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)) -- 2.12.3 --=-=-=--