mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-23 09:42:10 +03:00
allow the changing of closing punctuation and closing brackets (used in
justification) via the rcfile git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1783 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
483ea32c75
commit
2c62b07d2b
@ -101,6 +101,9 @@ CVS code -
|
|||||||
"whitespace". This is disabled if nanorc support is disabled
|
"whitespace". This is disabled if nanorc support is disabled
|
||||||
or if we're in tiny mode. (Mike Frysinger; minor changes and
|
or if we're in tiny mode. (Mike Frysinger; minor changes and
|
||||||
adaptations by DLR)
|
adaptations by DLR)
|
||||||
|
- Add the ability to change the closing punctuation and closing
|
||||||
|
brackets used to control justification, via the rcfile
|
||||||
|
entries "punct" and "brackets". (DLR)
|
||||||
- files.c:
|
- files.c:
|
||||||
add_open_file()
|
add_open_file()
|
||||||
- Rearrange the NANO_SMALL #ifdef so that the code to set the
|
- Rearrange the NANO_SMALL #ifdef so that the code to set the
|
||||||
@ -374,6 +377,7 @@ CVS code -
|
|||||||
- Document the smart home key option. (DLR)
|
- Document the smart home key option. (DLR)
|
||||||
- Document the whitespace option. (DLR, adapted from
|
- Document the whitespace option. (DLR, adapted from
|
||||||
documentation by Mike Frysinger)
|
documentation by Mike Frysinger)
|
||||||
|
- Document the punct and brackets options. (DLR)
|
||||||
- nano.texi:
|
- nano.texi:
|
||||||
- Fix toggle inaccuracies: Meta-L now toggles line wrapping, and
|
- Fix toggle inaccuracies: Meta-L now toggles line wrapping, and
|
||||||
Meta-< and Meta-> aren't toggles. (DLR)
|
Meta-< and Meta-> aren't toggles. (DLR)
|
||||||
|
@ -50,6 +50,10 @@ Create backup files in
|
|||||||
\fBset backupdir "\fIdirectory\fP"\fP
|
\fBset backupdir "\fIdirectory\fP"\fP
|
||||||
Set the directory where \fBnano\fP puts the backup files if file backups
|
Set the directory where \fBnano\fP puts the backup files if file backups
|
||||||
are enabled.
|
are enabled.
|
||||||
|
\fBset brackets "\fIstring\fP"\fP
|
||||||
|
Set the characters treated as closing brackets. They cannot contain
|
||||||
|
tabs or spaces. Only closing punctuation, optionally followed by
|
||||||
|
closing brackets, can end sentences.
|
||||||
.TP
|
.TP
|
||||||
\fBset/unset const\fP
|
\fBset/unset const\fP
|
||||||
Constantly display the cursor position in the status bar.
|
Constantly display the cursor position in the status bar.
|
||||||
@ -90,6 +94,11 @@ feature is turned off.
|
|||||||
\fBset/unset preserve\fP
|
\fBset/unset preserve\fP
|
||||||
Preserve the XON and XOFF keys (^Q and ^S).
|
Preserve the XON and XOFF keys (^Q and ^S).
|
||||||
.TP
|
.TP
|
||||||
|
\fBset punct "\fIstring\fP"\fP
|
||||||
|
Set the characters treated as closing punctuation. They cannot contain
|
||||||
|
tabs or spaces. Only closing punctuation, optionally followed by
|
||||||
|
closing brackets, can end sentences.
|
||||||
|
.TP
|
||||||
\fBset quotestr "\fIstring\fP"\fP
|
\fBset quotestr "\fIstring\fP"\fP
|
||||||
The email-quote string, used to justify email-quoted paragraphs. This
|
The email-quote string, used to justify email-quoted paragraphs. This
|
||||||
is an "extended regular expression" if your system supports them,
|
is an "extended regular expression" if your system supports them,
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
## The directory to put the backup files in.
|
## The directory to put the backup files in.
|
||||||
# set backupdir ""
|
# set backupdir ""
|
||||||
|
|
||||||
|
## The characters treated as closing brackets. They cannot contain tabs
|
||||||
|
## or spaces. Only closing punctuation, optionally followed by closing
|
||||||
|
## brackets, can end sentences.
|
||||||
|
##
|
||||||
|
# set brackets "'")}]>"
|
||||||
|
|
||||||
## Constantly display the cursor position in the status bar.
|
## Constantly display the cursor position in the status bar.
|
||||||
# set const
|
# set const
|
||||||
|
|
||||||
@ -64,6 +70,12 @@
|
|||||||
## Preserve the XON and XOFF keys (^Q and ^S).
|
## Preserve the XON and XOFF keys (^Q and ^S).
|
||||||
# set preserve
|
# set preserve
|
||||||
|
|
||||||
|
## The characters treated as closing punctuation. They cannot contain
|
||||||
|
## tabs or spaces. Only closing punctuation, optionally followed by
|
||||||
|
## closing brackets, can end sentences.
|
||||||
|
##
|
||||||
|
# set punct ".?!"
|
||||||
|
|
||||||
## The email-quote string, used to justify email-quoted paragraphs.
|
## The email-quote string, used to justify email-quoted paragraphs.
|
||||||
## This is an extended regular expression if your system supports them,
|
## This is an extended regular expression if your system supports them,
|
||||||
## otherwise a literal string. Default:
|
## otherwise a literal string. Default:
|
||||||
@ -219,7 +231,7 @@
|
|||||||
## highlight possible errors and parameters
|
## highlight possible errors and parameters
|
||||||
#color brightwhite "^ *(set|unset|syntax|color).*$"
|
#color brightwhite "^ *(set|unset|syntax|color).*$"
|
||||||
## set, unset and syntax
|
## set, unset and syntax
|
||||||
#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view|whitespace)"
|
#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|brackets|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|punct|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view|whitespace)"
|
||||||
#color green "^ *(set|unset|syntax)\>"
|
#color green "^ *(set|unset|syntax)\>"
|
||||||
## colors
|
## colors
|
||||||
#color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
#color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||||
|
@ -67,6 +67,11 @@ openfilestruct *open_files = NULL; /* The list of open files */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
char *punct = NULL; /* Closing punctuation that can end
|
||||||
|
sentences. */
|
||||||
|
char *brackets = NULL; /* Closing brackets that can follow
|
||||||
|
closing punctuation and can end
|
||||||
|
sentences. */
|
||||||
char *quotestr = NULL; /* Quote string. The default value is
|
char *quotestr = NULL; /* Quote string. The default value is
|
||||||
set in main(). */
|
set in main(). */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1902,8 +1902,6 @@ size_t indent_length(const char *line)
|
|||||||
* line[skip + 1] must not be whitespace. */
|
* line[skip + 1] must not be whitespace. */
|
||||||
void justify_format(filestruct *line, size_t skip)
|
void justify_format(filestruct *line, size_t skip)
|
||||||
{
|
{
|
||||||
const char *punct = ".?!";
|
|
||||||
const char *brackets = "'\")}]>";
|
|
||||||
char *back, *front;
|
char *back, *front;
|
||||||
|
|
||||||
/* These four asserts are assumptions about the input data. */
|
/* These four asserts are assumptions about the input data. */
|
||||||
@ -3392,6 +3390,12 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
if (punct == NULL)
|
||||||
|
punct = mallocstrcpy(punct, ".?!");
|
||||||
|
|
||||||
|
if (brackets == NULL)
|
||||||
|
brackets = mallocstrcpy(brackets, "'\")}]>");
|
||||||
|
|
||||||
if (quotestr == NULL)
|
if (quotestr == NULL)
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
quotestr = mallocstrcpy(NULL, "^([ \t]*[|>:}#])+");
|
quotestr = mallocstrcpy(NULL, "^([ \t]*[|>:}#])+");
|
||||||
|
@ -47,6 +47,8 @@ extern int search_offscreen;
|
|||||||
extern int currslen;
|
extern int currslen;
|
||||||
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
extern char *punct;
|
||||||
|
extern char *brackets;
|
||||||
extern char *quotestr;
|
extern char *quotestr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
35
src/rcfile.c
35
src/rcfile.c
@ -43,6 +43,9 @@ const static rcoption rcopts[] = {
|
|||||||
{"autoindent", AUTOINDENT},
|
{"autoindent", AUTOINDENT},
|
||||||
{"backup", BACKUP_FILE},
|
{"backup", BACKUP_FILE},
|
||||||
{"backupdir", 0},
|
{"backupdir", 0},
|
||||||
|
#endif
|
||||||
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
{"brackets", 0},
|
||||||
#endif
|
#endif
|
||||||
{"const", CONSTUPDATE},
|
{"const", CONSTUPDATE},
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
@ -73,6 +76,7 @@ const static rcoption rcopts[] = {
|
|||||||
#endif
|
#endif
|
||||||
{"preserve", PRESERVE},
|
{"preserve", PRESERVE},
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
{"punct", 0},
|
||||||
{"quotestr", 0},
|
{"quotestr", 0},
|
||||||
#endif
|
#endif
|
||||||
{"rebinddelete", REBIND_DELETE},
|
{"rebinddelete", REBIND_DELETE},
|
||||||
@ -152,12 +156,12 @@ char *parse_next_word(char *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The keywords operatingdir, backupdir, fill, tabsize, speller,
|
/* The keywords operatingdir, backupdir, fill, tabsize, speller,
|
||||||
* quotestr, and whitespace take an argument when set. Among these,
|
* punct, brackets, quotestr, and whitespace take an argument when set.
|
||||||
* operatingdir, backupdir, speller, quotestr, and whitespace have to
|
* Among these, operatingdir, backupdir, speller, punct, brackets,
|
||||||
* allow tabs and spaces in the argument. Thus, if the next word starts
|
* quotestr, and whitespace have to allow tabs and spaces in the
|
||||||
* with a ", we say it ends with the last " of the line. Otherwise, the
|
* argument. Thus, if the next word starts with a ", we say it ends
|
||||||
* word is interpreted as usual. That is so the arguments can contain
|
* with the last " of the line. Otherwise, the word is interpreted as
|
||||||
* "s too. */
|
* usual. That is so the arguments can contain "s too. */
|
||||||
char *parse_argument(char *ptr)
|
char *parse_argument(char *ptr)
|
||||||
{
|
{
|
||||||
const char *ptr_bak = ptr;
|
const char *ptr_bak = ptr;
|
||||||
@ -545,6 +549,8 @@ void parse_rcfile(FILE *rcstream)
|
|||||||
|| !strcasecmp(rcopts[i].name, "fill")
|
|| !strcasecmp(rcopts[i].name, "fill")
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
|| !strcasecmp(rcopts[i].name, "punct")
|
||||||
|
|| !strcasecmp(rcopts[i].name, "brackets")
|
||||||
|| !strcasecmp(rcopts[i].name, "quotestr")
|
|| !strcasecmp(rcopts[i].name, "quotestr")
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
@ -589,9 +595,22 @@ void parse_rcfile(FILE *rcstream)
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
if (!strcasecmp(rcopts[i].name, "quotestr"))
|
if (!strcasecmp(rcopts[i].name, "punct")) {
|
||||||
|
punct = mallocstrcpy(NULL, option);
|
||||||
|
if (strchr(punct, '\t') != NULL || strchr(punct, ' ') != NULL) {
|
||||||
|
rcfile_error(_("Non-tab and non-space characters required"));
|
||||||
|
free(punct);
|
||||||
|
punct = NULL;
|
||||||
|
}
|
||||||
|
} else if (!strcasecmp(rcopts[i].name, "brackets")) {
|
||||||
|
brackets = mallocstrcpy(NULL, option);
|
||||||
|
if (strchr(brackets, '\t') != NULL || strchr(brackets, ' ') != NULL) {
|
||||||
|
rcfile_error(_("Non-tab and non-space characters required"));
|
||||||
|
free(brackets);
|
||||||
|
brackets = NULL;
|
||||||
|
}
|
||||||
|
} else if (!strcasecmp(rcopts[i].name, "quotestr"))
|
||||||
quotestr = mallocstrcpy(NULL, option);
|
quotestr = mallocstrcpy(NULL, option);
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (!strcasecmp(rcopts[i].name, "backupdir"))
|
if (!strcasecmp(rcopts[i].name, "backupdir"))
|
||||||
|
Loading…
Reference in New Issue
Block a user