20 | | The file you are editing does not end with a newline as required by |
21 | | many programs. Do you want to add one? |
22 | | [Yes] [No] |
| 20 | I think a text editor should default to the OS's text file format |
| 21 | which does require a newline at the end of the last line (many |
| 22 | utilities including sudo actually require that and gcc warns if the |
| 23 | last line does not end with a newline). Of course, if one is |
| 24 | editing a DOS file (CRLF line separators), no newline is to be |
| 25 | enforced. |
| 26 | }}} |
24 | | and - since mcedit is suitable for editing binaries - it would not |
25 | | hurt if "No" was the by default selected button. |
| 28 | Comment 1 by Oswald Buddenhagen <ossi> at Thu 27 Apr 2006 04:05:23 PM UTC: |
| 29 | {{{ |
| 30 | nothing in the quoted paragraph suggests that a newline has to be |
| 31 | present. there are two philosophies regarding newlines: newlines as |
| 32 | line terminators (requires newline) and newlines as line breaks |
| 33 | (separators - no newline required). personally, i also lean towards |
| 34 | line termination. however, so far mcedit follows a "don't do |
| 35 | anything not explicitly requested" philosophy (autoindent being the |
| 36 | exception) - not necessarily by design, but because it is simpler |
| 37 | to implement. but i'd argue that the "explicit" mode is a good |
| 38 | default choice anyway. |
27 | | But a method to warn the user via some red highlighting would also |
28 | | suffice I think... the main reason is that I often read about |
29 | | complaints from users who edited their files with mcedit - and then |
30 | | the program (again, sudo and gcc are the most prominent examples) |
31 | | fails to work with the file (sudo, and there is no indication in |
32 | | the error messages about what is wrong) or outputs a warning the |
33 | | clueless user does not understand (in case of gcc - although I |
34 | | think gcc's warning is clear enough). |
35 | | Rudolf Polzer <div0> |
36 | | Sat 29 Apr 2006 08:25:21 AM UTC, comment #5: |
| 40 | as far as dos newlines are concerned, i repeatedly found it |
| 41 | annoying that mcedit can't deal with them (displaying ^M does not |
| 42 | count ;). i think it should handle them transparently - and |
| 43 | possibly offer a conversion option. |
| 44 | }}} |
38 | | ... except that this patch does not actually handle the Cancel case |
39 | | ... |
40 | | but other than that i'm fine with it. |
41 | | Oswald Buddenhagen <ossi> |
42 | | Sat 29 Apr 2006 08:12:29 AM UTC, comment #4: |
43 | | |
44 | | mcedit is currently suitable for editing binary files, too. I |
45 | | wouldn't like to give up this feature. So we had to do something |
46 | | like: |
47 | | |
48 | | if (the current file looks like a text file) { |
49 | | if (edit->size > 0 && get_byte(edit->size) != '\n') { |
50 | | if (inputbox("This file does not end with a newline. " |
51 | | "Shall we add it?", YES|NO|CANCEL) == YES) { |
52 | | edit_insert_byte(edit->size, '\n'); |
53 | | } |
54 | | } |
55 | | } |
56 | | Roland Illig <rillig> |
57 | | Project Member |
58 | | Thu 27 Apr 2006 09:50:09 PM UTC, comment #3: |
59 | | |
60 | | Damn, why does it say GNU/Hurd there? I'm quite sure that I didn't |
61 | | select that on purpose (I'm using GNU/Linux and FreeBSD), maybe I |
62 | | just clicked next to the right choice... please change that or |
63 | | ignore it, thanks. |
64 | | Rudolf Polzer <div0> |
65 | | Thu 27 Apr 2006 09:47:52 PM UTC, comment #2: |
66 | | |
| 46 | Comment 2 by Rudolf Polzer <div0> at Thu 27 Apr 2006 09:47:52 PM UTC: |
| 47 | {{{ |
88 | | nothing in the quoted paragraph suggests that a newline has to be |
89 | | present. there are two philosophies regarding newlines: newlines as |
90 | | line terminators (requires newline) and newlines as line breaks |
91 | | (separators - no newline required). personally, i also lean towards |
92 | | line termination. however, so far mcedit follows a "don't do |
93 | | anything not explicitly requested" philosophy (autoindent being the |
94 | | exception) - not necessarily by design, but because it is simpler |
95 | | to implement. but i'd argue that the "explicit" mode is a good |
96 | | default choice anyway. |
| 68 | Comment 3 by Rudolf Polzer <div0> at Thu 27 Apr 2006 09:50:09 PM UTC: |
| 69 | {{{ |
| 70 | Damn, why does it say GNU/Hurd there? I'm quite sure that I didn't |
| 71 | select that on purpose (I'm using GNU/Linux and FreeBSD), maybe I |
| 72 | just clicked next to the right choice... please change that or |
| 73 | ignore it, thanks. |
| 74 | }}} |
98 | | as far as dos newlines are concerned, i repeatedly found it |
99 | | annoying that mcedit can't deal with them (displaying ^M does not |
100 | | count ;). i think it should handle them transparently - and |
101 | | possibly offer a conversion option. |
102 | | Oswald Buddenhagen <ossi> |
103 | | Thu 27 Apr 2006 07:27:54 AM UTC, original submission: |
| 76 | Comment 4 by Roland Illig <rillig> at Sat 29 Apr 2006 08:12:29 AM UTC: |
| 77 | {{{ |
| 78 | mcedit is currently suitable for editing binary files, too. I |
| 79 | wouldn't like to give up this feature. So we had to do something |
| 80 | like: |
105 | | When editing a file, mcedit does not put a newline character at the |
106 | | end of the file as required by POSIX and other standards. |
| 82 | if (the current file looks like a text file) { |
| 83 | if (edit->size > 0 && get_byte(edit->size) != '\n') { |
| 84 | if (inputbox("This file does not end with a newline. " |
| 85 | "Shall we add it?", YES | NO | CANCEL) == YES) { |
| 86 | edit_insert_byte(edit->size, '\n'); |
| 87 | } |
| 88 | } |
| 89 | } |
114 | | I think a text editor should default to the OS's text file format |
115 | | which does require a newline at the end of the last line (many |
116 | | utilities including sudo actually require that and gcc warns if the |
117 | | last line does not end with a newline). Of course, if one is |
118 | | editing a DOS file (CRLF line separators), no newline is to be |
119 | | enforced. |
| 100 | Comment 6 by Rudolf Polzer <div0> at Sat 29 Apr 2006 09:18:23 AM UTC: |
| 101 | {{{ |
| 102 | I think such a dialog box should rather read: |
| 103 | |
| 104 | The file you are editing does not end with a newline as required by |
| 105 | many programs. Do you want to add one? |
| 106 | [Yes] [No] |
| 107 | |
| 108 | and - since mcedit is suitable for editing binaries - it would not |
| 109 | hurt if "No" was the by default selected button. |
| 110 | |
| 111 | But a method to warn the user via some red highlighting would also |
| 112 | suffice I think... the main reason is that I often read about |
| 113 | complaints from users who edited their files with mcedit - and then |
| 114 | the program (again, sudo and gcc are the most prominent examples) |
| 115 | fails to work with the file (sudo, and there is no indication in |
| 116 | the error messages about what is wrong) or outputs a warning the |
| 117 | clueless user does not understand (in case of gcc - although I |
| 118 | think gcc's warning is clear enough). |