GNU bug report logs - #48043
UTF-8 magic comment is unwelcome with recent Ruby versions

Previous Next

Package: emacs;

Reported by: Peter Oliver <p.d.oliver <at> mavit.org.uk>

Date: Mon, 26 Apr 2021 18:29:01 UTC

Severity: normal

Tags: patch

Fixed in version 28.1

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#48043: closed (UTF-8 magic comment is unwelcome with recent
 Ruby versions)
Date: Wed, 28 Apr 2021 02:25:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 28 Apr 2021 05:23:56 +0300
with message-id <ad76c850-8f67-a427-ef40-5cb5d2c14e97 <at> yandex.ru>
and subject line Re: bug#48043: UTF-8 magic comment is unwelcome with recent Ruby versions
has caused the debbugs.gnu.org bug report #48043,
regarding UTF-8 magic comment is unwelcome with recent Ruby versions
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
48043: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=48043
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Peter Oliver <p.d.oliver <at> mavit.org.uk>
To: bug-gnu-emacs <at> gnu.org
Subject: UTF-8 magic comment is unwelcome with recent Ruby versions
Date: Mon, 26 Apr 2021 19:28:21 +0100 (BST)
[Message part 3 (text/plain, inline)]
When saving a ruby-mode buffer, if the content is not plain ASCII, then the default behaviour is to add a specially-formatted comment that indicates the encoding to the Ruby interpreter.  E.g.,

# coding: utf-8

However, since Ruby 2.0 released in 2013, the default encoding for Ruby has been UTF-8.  Consequently, users of other editors tend not to include this comment when using UTF-8.  When you edit such a file with Emacs, you end up with a messy diff.

Two patches are attached to address this:

- The first patch adds a new choice to ruby-insert-encoding-magic-comment, unless-utf8, which causes the magic comment not to be inserted if the encoding is UTF-8.

- The second patch, perhaps more controversially, makes this the default.

-- 
Peter Oliver
[0001-New-choice-for-ruby-insert-encoding-magic-comment-un.patch (text/plain, attachment)]
[0002-Default-ruby-insert-encoding-magic-comment-to-unless.patch (text/plain, attachment)]
[Message part 6 (message/rfc822, inline)]
From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Peter Oliver <p.d.oliver <at> mavit.org.uk>
Cc: 48043-done <at> debbugs.gnu.org
Subject: Re: bug#48043: UTF-8 magic comment is unwelcome with recent Ruby
 versions
Date: Wed, 28 Apr 2021 05:23:56 +0300
Version: 28.1

On 27.04.2021 18:29, Peter Oliver wrote:

> That works for me, and I think is more straightforward than my 
> approach.  Thanks.
> 
> Attached is an additional patch which adapts the tests added in my patch 
> for your patch.

Thanks! I've pushed the change and the tests to master.

Please note that since (AFAICT) you don't have FSF copyright assignment 
on file this exhausts the allowed limit for code contributions to Emacs.

Would you like us to send you the assignment form, so that the next 
patch could be accepted without reservation?


This bug report was last modified 4 years and 23 days ago.

Previous Next


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