all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bozhidar Batsov <bozhidar@batsov.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Subject: [PATCH] * lisp/progmodes/ruby-mode.el: Set `ruby-insert-encoding-magic-comment' to nil by default.
Date: Wed, 6 Nov 2013 19:10:11 +0200	[thread overview]
Message-ID: <CAM9Zgm0YfpnCXS4-0qA8QZ8PZpJ_0QuGJGB8TtaQFBgjW=ReaQ@mail.gmail.com> (raw)
In-Reply-To: <CAM9Zgm1iJGbUxWfzLJW3=g_=_tBPTSMySbmek1tPRuTdSOknRg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1470 bytes --]

Here's a patch for making the comment format customizable. How does it look
to you?


I'll send later another patch with the always-utf8 customization we
discussed.


On 4 November 2013 15:40, Bozhidar Batsov <bozhidar@batsov.com> wrote:

> OK. I'll implement the discussed customizations.
>
>
> On 3 November 2013 11:22, Dmitry Gutov <dgutov@yandex.ru> wrote:
>
>> Bozhidar Batsov <bozhidar@batsov.com> writes:
>>
>> > Sorry about the lack of clarity - I meant that if you have a Ruby 2.0
>> only project you likely don't
>> > want the insertion of utf-8 coding comments.
>> >
>> > ...
>> >
>> > Yeah, I'm aware of that. In my open source projects I still keep 1.9
>> compatibility and generally
>> > include those cookies in every file. Since I want them included
>> unconditionally (AFAIK many other
>> > Ruby programmers do this as well for the sake of consistency) the
>> magic-comment functionality in
>> > ruby-mode is quite useless to me even for Ruby 1.9.
>>
>> Now I get it, thanks for the explanation.
>>
>> > If we add the option to include the magic
>> > comment unconditionally that might increase the usefulness of the
>> > setting for some people.
>>
>> Sure, as long as it's not on by default. For example, add a new possible
>> value of `ruby-insert-encoding-magic-comment': `always'. Or `always-utf8'.
>>
>> In this case, `ruby-mode-set-encoding' might short-circuit the whole
>> encoding detection logic and just always write `coding: utf-8'.
>>
>
>

[-- Attachment #1.2: Type: text/html, Size: 2327 bytes --]

[-- Attachment #2: 0001-lisp-progmodes-ruby-mode.el-ruby-mode-set-encoding.patch --]
[-- Type: application/octet-stream, Size: 1641 bytes --]

From 3202624bb533968cc1bdd7b4a8c8669a9fc4f967 Mon Sep 17 00:00:00 2001
From: Bozhidar Batsov <bozhidar@batsov.com>
Date: Wed, 6 Nov 2013 19:04:34 +0200
Subject: [PATCH] * lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding):  
 Make encoding comment format customizable via
 `ruby-encoding-magic-comment-template'.

---
 lisp/progmodes/ruby-mode.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 253a600..01989f5 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -261,6 +261,10 @@ explicitly declared in magic comment."
   "Insert a magic Emacs 'coding' comment upon save if this is non-nil."
   :type 'boolean :group 'ruby)
 
+(defcustom ruby-encoding-magic-comment-template " -*- coding: %s -*-"
+  "An encoding comment template in which the actual encoding will be inserted."
+  :type 'string :group 'ruby)
+
 (defcustom ruby-use-encoding-map t
   "Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
   :type 'boolean :group 'ruby)
@@ -621,7 +625,10 @@ explicitly declared in magic comment."
                    (insert coding-system)))
                 ((looking-at "\\s *#.*coding\\s *[:=]"))
                 (t (when ruby-insert-encoding-magic-comment
-                     (insert "# -*- coding: " coding-system " -*-\n"))))
+                     (insert
+                      "#"
+                      (format ruby-encoding-magic-comment-template coding-system)
+                      "\n"))))
           (when (buffer-modified-p)
             (basic-save-buffer-1)))))))
 
-- 
1.8.4


  reply	other threads:[~2013-11-06 17:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-01 12:59 Subject: [PATCH] * lisp/progmodes/ruby-mode.el: Set `ruby-insert-encoding-magic-comment' to nil by default Bozhidar Batsov
2013-11-01 17:46 ` Stefan Monnier
2013-11-01 18:51   ` Bozhidar Batsov
2013-11-02  0:00 ` Dmitry Gutov
2013-11-02 10:38   ` Bozhidar Batsov
2013-11-02 20:15     ` Dmitry Gutov
2013-11-03  7:35       ` Bozhidar Batsov
2013-11-03  9:22         ` Dmitry Gutov
2013-11-04 13:40           ` Bozhidar Batsov
2013-11-06 17:10             ` Bozhidar Batsov [this message]
2013-11-06 21:45               ` Dmitry Gutov
2013-11-07 10:23                 ` Bozhidar Batsov
2013-11-07 11:06                   ` Dmitry Gutov
2013-11-13 14:36                     ` Bozhidar Batsov
2013-11-13 19:19                       ` Dmitry Gutov
2013-11-14  9:53                         ` Bozhidar Batsov
2013-11-14 13:23                           ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM9Zgm0YfpnCXS4-0qA8QZ8PZpJ_0QuGJGB8TtaQFBgjW=ReaQ@mail.gmail.com' \
    --to=bozhidar@batsov.com \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.