unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47167: Multi-line comment-region with empty comment-continue
@ 2021-03-15 17:03 Juri Linkov
  2021-03-15 17:35 ` bug#47167: [External] : " Drew Adams
  2021-03-18  5:19 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: Juri Linkov @ 2021-03-15 17:03 UTC (permalink / raw)
  To: 47167

[-- 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-18 18:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-15 17:03 bug#47167: Multi-line comment-region with empty comment-continue Juri Linkov
2021-03-15 17:35 ` bug#47167: [External] : " 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).