add the ability to convert (non-verbatim input) typed tabs to spaces
using the -E/--tabstospaces command line options, the "tabstospaces" rcfile option, and the toggle Meta-E; also, change the short command line option for --backupdir from -E to -C git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2682 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
072f86c5f9
commit
6f143c8124
|
@ -86,6 +86,15 @@ CVS code -
|
|||
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
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
.\" 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.
|
||||
.\"
|
||||
|
||||
|
@ -50,10 +50,13 @@ line.
|
|||
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
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANORC 5 "version 1.3.8" "June 8, 2005"
|
||||
.TH NANORC 5 "version 1.3.8" "June 15, 2005"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
|
@ -143,6 +143,9 @@ Allow nano to be suspended.
|
|||
Use a tab size of \fIn\fP columns instead of the default (8); must be
|
||||
greater than 0.
|
||||
.TP
|
||||
\fBset/unset tabstospaces\fP
|
||||
Convert typed tabs to spaces.
|
||||
.TP
|
||||
\fBset/unset tempfile\fP
|
||||
Save automatically on exit, don't prompt.
|
||||
.TP
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
## Use cut to end of line by default.
|
||||
# set cut
|
||||
|
||||
## Convert typed tabs to spaces.
|
||||
# set tabstospaces
|
||||
|
||||
## Set the line length for wrapping text and justifying paragraphs.
|
||||
## If fill is negative, the line length will be the screen width less
|
||||
## this number.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 1.3.8
|
||||
@set UPDATED 03 Jun 2005
|
||||
@set UPDATED 15 Jun 2005
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
|
@ -124,10 +124,13 @@ line.
|
|||
When saving a file, back up the previous version of it to the current
|
||||
filename suffixed with a ~.
|
||||
|
||||
@item -E, --backupdir=[dir]
|
||||
@item -C, --backupdir=[dir]
|
||||
Set the directory where @code{nano} puts unique backup files if file
|
||||
backups are enabled.
|
||||
|
||||
@item -E, --tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
|
||||
@item -F, --multibuffer
|
||||
Enable multiple file buffers, if available.
|
||||
|
||||
|
|
|
@ -1151,6 +1151,8 @@ void toggle_init(void)
|
|||
#endif
|
||||
toggle_init_one(TOGGLE_MORESPACE_KEY,
|
||||
N_("Use of more space for editing"), MORE_SPACE);
|
||||
toggle_init_one(TOGGLE_TABSTOSPACES_KEY,
|
||||
N_("Conversion of typed tabs to spaces"), TABS_TO_SPACES);
|
||||
}
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
|
|
54
src/nano.c
54
src/nano.c
|
@ -519,15 +519,20 @@ void help_init(void)
|
|||
}
|
||||
/* 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';
|
||||
}
|
||||
|
@ -1024,8 +1029,10 @@ void usage(void)
|
|||
#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"));
|
||||
|
@ -1381,7 +1388,28 @@ void do_delete(void)
|
|||
|
||||
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!* */
|
||||
|
@ -4122,7 +4150,8 @@ int main(int argc, char **argv)
|
|||
#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'},
|
||||
|
@ -4169,11 +4198,11 @@ int main(int argc, char **argv)
|
|||
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) {
|
||||
|
||||
|
@ -4193,9 +4222,12 @@ int main(int argc, char **argv)
|
|||
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':
|
||||
|
|
|
@ -303,7 +303,8 @@ typedef struct syntaxtype {
|
|||
#define SMART_HOME (1<<26)
|
||||
#define WHITESPACE_DISPLAY (1<<27)
|
||||
#define MORE_SPACE (1<<28)
|
||||
#define NO_UTF8 (1<<29)
|
||||
#define TABS_TO_SPACES (1<<29)
|
||||
#define NO_UTF8 (1<<30)
|
||||
|
||||
/* Control key sequences. Changing these would be very, very bad. */
|
||||
#define NANO_CONTROL_SPACE 0
|
||||
|
@ -489,6 +490,7 @@ typedef struct syntaxtype {
|
|||
#define TOGGLE_SMARTHOME_KEY NANO_ALT_H
|
||||
#define TOGGLE_WHITESPACE_KEY NANO_ALT_P
|
||||
#define TOGGLE_MORESPACE_KEY NANO_ALT_O
|
||||
#define TOGGLE_TABSTOSPACES_KEY NANO_ALT_E
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
#define MAIN_VISIBLE 12
|
||||
|
|
|
@ -88,6 +88,9 @@ const static rcoption rcopts[] = {
|
|||
#endif
|
||||
{"suspend", SUSPEND},
|
||||
{"tabsize", 0},
|
||||
#ifndef NANO_SMALL
|
||||
{"tabstospaces", TABS_TO_SPACES},
|
||||
#endif
|
||||
{"tempfile", TEMP_FILE},
|
||||
{"view", VIEW_MODE},
|
||||
#ifndef NANO_SMALL
|
||||
|
|
Loading…
Reference in New Issue