GNU bug report logs - #68226
[PATCH] Improve block_node handling for yaml-ts-mode fill-paragraph

Previous Next

Package: emacs;

Reported by: Graham Marlow <graham <at> mgmarlow.com>

Date: Tue, 2 Jan 2024 22:12:02 UTC

Severity: normal

Tags: patch

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 68226 in the body.
You can then email your comments to 68226 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#68226; Package emacs. (Tue, 02 Jan 2024 22:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Graham Marlow <graham <at> mgmarlow.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 02 Jan 2024 22:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Graham Marlow <graham <at> mgmarlow.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Improve block_node handling for yaml-ts-mode fill-paragraph
Date: Tue, 2 Jan 2024 14:10:53 -0800
[Message part 1 (text/plain, inline)]
Hello Emacs maintainers,

I noticed that the yaml-ts-mode fill-paragraph function doesn't play 
nicely with block nodes, making it difficult to tidy paragraphs. For 
example,

foo: |
  line-one
  line-two

Becomes

foo: | line-one line-two

Effectively undoing the block.

My proposed changes (see attached patch) fixes this behavior so that 
block nodes remain formatted correctly:

foo: |
  line-one line-two

It also plays nicely with longer pieces of text and multiple paragraphs.

I tried to base my changes off of the fill-paragraph function from 
c-ts-common, though the YAML version is much simpler since it doesn't 
need to account for comment insertion. I've not written a fill-paragraph 
function before so I'm sure I messed something up.

What do you think?
[0001-Improve-block_node-handling-for-yaml-ts-mode-fill-pa.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68226; Package emacs. (Wed, 03 Jan 2024 04:43:01 GMT) Full text and rfc822 format available.

Message #8 received at 68226 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Graham Marlow <graham <at> mgmarlow.com>
Cc: 68226 <at> debbugs.gnu.org
Subject: Re: bug#68226: [PATCH] Improve block_node handling for yaml-ts-mode
 fill-paragraph
Date: Tue, 2 Jan 2024 20:41:52 -0800

> On Jan 2, 2024, at 2:10 PM, Graham Marlow <graham <at> mgmarlow.com> wrote:
> 
> Hello Emacs maintainers,
> 
> I noticed that the yaml-ts-mode fill-paragraph function doesn't play nicely with block nodes, making it difficult to tidy paragraphs. For example,
> 
> foo: |
>  line-one
>  line-two
> 
> Becomes
> 
> foo: | line-one line-two
> 
> Effectively undoing the block.
> 
> My proposed changes (see attached patch) fixes this behavior so that block nodes remain formatted correctly:
> 
> foo: |
>  line-one line-two
> 
> It also plays nicely with longer pieces of text and multiple paragraphs.
> 
> I tried to base my changes off of the fill-paragraph function from c-ts-common, though the YAML version is much simpler since it doesn't need to account for comment insertion. I've not written a fill-paragraph function before so I'm sure I messed something up.
> 
> What do you think?<0001-Improve-block_node-handling-for-yaml-ts-mode-fill-pa.patch>

Thank you! This is great. The function assumes that the block starts at the line below “|”, but I think it’s very rare when people write string block right after the “|”.

Have you signed the copyright assignment?

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68226; Package emacs. (Wed, 03 Jan 2024 05:23:02 GMT) Full text and rfc822 format available.

Message #11 received at 68226 <at> debbugs.gnu.org (full text, mbox):

From: "Graham Marlow" <graham <at> mgmarlow.com>
To: "Yuan Fu" <casouri <at> gmail.com>
Cc: 68226 <at> debbugs.gnu.org
Subject: Re: bug#68226: [PATCH] Improve block_node handling for yaml-ts-mode
 fill-paragraph
Date: Tue, 02 Jan 2024 21:21:02 -0800
> Thank you! This is great. The function assumes that the block starts at 
> the line below “|”, but I think it’s very rare when people write string 
> block right after the “|”.

Happy to help!

> Have you signed the copyright assignment?

I have indeed. 

Best,
Graham




Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Fri, 05 Jan 2024 00:43:02 GMT) Full text and rfc822 format available.

Notification sent to Graham Marlow <graham <at> mgmarlow.com>:
bug acknowledged by developer. (Fri, 05 Jan 2024 00:43:02 GMT) Full text and rfc822 format available.

Message #16 received at 68226-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Graham Marlow <graham <at> mgmarlow.com>
Cc: 68226-done <at> debbugs.gnu.org
Subject: Re: bug#68226: [PATCH] Improve block_node handling for yaml-ts-mode
 fill-paragraph
Date: Thu, 4 Jan 2024 16:42:23 -0800

> On Jan 2, 2024, at 9:21 PM, Graham Marlow <graham <at> mgmarlow.com> wrote:
> 
>> Thank you! This is great. The function assumes that the block starts at 
>> the line below “|”, but I think it’s very rare when people write string 
>> block right after the “|”.
> 
> Happy to help!
> 
>> Have you signed the copyright assignment?
> 
> I have indeed. 

Installed on master, thanks!

Yuan



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 02 Feb 2024 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.