mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-23 01:32:06 +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
|
||||
or if we're in tiny mode. (Mike Frysinger; minor changes and
|
||||
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:
|
||||
add_open_file()
|
||||
- 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 whitespace option. (DLR, adapted from
|
||||
documentation by Mike Frysinger)
|
||||
- Document the punct and brackets options. (DLR)
|
||||
- nano.texi:
|
||||
- Fix toggle inaccuracies: Meta-L now toggles line wrapping, and
|
||||
Meta-< and Meta-> aren't toggles. (DLR)
|
||||
|
@ -50,6 +50,10 @@ Create backup files in
|
||||
\fBset backupdir "\fIdirectory\fP"\fP
|
||||
Set the directory where \fBnano\fP puts the backup files if file backups
|
||||
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
|
||||
\fBset/unset const\fP
|
||||
Constantly display the cursor position in the status bar.
|
||||
@ -90,6 +94,11 @@ feature is turned off.
|
||||
\fBset/unset preserve\fP
|
||||
Preserve the XON and XOFF keys (^Q and ^S).
|
||||
.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
|
||||
The email-quote string, used to justify email-quoted paragraphs. This
|
||||
is an "extended regular expression" if your system supports them,
|
||||
|
@ -17,6 +17,12 @@
|
||||
## The directory to put the backup files in.
|
||||
# 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.
|
||||
# set const
|
||||
|
||||
@ -64,6 +70,12 @@
|
||||
## Preserve the XON and XOFF keys (^Q and ^S).
|
||||
# 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.
|
||||
## This is an extended regular expression if your system supports them,
|
||||
## otherwise a literal string. Default:
|
||||
@ -219,7 +231,7 @@
|
||||
## highlight possible errors and parameters
|
||||
#color brightwhite "^ *(set|unset|syntax|color).*$"
|
||||
## 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)\>"
|
||||
## colors
|
||||
#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
|
||||
|
||||
#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
|
||||
set in main(). */
|
||||
#endif
|
||||
|
@ -1902,8 +1902,6 @@ size_t indent_length(const char *line)
|
||||
* line[skip + 1] must not be whitespace. */
|
||||
void justify_format(filestruct *line, size_t skip)
|
||||
{
|
||||
const char *punct = ".?!";
|
||||
const char *brackets = "'\")}]>";
|
||||
char *back, *front;
|
||||
|
||||
/* These four asserts are assumptions about the input data. */
|
||||
@ -3392,6 +3390,12 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
if (punct == NULL)
|
||||
punct = mallocstrcpy(punct, ".?!");
|
||||
|
||||
if (brackets == NULL)
|
||||
brackets = mallocstrcpy(brackets, "'\")}]>");
|
||||
|
||||
if (quotestr == NULL)
|
||||
#ifdef HAVE_REGEX_H
|
||||
quotestr = mallocstrcpy(NULL, "^([ \t]*[|>:}#])+");
|
||||
|
@ -47,6 +47,8 @@ extern int search_offscreen;
|
||||
extern int currslen;
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
extern char *punct;
|
||||
extern char *brackets;
|
||||
extern char *quotestr;
|
||||
#endif
|
||||
|
||||
|
35
src/rcfile.c
35
src/rcfile.c
@ -43,6 +43,9 @@ const static rcoption rcopts[] = {
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
{"backupdir", 0},
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"brackets", 0},
|
||||
#endif
|
||||
{"const", CONSTUPDATE},
|
||||
#ifndef NANO_SMALL
|
||||
@ -73,6 +76,7 @@ const static rcoption rcopts[] = {
|
||||
#endif
|
||||
{"preserve", PRESERVE},
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"punct", 0},
|
||||
{"quotestr", 0},
|
||||
#endif
|
||||
{"rebinddelete", REBIND_DELETE},
|
||||
@ -152,12 +156,12 @@ char *parse_next_word(char *ptr)
|
||||
}
|
||||
|
||||
/* The keywords operatingdir, backupdir, fill, tabsize, speller,
|
||||
* quotestr, and whitespace take an argument when set. Among these,
|
||||
* operatingdir, backupdir, speller, quotestr, and whitespace have to
|
||||
* allow tabs and spaces in the argument. Thus, if the next word starts
|
||||
* with a ", we say it ends with the last " of the line. Otherwise, the
|
||||
* word is interpreted as usual. That is so the arguments can contain
|
||||
* "s too. */
|
||||
* punct, brackets, quotestr, and whitespace take an argument when set.
|
||||
* Among these, operatingdir, backupdir, speller, punct, brackets,
|
||||
* quotestr, and whitespace have to allow tabs and spaces in the
|
||||
* argument. Thus, if the next word starts with a ", we say it ends
|
||||
* with the last " of the line. Otherwise, the word is interpreted as
|
||||
* usual. That is so the arguments can contain "s too. */
|
||||
char *parse_argument(char *ptr)
|
||||
{
|
||||
const char *ptr_bak = ptr;
|
||||
@ -545,6 +549,8 @@ void parse_rcfile(FILE *rcstream)
|
||||
|| !strcasecmp(rcopts[i].name, "fill")
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
|| !strcasecmp(rcopts[i].name, "punct")
|
||||
|| !strcasecmp(rcopts[i].name, "brackets")
|
||||
|| !strcasecmp(rcopts[i].name, "quotestr")
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
@ -589,9 +595,22 @@ void parse_rcfile(FILE *rcstream)
|
||||
} else
|
||||
#endif
|
||||
#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);
|
||||
else
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
if (!strcasecmp(rcopts[i].name, "backupdir"))
|
||||
|
Loading…
Reference in New Issue
Block a user