https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2017-04-28T02:58:59Z
Ruby Issue Tracking System
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=64523
2017-04-28T02:58:59Z
tscheingeld (Terry Scheingeld)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/64523/diff?detail_id=44859">diff</a>)</li></ul>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=64564
2017-04-28T18:58:29Z
shevegen (Robert A. Heiler)
shevegen@gmail.com
<ul></ul><p>I have no particular pro or con opinion here (I do not use =begin or =end anyway,<br>
only '#') but would this even be possible?</p>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=64569
2017-04-29T05:39:04Z
nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org
<ul></ul><p>Possible of course, but I'm not a big fan of this.</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git i/misc/ruby-mode.el w/misc/ruby-mode.el
index b1abd18a9e..5e8a6a1646 100644
</span><span class="gd">--- i/misc/ruby-mode.el
</span><span class="gi">+++ w/misc/ruby-mode.el
</span><span class="p">@@ -135,7 +135,7 @@</span>
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\_<\\("
ruby-block-beg-re
"\\)\\_>\\|" ruby-block-end-re
<span class="gd">- "\\|^=begin\\|" ruby-here-doc-beg-re)
</span><span class="gi">+ "\\|^[ \t]*=begin\\|" ruby-here-doc-beg-re)
</span> )
(defconst ruby-negative
<span class="p">@@ -671,8 +671,8 @@</span> Emacs to Ruby."
(looking-at "\\.[a-zA-Z_0-9]+")
(looking-at "\\."))
(goto-char (match-end 0)))
<span class="gd">- ((looking-at "^=begin")
- (if (re-search-forward "^=end" end t)
</span><span class="gi">+ ((looking-at "^[ \t]*=begin")
+ (if (re-search-forward "^[ \t]*=end" end t)
</span> (forward-line 1)
(setq in-string (match-end 0))
(goto-char end)))
<span class="p">@@ -954,10 +954,10 @@</span> An end of a defun is found by moving forward from the beginning of one."
(cond
((looking-at "^\\s *$"))
((looking-at "^\\s *#"))
<span class="gd">- ((and (> n 0) (looking-at "^=begin\\>"))
- (re-search-forward "^=end\\>"))
- ((and (< n 0) (looking-at "^=end\\>"))
- (re-search-backward "^=begin\\>"))
</span><span class="gi">+ ((and (> n 0) (looking-at "^[ \t]*=begin\\>"))
+ (re-search-forward "^[ \t]*=end\\>"))
+ ((and (< n 0) (looking-at "^[ \t]*=end\\>"))
+ (re-search-backward "^[ \t]*=begin\\>"))
</span> (t
(setq pos (current-indentation))
(cond
<span class="p">@@ -1410,12 +1410,12 @@</span> buffer position `limit' or the end of the buffer."
. ruby-font-lock-syntactic-keywords))))
(defun ruby-font-lock-docs (limit)
<span class="gd">- (if (re-search-forward "^=begin\\(\\s \\|$\\)" limit t)
</span><span class="gi">+ (if (re-search-forward "^[ \t]*=begin\\(\\s \\|$\\)" limit t)
</span> (let (beg)
(beginning-of-line)
(setq beg (point))
(forward-line 1)
<span class="gd">- (if (re-search-forward "^=end\\(\\s \\|$\\)" limit t)
</span><span class="gi">+ (if (re-search-forward "^[ \t]*=end\\(\\s \\|$\\)" limit t)
</span> (progn
(set-match-data (list beg (point)))
t)))))
<span class="p">@@ -1423,12 +1423,12 @@</span> buffer position `limit' or the end of the buffer."
(defun ruby-font-lock-maybe-docs (limit)
(let (beg)
(save-excursion
<span class="gd">- (if (and (re-search-backward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
</span><span class="gi">+ (if (and (re-search-backward "^[ \t]*=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
</span> (string= (match-string 1) "begin"))
(progn
(beginning-of-line)
(setq beg (point)))))
<span class="gd">- (if (and beg (and (re-search-forward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
</span><span class="gi">+ (if (and beg (and (re-search-forward "^[ \t]*=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t)
</span> (string= (match-string 1) "end")))
(progn
(set-match-data (list beg (point)))
<span class="gh">diff --git i/parse.y w/parse.y
index 028b89c070..4d3de062c6 100644
</span><span class="gd">--- i/parse.y
</span><span class="gi">+++ w/parse.y
</span><span class="p">@@ -7851,6 +7851,18 @@</span> parse_ident(struct parser_params *parser, int c, int cmd_state)
}
static int
<span class="gi">+parser_indented_bol_p(struct parser_params *parser)
+{
+ const char *p = lex_pbeg;
+ const char *e = lex_p - 1;
+ while (p < e) {
+ if (!ISSPACE(*p)) return FALSE;
+ p++;
+ }
+ return TRUE;
+}
+
+static int
</span> parser_yylex(struct parser_params *parser)
{
register int c;
<span class="p">@@ -8039,7 +8051,7 @@</span> parser_yylex(struct parser_params *parser)
return '!';
case '=':
<span class="gd">- if (was_bol()) {
</span><span class="gi">+ if (was_bol() || parser_indented_bol_p(parser)) {
</span> /* skip embedded rd document */
if (strncmp(lex_p, "begin", 5) == 0 && ISSPACE(lex_p[5])) {
int first_p = TRUE;
<span class="p">@@ -8057,6 +8069,7 @@</span> parser_yylex(struct parser_params *parser)
compile_error(PARSER_ARG "embedded document meets end of file");
return 0;
}
<span class="gi">+ while (ISSPACE(c)) c = nextc();
</span> if (c != '=') continue;
if (c == '=' && strncmp(lex_p, "end", 3) == 0 &&
(lex_p + 3 == lex_pend || ISSPACE(lex_p[3]))) {
<span class="gh">diff --git i/test/ruby/test_parse.rb w/test/ruby/test_parse.rb
index 56e1020c5a..a51b5471e4 100644
</span><span class="gd">--- i/test/ruby/test_parse.rb
</span><span class="gi">+++ w/test/ruby/test_parse.rb
</span><span class="p">@@ -988,6 +988,15 @@</span>
assert_equal(-100, e.backtrace_locations.first.lineno, bug)
end
<span class="gi">+ def test_indented_multiline_comment
+ assert_valid_syntax("#{<<-"begin;"}\n#{<<-"end;"}")
+ begin;
+ =begin
+ <.><^>
+ =end
+ end;
+ end
+
</span> =begin
def test_past_scope_variable
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
</code></pre>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=64571
2017-04-30T00:17:49Z
tscheingeld (Terry Scheingeld)
<ul></ul><p>nobu (Nobuyoshi Nakada) wrote:</p>
<blockquote>
<p>Possible of course, but I'm not a big fan of this.</p>
</blockquote>
<p>Respect for your ability to quickly modify the code for what I suggested.</p>
<p>Just to clarify: are you not a big fan of the feature request in general, or just not a fan of the particular implementation you displayed?</p>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=64618
2017-05-01T08:04:10Z
duerst (Martin Dürst)
duerst@it.aoyama.ac.jp
<ul></ul><p>Nobu can correct me if I'm wrong, but he meant the feature when he said "not a big fan". Same for me. <code>=begin</code>/<code>=end</code> are rare, and it's better to make them stick out.</p>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=64677
2017-05-06T22:13:29Z
tscheingeld (Terry Scheingeld)
<ul></ul><p>duerst (Martin Dürst) wrote:</p>
<blockquote>
<p><code>=begin</code>/<code>=end</code> are rare, and it's better to make them stick out.</p>
</blockquote>
<p>I would make the case that <code>=begin</code>/<code>=end</code> is rare because it can't be indented. Multiline comments are very handy. It makes syntax highlighting much cleaner for embedded content (in my case, documentation) if every line doesn't have to start with a comment from the outer language.</p>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=64932
2017-05-19T08:14:17Z
nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>How about that matching indentation of <code>=begin</code> and <code>=end</code>?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"> <span class="o">=</span><span class="k">begin</span>
<span class="k">in</span> <span class="n">a</span> <span class="n">comment</span>
<span class="o">=</span><span class="k">end</span>
<span class="n">still</span> <span class="k">in</span> <span class="n">a</span> <span class="n">comment</span>
<span class="o">=</span><span class="k">end</span>
<span class="c1"># end of the comment</span>
</code></pre>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=65353
2017-06-13T02:22:40Z
tscheingeld (Terry Scheingeld)
<ul></ul><p>nobu (Nobuyoshi Nakada) wrote:</p>
<blockquote>
<p>How about that matching indentation of <code>=begin</code> and <code>=end</code>?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"> <span class="o">=</span><span class="k">begin</span>
<span class="k">in</span> <span class="n">a</span> <span class="n">comment</span>
<span class="o">=</span><span class="k">end</span>
<span class="n">still</span> <span class="k">in</span> <span class="n">a</span> <span class="n">comment</span>
<span class="o">=</span><span class="k">end</span>
<span class="c1"># end of the comment</span>
</code></pre>
</blockquote>
<p>Makes sense to me.</p>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=65404
2017-06-16T08:57:05Z
matz (Yukihiro Matsumoto)
matz@ruby.or.jp
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Rejected</i></li></ul><p><code>=begin</code> and <code>=end</code> are ugly appendix inherited from Perl. I'd rather remove them than enhance them.</p>
<p>Matz.</p>
Ruby master - Feature #13518: Indented multiline comments
https://redmine.ruby-lang.org/issues/13518?journal_id=103277
2023-05-24T16:19:35Z
nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/19688">Feature #19688</a>: Add indentable block comment syntax</i> added</li></ul>