On 6 November 2013 23:45, Dmitry Gutov wrote: > On 06.11.2013 19:10, Bozhidar Batsov wrote: > >> Here's a patch for making the comment format customizable. How does it >> look to you? >> > > There might be a problem with weird template formats a user would be > technically allowed to choose: if the template doesn't match either of the > regexps used in `ruby-mode-set-encoding', the coding comment will be added > at the first line of the buffer, even if it already contains (the > non-standard) one. Not sure if that's a real problem, but maybe we should > relax the regexps and/or reject all non-matching templates. > Yeah, I though of this, but decided we can assume that few people would run into this and they'll probably understand their mistake pretty soon. > > Other than that, looks fine to me. Possible improvements, if you like: > > 1. Move "#" also inside the template. It'll make the code a bit simpler > and get rid of the implicit requirement that the template starts with a > space. > Actually the template should not necessary start with a space, that why I did not put the `#` in it. A comment like #coding:utf-8 is perfectly valid (albeit it looks kind of ugly). But yeah, might be easier for people of the `#` was in the template itself. > > 2. Add predefined values to the customize widget? (:type (choice ...)) > Allow the user to choose between Emacs-style and Ruby-style. > Makes sense. Btw, Dimitry - please add some info the ruby-mode.el about running the tests. I tried evaluating and running them manually, but this crashed my Emacs (the tests hogged my CPU completely and I had to kill Emacs). Maybe there is something wrong with them right now, or perhaps they should invoked in some manner I'm not aware of.