Changes between Version 2 and Version 4 of Ticket #2138
- Timestamp:
- 2013-12-18T00:04:53Z (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #2138 – Description
v2 v4 1 This makes it so that emacs knows the intended character encoding, BOM, 2 end-of-line markers, and standard line-width of these files. 1 This makes it so that emacs knows the intended character encoding, BOM, end-of-line markers, standard line-width, and tabs-vs-spaces policy for these files. 3 2 4 Also this is a form of documentation. It means that you should put only 5 utf-8-encoded things into text files, only utf-8-encoded things into source 6 code files (and actually you should write only put ASCII-encoded things except 7 possibly in comments or docstrings!), and that you should line-wrap everything 8 at 77 columns wide. 3 This is also a form of documentation. It means that you should put only utf-8-encoded things into text files, only utf-8-encoded things into source code files (and actually you should write only put ASCII-encoded things except possibly in comments or docstrings!), and that you should line-wrap everything at 77 columns wide. 9 4 10 It also specifies that text files should start with a "utf-8 BOM". (Brian 11 questions the point of this, and my answer is that it adds information and 12 doesn't hurt. Whether that information will ever be useful is an open 13 question.) 5 It also specifies that text files should start with a "utf-8 BOM". (Brian questions the point of this, and my answer is that it adds information and doesn't hurt. Whether that information will ever be useful is an open question.) 14 6 15 It also specifies that text files should have unix-style ('\n') end-of-line 16 markers, not windows-style or old-macos-style. 7 It also specifies that text files should have unix-style end-of-line markers (i.e. '\n'), not windows-style or old-macos-style. 17 8 18 I generated this patch by writing and running the following script, and then 19 reading the resulting diff to make sure it was correct. I then undid the 20 changes that the script had done to the files inside the 21 "setuptools-0.6c16dev4.egg" directory before committing the patch. 9 For Python source code files, it also specifies that you should not insert tab characters (so you should use spaces for Python block structure). 22 10 11 I generated this patch by writing and running the following script, and then reading the resulting diff to make sure it was correct. I then undid the changes that the script had done to the files inside the "setuptools-0.6c16dev4.egg" directory before committing the patch. 12 13 ------- begin appended script:: 23 14 {{{ 15 #!/usr/bin/env python 16 # -*- coding: utf-8-with-signature-unix; fill-column: 77 -*- 17 24 18 import os 25 19 … … 40 34 41 35 if len(formattedlines) == 0: 42 return36 continue 43 37 44 38 outfo = open(fname, 'w') … … 52 46 if firstline.startswith(u"#!"): 53 47 outfo.write(firstline.encode('utf-8')) 54 outfo.write(commentsign.encode('utf-8')) 55 outfo.write("-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8')) 48 outfo.write(commentsign+"-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8')) 49 if ext == '.py': 50 outfo.write(commentsign+"-*- indent-tabs-mode: nil -*-\n".encode('utf-8')) 56 51 else: 57 outfo.write(commentsign.encode('utf-8')) 58 outfo.write("-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8')) 59 if (commentsign in firstline) and ("-*-" in firstline) and ("coding:" in firstline): 52 outfo.write(commentsign+"-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8')) 53 if ext == '.py': 54 outfo.write(commentsign+"-*- indent-tabs-mode: nil -*-\n".encode('utf-8')) 55 if (firstline.strip().startswith(commentsign)) and ("-*-" in firstline) and ("coding:" in firstline): 60 56 print "warning there was already a coding line %r in %r" % (firstline, fname) 61 57 else: … … 63 59 64 60 for l in formattedlines: 65 if ( commentsign in l) and ("-*-" in l) and ("coding:" in l):61 if (l.strip().startswith(commentsign)) and ("-*-" in l) and ("coding:" in l): 66 62 print "warning there was already a coding line %r in %r" % (l, fname) 67 63 else: