commit f3ecffd24da0dc654408caa976dd7c056225146c
parent f7740178017c91c1e58c4dbab4bbbe9496318baf
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 16 Jun 2005 18:48:30 +0000
add the "regexp" rcfile option back in at DB's suggestion, the
"casesensitive" and "backwards" rcfile options for consistency,
documentation updates, and related cleanups
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2700 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
9 files changed, 58 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -47,13 +47,12 @@ CVS code -
write_file(), write_marked(), die(), do_spell(), and
do_exit(). (DLR)
- Remove the -R/--regexp command line option and enable the
- toggle at the search promptin tiny mode, as it already
+ toggle at the search prompt in tiny mode, as it already
allows the prepend and append toggles at the search prompt.
For consistency, rename TOGGLE_REGEXP_KEY to NANO_REGEXP_KEY,
and move it out of the toggles block to where NANO_PREPEND_KEY
and NANO_APPEND_KEY are. Changes to shortcut_init(), usage(),
- main(), search_init(), nanorc.sample, nano.1, nanorc.5,
- nano.texi, etc. (DLR)
+ main(), search_init(), nano.1, nano.texi, etc. (DLR)
- Various cleanups and improvements in chars.c. Remove some
unnecessary w?ctype wrappers; change the wctype wrappers to
take wint_t instead of wchar_t to match the functions they
@@ -95,9 +94,14 @@ CVS code -
toggle_init(), usage(), do_tab(), main(), nanorc.sample,
nano.1, nanorc.5, and nano.texi. (DLR, suggested by many
people)
+ - Change the REVERSE_SEARCH flag to the BACKWARDS_SEARCH flag.
+ (DLR)
- Change the SMOOTHSCROLL flag to the SMOOTH_SCROLL flag. (DLR)
- Change the NO_UTF8 flag to the USE_UTF8 flag, and reverse its
meaning. (DLR)
+ - Add rcfile options "casesensitive" and "backwards", to do
+ case sensitive and backwards searches by default. Changes to
+ nanorc.sample and nanorc.5. (DLR)
- chars.c:
make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a
@@ -157,6 +161,8 @@ CVS code -
- Allow the mark to be used in view mode, as Pico does. (DLR)
- Clarify the description of ^X when --enable-multibuffer is
used. (DLR)
+ - Change the description of the Meta-B toggle at the search
+ prompt from "Direction" to "Backwards", for consistency. (DLR)
thanks_for_all_the_fish()
- Remove free_toggles() and move its code here verbatim, as it's
only called here anyway. (David Benbennick)
diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5
@@ -6,7 +6,7 @@
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
-.TH NANORC 5 "version 1.3.8" "June 15, 2005"
+.TH NANORC 5 "version 1.3.8" "June 16, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
@@ -51,11 +51,18 @@ Create backup files in
\fBset backupdir "\fIdirectory\fP"\fP
Set the directory where \fBnano\fP puts unique backup files if file
backups are enabled.
+.TP
+\fBset/unset backwards\fP
+Do backwards searches by default.
+.TP
\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 casesensitive\fP
+Do case sensitive searches by default.
+.TP
\fBset/unset const\fP
Constantly display the cursor position in the status bar.
.TP
@@ -122,6 +129,9 @@ Interpret the Delete key differently so that both Backspace and Delete
work properly. You should only need to use this option if Backspace
acts like Delete on your system.
.TP
+\fBset/unset regexp\fP
+Do regular expression searches by default.
+.TP
\fBset/unset smarthome\fP
Make the Home key smarter. When Home is pressed anywhere but at the
very beginning of non-whitespace characters on a line, the cursor will
diff --git a/doc/nanorc.sample b/doc/nanorc.sample
@@ -17,12 +17,18 @@
## The directory to put unique backup files in.
# set backupdir ""
+## Do backwards searches by default.
+# set backwards
+
## 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 "'")}]>"
+## Do case sensitive searches by default.
+# set casesensitive
+
## Constantly display the cursor position in the status bar.
# set const
@@ -91,6 +97,9 @@
## Fix Backspace/Delete confusion problem.
# set rebinddelete
+## Do extended regular expression searches by default.
+# set regexp
+
## Make the Home key smarter. When Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards). If the
diff --git a/src/global.c b/src/global.c
@@ -253,7 +253,7 @@ void shortcut_init(bool unjustify)
#endif
#ifndef NANO_SMALL
const char *case_sens_msg = N_("Case Sens");
- const char *direction_msg = N_("Direction");
+ const char *backwards_msg = N_("Backwards");
#endif
#ifdef HAVE_REGEX_H
const char *regexp_msg = N_("Regexp");
@@ -679,7 +679,7 @@ void shortcut_init(bool unjustify)
NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 10 characters long */
- sc_init_one(&whereis_list, NANO_NO_KEY, direction_msg,
+ sc_init_one(&whereis_list, NANO_NO_KEY, backwards_msg,
IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
@@ -748,7 +748,7 @@ void shortcut_init(bool unjustify)
IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
- sc_init_one(&replace_list, NANO_NO_KEY, direction_msg,
+ sc_init_one(&replace_list, NANO_NO_KEY, backwards_msg,
IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
diff --git a/src/nano.c b/src/nano.c
@@ -1955,7 +1955,7 @@ bool do_int_spell_fix(const char *word)
/* The return value. */
bool case_sens_set = ISSET(CASE_SENSITIVE);
#ifndef NANO_SMALL
- bool reverse_search_set = ISSET(REVERSE_SEARCH);
+ bool backwards_search_set = ISSET(BACKWARDS_SEARCH);
#endif
#ifdef HAVE_REGEX_H
bool regexp_set = ISSET(USE_REGEXP);
@@ -1976,7 +1976,7 @@ bool do_int_spell_fix(const char *word)
#ifndef NANO_SMALL
/* Make sure spell-check goes forward only. */
- UNSET(REVERSE_SEARCH);
+ UNSET(BACKWARDS_SEARCH);
#endif
#ifdef HAVE_REGEX_H
/* Make sure spell-check doesn't use regular expressions. */
@@ -2091,8 +2091,8 @@ bool do_int_spell_fix(const char *word)
#ifndef NANO_SMALL
/* Restore search/replace direction. */
- if (reverse_search_set)
- SET(REVERSE_SEARCH);
+ if (backwards_search_set)
+ SET(BACKWARDS_SEARCH);
#endif
#ifdef HAVE_REGEX_H
/* Restore regular expression usage setting. */
diff --git a/src/nano.h b/src/nano.h
@@ -288,7 +288,7 @@ typedef struct syntaxtype {
#define USE_REGEXP (1<<11)
#define TEMP_FILE (1<<12)
#define CUT_TO_END (1<<13)
-#define REVERSE_SEARCH (1<<14)
+#define BACKWARDS_SEARCH (1<<14)
#define MULTIBUFFER (1<<15)
#define SMOOTH_SCROLL (1<<16)
#define DISABLE_CURPOS (1<<17) /* Damn, we still need it. */
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -41,10 +41,14 @@ const static rcoption rcopts[] = {
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"backupdir", 0},
+ {"backwards", BACKWARDS_SEARCH},
#endif
#ifndef DISABLE_JUSTIFY
{"brackets", 0},
#endif
+#ifndef NANO_SMALL
+ {"casesensitive", CASE_SENSITIVE},
+#endif
{"const", CONSTUPDATE},
#ifndef NANO_SMALL
{"cut", CUT_TO_END},
@@ -79,6 +83,9 @@ const static rcoption rcopts[] = {
{"quotestr", 0},
#endif
{"rebinddelete", REBIND_DELETE},
+#ifdef HAVE_REGEX_H
+ {"regexp", USE_REGEXP},
+#endif
#ifndef NANO_SMALL
{"smarthome", SMART_HOME},
{"smooth", SMOOTH_SCROLL},
diff --git a/src/search.c b/src/search.c
@@ -186,7 +186,7 @@ int search_init(bool replacing, bool use_answer)
#ifndef NANO_SMALL
/* This string is just a modifier for the search prompt; no
* grammar is implied. */
- ISSET(REVERSE_SEARCH) ? _(" [Backwards]") :
+ ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") :
#endif
"",
@@ -235,7 +235,7 @@ int search_init(bool replacing, bool use_answer)
backupstring = mallocstrcpy(backupstring, answer);
return 1;
case TOGGLE_BACKWARDS_KEY:
- TOGGLE(REVERSE_SEARCH);
+ TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
#endif
@@ -311,7 +311,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
* previous or next line. */
rev_start =
#ifndef NANO_SMALL
- ISSET(REVERSE_SEARCH) ? fileptr->data + (current_x - 1) :
+ ISSET(BACKWARDS_SEARCH) ? fileptr->data + (current_x - 1) :
#endif
fileptr->data + (current_x + 1);
@@ -360,7 +360,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
}
#ifndef NANO_SMALL
- if (ISSET(REVERSE_SEARCH)) {
+ if (ISSET(BACKWARDS_SEARCH)) {
fileptr = fileptr->prev;
current_y_find--;
} else {
@@ -377,7 +377,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
return FALSE;
#ifndef NANO_SMALL
- if (ISSET(REVERSE_SEARCH)) {
+ if (ISSET(BACKWARDS_SEARCH)) {
fileptr = filebot;
current_y_find = editwinrows - 1;
} else {
@@ -398,7 +398,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
rev_start = fileptr->data;
#ifndef NANO_SMALL
- if (ISSET(REVERSE_SEARCH))
+ if (ISSET(BACKWARDS_SEARCH))
rev_start += strlen(fileptr->data);
#endif
}
@@ -409,8 +409,8 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
/* Ensure we haven't wrapped around again! */
if (search_last_line &&
#ifndef NANO_SMALL
- ((!ISSET(REVERSE_SEARCH) && current_x_find > beginx) ||
- (ISSET(REVERSE_SEARCH) && current_x_find < beginx))
+ ((!ISSET(BACKWARDS_SEARCH) && current_x_find > beginx) ||
+ (ISSET(BACKWARDS_SEARCH) && current_x_find < beginx))
#else
current_x_find > beginx
#endif
@@ -825,7 +825,7 @@ ssize_t do_replace_loop(const char *needle, const filestruct
* text. Note that current_x might be set to (size_t)-1
* here. */
#ifndef NANO_SMALL
- if (!ISSET(REVERSE_SEARCH))
+ if (!ISSET(BACKWARDS_SEARCH))
#endif
current_x += match_len + length_change - 1;
@@ -1073,12 +1073,12 @@ void do_find_bracket(void)
/* On a left bracket. */
regexp_pat[1] = wanted_ch;
regexp_pat[2] = ch_under_cursor;
- UNSET(REVERSE_SEARCH);
+ UNSET(BACKWARDS_SEARCH);
} else {
/* On a right bracket. */
regexp_pat[1] = ch_under_cursor;
regexp_pat[2] = wanted_ch;
- SET(REVERSE_SEARCH);
+ SET(BACKWARDS_SEARCH);
}
regexp_init(regexp_pat);
diff --git a/src/utils.c b/src/utils.c
@@ -259,7 +259,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
#ifndef NANO_SMALL
- if (ISSET(REVERSE_SEARCH)) {
+ if (ISSET(BACKWARDS_SEARCH)) {
if (regexec(&search_regexp, haystack, 1, regmatches, 0) == 0
&& haystack + regmatches[0].rm_so <= start) {
const char *retval = haystack + regmatches[0].rm_so;
@@ -290,7 +290,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
#if !defined(NANO_SMALL) || !defined(DISABLE_SPELLER)
if (ISSET(CASE_SENSITIVE)) {
#ifndef NANO_SMALL
- if (ISSET(REVERSE_SEARCH))
+ if (ISSET(BACKWARDS_SEARCH))
return revstrstr(haystack, needle, start);
else
#endif
@@ -298,7 +298,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
}
#endif /* !DISABLE_SPELLER || !NANO_SMALL */
#ifndef NANO_SMALL
- else if (ISSET(REVERSE_SEARCH))
+ else if (ISSET(BACKWARDS_SEARCH))
return mbrevstrcasestr(haystack, needle, start);
#endif
return mbstrcasestr(start, needle);