]> Sergey Matveev's repositories - nnn.git/commitdiff
Use string filters by default
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Dec 2019 08:36:00 +0000 (14:06 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Dec 2019 08:45:07 +0000 (14:15 +0530)
README.md
nnn.1
src/nnn.c

index 8264418796cb47f0885b594f16f4541918ec91ee..71f9ff2d8e651c4fe56d4bb7b847dbcc6c91c4bd 100644 (file)
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ Add to that an awesome [Wiki](https://github.com/jarun/nnn/wiki)!
   - By file name, modification/access time, size, extension
 - Search
   - Instant filtering with *search-as-you-type*
-  - Regex (default) and substring match
+  - Regex and substring (default) matches
   - Subtree search to open or edit files (using plugin)
 - Mimes
   - Open with desktop opener or specify a custom app
@@ -189,6 +189,7 @@ optional args:
  -e name load session by name
  -E      use EDITOR for undetached edits
  -f      run filter as cmd on prompt key
+ -g      regex filters [default: string]
  -H      show hidden files
  -i      nav-as-you-type mode
  -K      detect key collision
@@ -197,7 +198,6 @@ optional args:
  -p file selection file [stdout if '-']
  -r      use advcpmv patched cp, mv
  -R      disable rollover at edges
- -s      string filters [default: regex]
  -S      du mode
  -t      disable dir auto-select
  -v      show version
diff --git a/nnn.1 b/nnn.1
index 8130587dc5ba0ef51ce63278d508f08e10d75606..5345ba89b1152f978b8bc1effd8366856483ef1e 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -13,6 +13,7 @@
 .Op Ar -e name
 .Op Ar -E
 .Op Ar -f
+.Op Ar -g
 .Op Ar -H
 .Op Ar -i
 .Op Ar -K
@@ -20,7 +21,6 @@
 .Op Ar -p file
 .Op Ar -r
 .Op Ar -R
-.Op Ar -s
 .Op Ar -S
 .Op Ar -v
 .Op Ar -x
@@ -65,6 +65,9 @@ supports the following options:
 .Fl f
         run filter as command when the prompt key is pressed
 .Pp
+.Fl g
+        use regex filters instead of substring match
+.Pp
 .Fl H
         show hidden files
 .Pp
@@ -89,9 +92,6 @@ supports the following options:
 .Fl R
         disable rollover at edges
 .Pp
-.Fl s
-        use substring match for filters instead of regex
-.Pp
 .Fl S
         start in disk usage analyzer mode
 .Pp
@@ -137,10 +137,9 @@ When a session is loaded dynamically, the last working session is saved automati
 All the session files are located in the \fB${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions\fR directory by the session name.
 "@" is the "last session" file.
 .Sh FILTERS
-Filters support regexes (default) to instantly (search-as-you-type) list the matching
-entries in the current directory.
+Filters are substrings to find matching entries in the current directory instantly (search-as-you-type). There is a program option to use regex filters.
 .Pp
-Common use cases:
+Common regex use cases:
 .Pp
 (1) To list all matches starting with the filter expression, start the expression
 with a '^' (caret) symbol.
@@ -149,8 +148,6 @@ with a '^' (caret) symbol.
 .br
 (3) Use '.*' to match any character (\fIsort of\fR fuzzy search).
 .Pp
-There is a program option to filter entries by substring match instead of regex.
-.Pp
 There is a program option to execute the current filter as a command when the prompt key is pressed.
 .Pp
 In the \fInavigate-as-you-type\fR mode directories are opened in filter mode,
index c0beb5c5e9c723633f0a5b166d53a6958939c583..6629d99ae62a1c353513b49385af1727a446f80c 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -293,7 +293,7 @@ static settings cfg = {
        0, /* useeditor */
        0, /* runplugin */
        0, /* runctx */
-       1, /* filter_re */
+       0, /* filter_re */
        0, /* filtercmd */
        0, /* trash */
        1, /* mtime */
@@ -1804,7 +1804,7 @@ static int visible_str(const fltrexp_t *fltrexp, const char *fname)
        return strcasestr(fname, fltrexp->str) != NULL;
 }
 
-static int (*filterfn)(const fltrexp_t *fltr, const char *fname) = &visible_re;
+static int (*filterfn)(const fltrexp_t *fltr, const char *fname) = &visible_str;
 
 static int entrycmp(const void *va, const void *vb)
 {
@@ -5449,6 +5449,7 @@ static void usage(void)
                " -e name load session by name\n"
                " -E      use EDITOR for undetached edits\n"
                " -f      run filter as cmd on prompt key\n"
+               " -g      regex filters [default: string]\n"
                " -H      show hidden files\n"
                " -i      nav-as-you-type mode\n"
                " -K      detect key collision\n"
@@ -5457,7 +5458,6 @@ static void usage(void)
                " -p file selection file [stdout if '-']\n"
                " -r      use advcpmv patched cp, mv\n"
                " -R      disable rollover at edges\n"
-               " -s      string filters [default: regex]\n"
                " -S      du mode\n"
                " -t      disable dir auto-select\n"
                " -v      show version\n"
@@ -5604,7 +5604,7 @@ int main(int argc, char *argv[])
        bool progress = FALSE;
 #endif
 
-       while ((opt = getopt(argc, argv, "HSKiab:cde:Efnop:rRstvxh")) != -1) {
+       while ((opt = getopt(argc, argv, "HSKiab:cde:Efgnop:rRtvxh")) != -1) {
                switch (opt) {
                case 'S':
                        cfg.blkorder = 1;
@@ -5635,6 +5635,10 @@ int main(int argc, char *argv[])
                case 'f':
                        cfg.filtercmd = 1;
                        break;
+               case 'g':
+                       cfg.filter_re = 1;
+                       filterfn = &visible_re;
+                       break;
                case 'H':
                        cfg.showhidden = 1;
                        break;
@@ -5669,10 +5673,6 @@ int main(int argc, char *argv[])
                case 'R':
                        cfg.rollover = 0;
                        break;
-               case 's':
-                       cfg.filter_re = 0;
-                       filterfn = &visible_str;
-                       break;
                case 't':
                        cfg.autoselect = 0;
                        break;