2009-02-09 Chris Allegretta <chrisa@asty.org>

* New option -q, --quiet, rcfile option "quiet" implemented.  Skips printing
          errors about the rcfile and asking user to press enter.  Also, nano should
          now only ask for one enter press when there is an error when not using -q.
          Based on discussion between Eitan Adler and Mike Frysinger.
        * rcfile.c (parse_keybinding) -  Significant cleanups and fixes for
          detecting and reporting errors in key bindings code.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4374 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2009-02-09 04:03:20 +00:00
parent 35686daf9d
commit a30eb78006
6 changed files with 52 additions and 25 deletions

View File

@ -1,3 +1,11 @@
2009-02-09 Chris Allegretta <chrisa@asty.org>
* New option -q, --quiet, rcfile option "quiet" implemented. Skips printing
errors about the rcfile and asking user to press enter. Also, nano should
now only ask for one enter press when there is an error when not using -q.
Based on discussion between Eitan Adler and Mike Frysinger.
* rcfile.c (parse_keybinding) - Significant cleanups and fixes for
detecting and reporting errors in key bindings code.
2009-02-08 Chris Allegretta <chrisa@asty.org>
* Make reset_multidata reset more lines, since contrary to previous problems the
syntax highlting is now too *un*ambitious, causing display glitches when

View File

@ -172,6 +172,10 @@ chroot.
Preserve the XON and XOFF sequences (^Q and ^S) so they will be caught
by the terminal.
.TP
.B \-q (\-\-quiet)
Do not report errors in the nanorc file and ask them to
be acknowledged by pressing enter at startup.
.TP
.B \-r \fIcols\fP (\-\-fill=\fIcols\fP)
Wrap lines at column \fIcols\fP. If this value is 0 or less, wrapping
will occur at the width of the screen less \fIcols\fP columns, allowing

View File

@ -145,6 +145,11 @@ paragraphs. They cannot contain blank characters. Only closing
punctuation, optionally followed by closing brackets, can end sentences.
The default value is "\fI!.?\fP".
.TP
.B set/unset quiet
\fBnano\fP will not report errors in the nanorc file and ask them to
be acknowledged by pressing enter at startup. If this is used it should
be placed at the top of the file to be fully effective.
.TP
.B set/unset quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
keystroke instead of 25.

View File

@ -879,6 +879,8 @@ void usage(void)
#endif
print_opt("-p", "--preserve",
N_("Preserve XON (^Q) and XOFF (^S) keys"));
print_opt("-q", "--quiet",
N_("Silently ignore startup issues like rc file errors"));
#ifndef DISABLE_WRAPJUSTIFY
print_opt(_("-r <#cols>"), _("--fill=<#cols>"),
N_("Set wrapping point at column #cols"));
@ -1930,6 +1932,7 @@ int main(int argc, char **argv)
{"operatingdir", 1, NULL, 'o'},
#endif
{"preserve", 0, NULL, 'p'},
{"quiet", 0, NULL, 'q'},
#ifndef DISABLE_WRAPJUSTIFY
{"fill", 1, NULL, 'r'},
#endif
@ -1993,11 +1996,11 @@ int main(int argc, char **argv)
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz",
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tvwxz",
long_options, NULL)
#else
getopt(argc, argv,
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz")
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tvwxz")
#endif
) != -1) {
switch (optchr) {
@ -2125,6 +2128,9 @@ int main(int argc, char **argv)
case 'p':
SET(PRESERVE);
break;
case 'q':
SET(QUIET);
break;
#ifndef DISABLE_WRAPJUSTIFY
case 'r':
if (!parse_num(optarg, &wrap_at)) {

View File

@ -471,6 +471,7 @@ typedef struct subnfunc {
#define WORD_BOUNDS (1<<28)
#define NO_NEWLINES (1<<29)
#define BOLD_TEXT (1<<30)
#define QUIET (1<<31)
/* Flags for which menus in which a given function should be present */
#define MMAIN (1<<0)

View File

@ -84,6 +84,7 @@ static const rcoption rcopts[] = {
{"historylog", HISTORYLOG},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
{"quiet", QUIET},
{"quickblank", QUICK_BLANK},
{"smarthome", SMART_HOME},
{"smooth", SMOOTH_SCROLL},
@ -117,6 +118,9 @@ void rcfile_error(const char *msg, ...)
{
va_list ap;
if (ISSET(QUIET))
return;
fprintf(stderr, "\n");
if (lineno > 0) {
errors = TRUE;
@ -388,41 +392,41 @@ void parse_keybinding(char *ptr)
if (keycopy[0] != 'M' && keycopy[0] != '^' && keycopy[0] != 'F' && keycopy[0] != 'K') {
rcfile_error(
N_("keybindings must begin with \"^\", \"M\", or \"F\"\n"));
N_("keybindings must begin with \"^\", \"M\", or \"F\""));
return;
}
funcptr = ptr;
ptr = parse_next_word(ptr);
if (funcptr == NULL) {
if (!strcmp(funcptr, "")) {
rcfile_error(
N_("Must specify function to bind key to\n"));
N_("Must specify function to bind key to"));
return;
}
menuptr = ptr;
ptr = parse_next_word(ptr);
if (menuptr == NULL) {
if (!strcmp(menuptr, "")) {
rcfile_error(
/* Note to translators, do not translate the word "all"
in the sentence below, everything else is fine */
N_("Must specify menu bind key to (or \"all\")\n"));
return;
}
menu = strtomenu(menuptr);
if (menu < 1) {
rcfile_error(
N_("Could not map name \"%s\" to a menu\n"), menuptr);
N_("Must specify menu to bind key to (or \"all\")"));
return;
}
newsc = strtosc(menu, funcptr);
if (newsc == NULL) {
rcfile_error(
N_("Could not map name \"%s\" to a function\n"), funcptr);
N_("Could not map name \"%s\" to a function"), funcptr);
return;
}
menu = strtomenu(menuptr);
if (menu < 1) {
rcfile_error(
N_("Could not map name \"%s\" to a menu"), menuptr);
return;
}
@ -444,7 +448,7 @@ void parse_keybinding(char *ptr)
if (check_bad_binding(newsc)) {
rcfile_error(
N_("Sorry, keystr \"%s\" is an illegal binding\n"), newsc->keystr);
N_("Sorry, keystr \"%s\" is an illegal binding"), newsc->keystr);
return;
}
@ -1057,15 +1061,6 @@ void parse_rcfile(FILE *rcstream
lineno = 0;
check_vitals_mapped();
if (errors) {
errors = FALSE;
fprintf(stderr,
_("\nPress Enter to continue starting nano.\n"));
while (getchar() != '\n')
;
}
return;
}
@ -1146,6 +1141,14 @@ void do_rcfile(void)
free(nanorc);
nanorc = NULL;
if (errors && !ISSET(QUIET)) {
errors = FALSE;
fprintf(stderr,
_("\nPress Enter to continue starting nano.\n"));
while (getchar() != '\n')
;
}
#ifdef ENABLE_COLOR
set_colorpairs();
#endif