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: Tue, 28 Mar 2017 14:52:21 +0200 Message-ID: <7171.1490705541@localhost> References: <29145.1489153275@localhost> <87r31i2i5a.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1490705596 5206 195.159.176.226 (28 Mar 2017 12:53:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 28 Mar 2017 12:53:16 +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 Tue Mar 28 14:53:11 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 1csqcW-0000e6-NJ for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Mar 2017 14:53:08 +0200 Original-Received: from localhost ([::1]:53149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csqcc-00047c-Db for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Mar 2017 08:53:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csqcT-00046t-UD for bug-gnu-emacs@gnu.org; Tue, 28 Mar 2017 08:53:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csqcP-00037d-U0 for bug-gnu-emacs@gnu.org; Tue, 28 Mar 2017 08:53:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csqcP-00037Y-Pn for bug-gnu-emacs@gnu.org; Tue, 28 Mar 2017 08:53:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1csqcP-0005tC-JM for bug-gnu-emacs@gnu.org; Tue, 28 Mar 2017 08:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Antonin Houska Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 28 Mar 2017 12:53: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: Original-Received: via spool by 26049-submit@debbugs.gnu.org id=B26049.149070555422602 (code B ref 26049); Tue, 28 Mar 2017 12:53:01 +0000 Original-Received: (at 26049) by debbugs.gnu.org; 28 Mar 2017 12:52:34 +0000 Original-Received: from localhost ([127.0.0.1]:48642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csqbx-0005sU-Qf for submit@debbugs.gnu.org; Tue, 28 Mar 2017 08:52:34 -0400 Original-Received: from mx1.mailbox.org ([80.241.60.212]:36526) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csqbw-0005sH-Kv for 26049@debbugs.gnu.org; Tue, 28 Mar 2017 08:52:33 -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 892AA45521; Tue, 28 Mar 2017 14:52:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id Jpyz9KQxlJfH; Tue, 28 Mar 2017 14:52:22 +0200 (CEST) In-reply-to: <87r31i2i5a.fsf@users.sourceforge.net> Comments: In-reply-to npostavs@users.sourceforge.net message dated "Mon, 27 Mar 2017 23:29:37 -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:131033 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable npostavs@users.sourceforge.net wrote: > Antonin Houska writes: > > Even though I have the following customizations in place > > > > '(comment-multi-line t) > > '(comment-style (quote extra-line)) > > > > comment-region command produces this > > > > /* some comment */ > > > > rather than this > > > > /* > > * some comment > > */ > > > > Attached is a patch that I use to fix the issue on my workstation. Besi= des > > fixing the (supposed) off-by-one error, the patch also removes trailing > > whitespace from the initial line of the comment ("/* "). (My knowledge = of > > Elisp is not too advanced so I wonder if there's simpler way to trim > > whitespace from a string.) > > > You can use use `string-trim-right' from subr-x. Thanks. > > (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) (point-max= )) t))))) > Maybe (re-search-forward "$" end t) is better? It's a bit unclear to me > what exactly all those tests are looking for. That code could use some > comments... I've just verified your approach - it does work too. Yes, comments would be useful. For the test we're fixing now, the reason se= ems to be to ensure that the last line of the comment can be broken w/o affecti= ng the following (non-comment) text. Perhaps someone else might come up with better wording. New version of the patch is attached. --=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_v2.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 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)) --=-=-=--