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: Sat, 23 Sep 2017 09:41:37 +0200 Message-ID: <17405.1506152497@localhost> References: <29145.1489153275@localhost> <87r31i2i5a.fsf@users.sourceforge.net> <7171.1490705541@localhost> <87h92c3jl8.fsf@users.sourceforge.net> <20705.1490770493@localhost> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1506152570 8946 195.159.176.226 (23 Sep 2017 07:42:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 23 Sep 2017 07:42:50 +0000 (UTC) Cc: 26049@debbugs.gnu.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 23 09:42:43 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 1dvf5F-0001pO-Th for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Sep 2017 09:42:42 +0200 Original-Received: from localhost ([::1]:34030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvf5N-0000Sy-8f for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Sep 2017 03:42:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvf4f-00004s-OB for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2017 03:42:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvf4c-0004dd-Jz for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2017 03:42:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44785) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvf4c-0004dV-Fk for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2017 03:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dvf4c-0006li-3e for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2017 03:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Antonin Houska Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Sep 2017 07:42:02 +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: Original-Received: via spool by 26049-submit@debbugs.gnu.org id=B26049.150615250025988 (code B ref 26049); Sat, 23 Sep 2017 07:42:02 +0000 Original-Received: (at 26049) by debbugs.gnu.org; 23 Sep 2017 07:41:40 +0000 Original-Received: from localhost ([127.0.0.1]:53466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvf4G-0006l4-Co for submit@debbugs.gnu.org; Sat, 23 Sep 2017 03:41:40 -0400 Original-Received: from mx1.mailbox.org ([80.241.60.212]:52930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvf4E-0006kp-44 for 26049@debbugs.gnu.org; Sat, 23 Sep 2017 03:41:38 -0400 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 mx1.mailbox.org (Postfix) with ESMTPS id D8F2B45CEB; Sat, 23 Sep 2017 09:41:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id wTByNH8fd4Ep; Sat, 23 Sep 2017 09:41:17 +0200 (CEST) In-reply-to: <20705.1490770493@localhost> Comments: In-reply-to Antonin Houska message dated "Wed, 29 Mar 2017 08:54:53 +0200." 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:137262 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Antonin Houska wrote: > npostavs@users.sourceforge.net wrote: >=20 > > Antonin Houska writes: > > > > > >> > (progn (goto-char end) (end-of-line) (skip-syntax-backward "= ") > > >> > (<=3D (point) end)) > > >> > (or block (not (string=3D "" comment-end))) > > >> > ! (or block (progn (goto-char beg) (search-forward > > >> > ! "\n" > > >> > ! (min (1+ end) (poin= t-max)) t))))) > > > > > >> Maybe (re-search-forward "$" end t) is better? It's a bit unclear t= o me > > >> what exactly all those tests are looking for. That code could use s= ome > > >> comments... > > > > > > I've just verified your approach - it does work too. >=20 > > "$" also matches at the end of buffer even if it doesn't end in newline > > (which is a very marginal corner case, I just happened to notice it > > because I didn't hit RET in my test buffer). >=20 > IMO this is ok. If the 'extra-line value of `comment-style' tells that the > comment should look like this >=20 > /* > * some comment > */ >=20 > it'd be kind of inconsistend if just a missing RET at the end of buffer > resulted in this >=20 > /* some comment */ >=20 > which effectively means discrepancy from the customization setting. >=20 > (The initial version of my patch ignored the `extra-line' setting in this > special case, but it was a thinko rather than intention.) >=20 > >=20 > > > + ;; Trim trailing whitespace from cs if there's some. > > > + (setq cs (string-trim cs)) > >=20 > > This would trim leading whitespace too, do we want that? >=20 > I haven't noticed any related issue but yes, string-trim-right is more > precise. If the (supposedly accidental) leading space should be removed f= rom > the value of `comment-start', it should probably happen elsewhere in the = code > because it's not specific to the 'extra-line style. The next version of the patch (with string-trim replaced with string-trim-right) is below. Is there anything else I should do? --=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=newcomment.diff diff --git a/lisp/newcomment.el b/lisp/newcomment.el new file mode 100644 index 1af8929..f2d9735 *** a/lisp/newcomment.el --- b/lisp/newcomment.el *************** *** 69,74 **** --- 69,77 ---- ;;; Code: + (eval-when-compile + (require 'subr-x)) + ;;;###autoload (defalias 'indent-for-comment 'comment-indent) ;;;###autoload *************** the region rather than at left margin." *** 1139,1144 **** --- 1142,1150 ---- ;; 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))) *************** changed with `comment-style'." *** 1209,1215 **** (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))))) ;; don't add end-markers just because the user asked for `block' (unless (or lines (string= "" comment-end)) (setq block nil)) --- 1215,1221 ---- (progn (goto-char end) (end-of-line) (skip-syntax-backward " ") (<= (point) end)) (or block (not (string= "" comment-end))) ! (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)) --=-=-=--