Subject: Re: bug#54613: 29.0.50; uncomment-region in sh-mode deletes extra char

From: Filipp Gunbin <[email-masked]>
Date: Tue, 29 Mar 2022 22:07:29 +0300

On 29/03/2022 18:17 +0300, Filipp Gunbin wrote:

> On 29/03/2022 14:59 +0200, Lars Ingebrigtsen wrote:
>
>> Filipp Gunbin <[email-masked]> writes:
>>
>>> - Notice that `-' after "cat" disappeared
>>
>> I can reproduce this issue, too.
>>
>> What happens is that we have the following:
>>
>> curl -s -d @- http://example.org <<EOF \
>> # cat -
>>
>> with point after "cat -".  In that case, (comment-enter-backward) will
>> skip back past the " -", because comment-end-skip is
>>
>> "[ 	]*\\(\\s>\\|
>> \\)"
>>
>> And...  \s> matches the " -\\'"?  Hm.  I'm not sure what's the real
>> problem here is.  Should comment-end-skip have that value in shell
>> scripts?  On the other hand, commenting out bits of a heredoc-introduced
>> command with a continuation line is pretty hairy in itself.
>>
>
> I'm seeing in debugging that "-" after "cat" gets syntax-class "comment
> end", which seems wrong.  Just in buffer, outside of running
> uncomment-region, it doesn't happen.
>
> Filipp

This is the suspect, in sh-font-lock-open-heredoc:

--8<---------------cut here---------------start------------->8---
      (if (nth 4 ppss)
          ;; The \n not only starts the heredoc but also closes a comment.
          ;; Let's close the comment just before the \n.
          (put-text-property (1- eol) eol 'syntax-table '(12))) ;">"
--8<---------------cut here---------------end--------------->8---

So we put ">" syntax on the "-" char, and it gets removed in
uncomment-region.

Don't know how to fix it, though.

Filipp