all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: 47167@debbugs.gnu.org
Subject: bug#47167: Multi-line comment-region with empty comment-continue
Date: Mon, 15 Mar 2021 19:03:22 +0200	[thread overview]
Message-ID: <87a6r4muw5.fsf@mail.linkov.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

Tags: patch

Tried to customize 'comment-region' to use multi-line comments,
so when commenting out such region in html-mode:

line 1
line 2
line 3

instead of adding comments to each line:

<!-- line 1 -->
<!-- line 2 -->
<!-- line 3 -->

to add comments only at the beginning/end:

<!--
line 1
line 2
line 3
  -->

According to the documentation, a legitimate way to do this is
to use such customization:

(setq-local comment-style 'extra-line
            comment-continue "")

But currently it has no effect.  So needed to fix newcomment.el.
One possible fix is to return the original string from 'comment-padright'
even when the string contains only whitespace.  Maybe this would be
the right fix, but still not sure about other calls of 'comment-padright'.
So a safer fix would be to do this in the caller:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: comment-region-padright-continue.patch --]
[-- Type: text/x-diff, Size: 751 bytes --]

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index ea47eec4fd..a5bfb06795 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1300,7 +1300,11 @@ comment-region-default-1
 	 (let ((s (comment-padleft comment-end numarg)))
 	   (and s (if (string-match comment-end-skip s) s
 		    (comment-padright comment-end))))
-	 (if multi (comment-padright comment-continue numarg))
+	 (if multi
+             (or (comment-padright comment-continue numarg)
+                 ;; `comment-padright' returns nil when
+                 ;; `comment-continue' contains only whitespace
+                 (and (stringp comment-continue) comment-continue)))
 	 (if multi
 	     (comment-padleft (comment-string-reverse comment-continue) numarg))
 	 block

             reply	other threads:[~2021-03-15 17:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 17:03 Juri Linkov [this message]
2021-03-15 17:35 ` bug#47167: [External] : bug#47167: Multi-line comment-region with empty comment-continue Drew Adams
2021-03-16 17:47   ` Juri Linkov
2021-03-16 19:24     ` Drew Adams
2021-03-17 17:04       ` Juri Linkov
2021-03-18  5:19 ` Lars Ingebrigtsen
2021-03-18 18:01   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6r4muw5.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=47167@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.