still work the same way with them. This also fixes
compilation on Mac OS X 10.4.1, which doesn't seem to define a
wint_t type. (DLR, problem found by Emily Jackson)
+ - Add the ability to convert typed tabs to spaces using
+ the -E/--tabstospaces command line options, the "tabstospaces"
+ rcfile option, and the toggle Meta-E. Note that this doesn't
+ affect tabs entered using verbatim input, and that it's
+ disabled when NANO_SMALL is defined. Also, change the short
+ command line option for --backupdir from -E to -C. Changes to
+ toggle_init(), help_init(), usage(), do_tab(), main(),
+ nanorc.sample, nano.1, nanorc.5, and nano.texi. (DLR,
+ suggested by many people)
- chars.c:
make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
-.TH NANO 1 "version 1.3.8" "June 3, 2005"
+.TH NANO 1 "version 1.3.8" "June 15, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
When saving a file, back up the previous version of it to the current
filename suffixed with a ~.
.TP
-.B \-E \fIdir\fP (\-\-backupdir=\fIdir\fP)
+.B \-C \fIdir\fP (\-\-backupdir=\fIdir\fP)
Set the directory where \fBnano\fP puts unique backup files if file
backups are enabled.
.TP
+.B \-E (\-\-tabstospaces)
+Convert typed tabs to spaces.
+.TP
.B \-F (\-\-multibuffer)
Enable multiple file buffers, if available.
.TP
}
/* If the primary meta key sequence is the first entry,
* don't put parentheses around it. */
- if (entries == 1 && s->metaval == NANO_ALT_SPACE) {
- char *space_ptr = display_string(_("Space"), 0, 5,
+ if (entries == 1) {
+ /* Yucky sentinel values we can't handle a better
+ * way. */
+ if (s->metaval == NANO_ALT_SPACE) {
+ char *space_ptr = display_string(_("Space"), 0, 5,
FALSE);
- ptr += sprintf(ptr, "M-%s", space_ptr);
+ ptr += sprintf(ptr, "M-%s", space_ptr);
- free(space_ptr);
+ free(space_ptr);
+ }
} else
- ptr += sprintf(ptr, entries == 1 ? "M-%c" : "(M-%c)",
+ /* Normal values. */
+ ptr += sprintf(ptr, (entries == 1) ? "M-%c" : "(M-%c)",
toupper(s->metaval));
*(ptr++) = '\t';
}
#ifndef NANO_SMALL
print1opt("-A", "--smarthome", N_("Enable smart home key"));
print1opt("-B", "--backup", N_("Save backups of existing files"));
- print1opt(_("-E [dir]"), _("--backupdir=[dir]"),
+ print1opt(_("-C [dir]"), _("--backupdir=[dir]"),
N_("Directory for saving unique backup files"));
+ print1opt("-E", "--tabstospaces",
+ N_("Convert typed tabs to spaces"));
#endif
#ifdef ENABLE_MULTIBUFFER
print1opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
void do_tab(void)
{
- do_output("\t", 1, TRUE);
+#ifndef NANO_SMALL
+ if (ISSET(TABS_TO_SPACES)) {
+ char *output;
+ size_t output_len = 0, new_pww = placewewant;
+
+ do {
+ new_pww++;
+ output_len++;
+ } while (new_pww % tabsize != 0);
+
+ output = charalloc(output_len + 1);
+
+ charset(output, ' ', output_len);
+ output[output_len] = '\0';
+
+ do_output(output, output_len, TRUE);
+ } else {
+#endif
+ do_output("\t", 1, TRUE);
+#ifndef NANO_SMALL
+ }
+#endif
}
/* Someone hits Return *gasp!* */
#ifndef NANO_SMALL
{"smarthome", 0, NULL, 'A'},
{"backup", 0, NULL, 'B'},
- {"backupdir", 1, NULL, 'E'},
+ {"backupdir", 1, NULL, 'C'},
+ {"tabstospaces", 0, NULL, 'E'},
{"noconvert", 0, NULL, 'N'},
{"smooth", 0, NULL, 'S'},
{"restricted", 0, NULL, 'Z'},
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
- "h?ABDE:FHINOQ:ST:VY:Zabcdefgijklmo:pr:s:tvwxz",
+ "h?ABC:EFHINOQ:ST:VY:Zabcdefgijklmo:pr:s:tvwxz",
long_options, NULL)
#else
getopt(argc, argv,
- "h?ABDE:FHINOQ:ST:VY:Zabcdefgijklmo:pr:s:tvwxz")
+ "h?ABC:EFHINOQ:ST:VY:Zabcdefgijklmo:pr:s:tvwxz")
#endif
) != -1) {
case 'B':
SET(BACKUP_FILE);
break;
- case 'E':
+ case 'C':
backup_dir = mallocstrcpy(backup_dir, optarg);
break;
+ case 'E':
+ SET(TABS_TO_SPACES);
+ break;
#endif
#ifdef ENABLE_MULTIBUFFER
case 'F':