]> Sergey Matveev's repositories - nnn.git/commitdiff
Remove file path quoting
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 27 Nov 2018 12:59:46 +0000 (18:29 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 27 Nov 2018 12:59:46 +0000 (18:29 +0530)
README.md
nnn.1
src/nnn.c
src/nnn.h

index c4142ca0241fb37204e2721c365d568fae4d7711..6faccaaf30c88635870c5ae83e770fde55e4e75d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -60,7 +60,6 @@ It runs on Linux, OS X, Raspberry Pi, Cygwin, Linux subsystem for Windows and Te
   - [add bookmarks](#add-bookmarks)
   - [copy file paths](#copy-file-paths)
     - [selection](#selection)
-    - [quote paths](#quote-paths)
     - [to clipboard](#to-clipboard)
   - [cd on quit](#cd-on-quit)
   - [(neo)vim plugin](#neovim-plugin)
@@ -222,17 +221,16 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
     →, ↵, l, ^M  Open file/enter dir   .  Toggle show hidden
               /  Filter          Ins, ^I  Toggle nav-as-you-type
               b  Pin current dir      ^W  Go to pinned dir
-             ^B  Next active context
-          `, ^/  Leader key      LeaderN  Switch to context N
+              d  Toggle detail view   ^B  Next active context
+          `, ^/  Leader key      LeaderN  Go to context N
             Esc  Exit prompt          ^L  Redraw, clear prompt
              ^G  Quit and cd           q  Quit context
           Q, ^Q  Quit                  ?  Help, config
  FILES
              ^O  Open with...          n  Create new
-              D  File details          d  Toggle detail view
-             ^R  Rename entry          r  Open dir in vidir
+              D  File details         ^R  Rename entry
+          ⎵, ^K  Copy entry path       r  Open dir in vidir
           Y, ^Y  Toggle selection      y  List selection
-          ⎵, ^K  Copy entry path      ^T  Toggle path quote
               P  Copy selection        X  Delete selection
               V  Move selection       ^X  Delete entry
               f  Archive entry         F  List archive
@@ -409,15 +407,6 @@ so you can easily handle files together:
     # fish
     ls -ltr (ncp)
 
-##### quote paths
-
-To wrap each file path within single quotes while selecting:
-
-    export NNN_QUOTE_ON=1
-This is particularly useful if you are planning to copy the whole string to the shell to run a command. Quotes can be toggled at runtime using <kbd>^T</kbd>.
-
-Note that the filename is not escaped. So copying may still fail for filenames having quote(s) in them.
-
 ##### to clipboard
 
 Along with default copy, `nnn` can pipe the absolute path of the current file or multiple files to a copier script. For example, you can use `xsel` on Linux or `pbcopy` on OS X.
diff --git a/nnn.1 b/nnn.1
index 91fc2b99ac9190db81cea0c2a405382645de4e9b..1379f80677d531d597ca601ebc475a0576ec5e1b 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -105,8 +105,6 @@ Toggle selection mode
 Copy entry absolute path
 .It Ic y
 Show selection list
-.It Ic ^T
-Toggle path quote
 .It Ic P
 Copy files from selection
 .It Ic V
@@ -296,10 +294,6 @@ files.
     If it's not set, by default file paths are copied to the tmp file \fBDIR/.nnncp\fR, where 'DIR' (by priority) is: \fI$HOME\fR or, \fI$TMPDIR\fR or, \fI/tmp\fR.
 .Ed
 .Pp
-\fBNNN_QUOTE_ON:\fR wrap copied paths within single quotes. Useful for pasting
-names in the shell. Note that the filename is not escaped. So copying may still fail
-for filenames having quote(s) in them.
-.Pp
 \fBNNN_SCRIPT:\fR path to a custom script to invoke with currently selected file name as argument 1.
 .Bd -literal
     export NNN_SCRIPT=/usr/local/bin/nscript
index f7cdbf045e19c9eed3c31bba1b6164a115910907..6904567c80d7b336599b0d4f4a56b2f3a9c4e0c9 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -258,10 +258,9 @@ typedef struct {
        uint showcolor  : 1;  /* Set to show dirs in blue */
        uint dircolor   : 1;  /* Current status of dir color */
        uint metaviewer : 1;  /* Index of metadata viewer in utils[] */
-       uint quote      : 1;  /* Copy paths within quotes */
        uint color      : 3;  /* Color code for directories */
        uint ctxactive  : 1;  /* Context active or not */
-       uint reserved   : 10;
+       uint reserved   : 11;
        /* The following settings are global */
        uint curctx     : 2;  /* Current context number */
        uint picker     : 1;  /* Write selection to user-specified file */
@@ -282,7 +281,7 @@ typedef struct {
 /* GLOBALS */
 
 /* Configuration, contexts */
-static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0};
+static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 4, 1, 0, 0, 0, 0, 0};
 static context g_ctx[MAX_CTX] __attribute__ ((aligned));
 
 static struct entry *dents;
@@ -684,23 +683,10 @@ static bool appendfpath(const char *path, const size_t len)
                }
        }
 
-       if (copybufpos) {
+       if (copybufpos)
                pcopybuf[copybufpos - 1] = '\n';
-               if (cfg.quote) {
-                       pcopybuf[copybufpos] = '\'';
-                       ++copybufpos;
-               }
-       } else if (cfg.quote) {
-               pcopybuf[copybufpos] = '\'';
-               ++copybufpos;
-       }
 
        copybufpos += xstrlcpy(pcopybuf + copybufpos, path, len);
-       if (cfg.quote) {
-               pcopybuf[copybufpos - 1] = '\'';
-               pcopybuf[copybufpos] = '\0';
-               ++copybufpos;
-       }
 
        return TRUE;
 }
@@ -1979,17 +1965,16 @@ static int show_help(char *path)
    "4→, ↵, l, ^M  Open file/enter dir   .  Toggle show hidden\n"
              "e/  Filter          Ins, ^I  Toggle nav-as-you-type\n"
              "eb  Pin current dir      ^W  Go to pinned dir\n"
-            "d^B  Next active context\n"
+             "ed  Toggle detail view   ^B  Next active context\n"
          "a`, ^/  Leader key      LeaderN  Go to context N\n"
            "cEsc  Exit prompt          ^L  Redraw, clear prompt\n"
             "d^G  Quit and cd           q  Quit context\n"
          "aQ, ^Q  Quit                  ?  Help, config\n"
 "1FILES\n"
             "d^O  Open with...          n  Create new\n"
-             "eD  File details          d  Toggle detail view\n"
-            "d^R  Rename entry          r  Open dir in vidir\n"
+             "eD  File details         ^R  Rename entry\n"
+         "a⎵, ^K  Copy entry path       r  Open dir in vidir\n"
          "aY, ^Y  Toggle selection      y  List selection\n"
-         "a⎵, ^K  Copy entry path      ^T  Toggle path quote\n"
              "eP  Copy selection        X  Delete selection\n"
              "eV  Move selection       ^X  Delete entry\n"
              "ef  Archive entry         F  List archive\n"
@@ -2986,23 +2971,6 @@ nochange:
                                        goto nochange;
 
                                ++ncp;
-                               printmsg(newpath);
-                       } else if (cfg.quote) {
-                               g_buf[0] = '\'';
-                               r = mkpath(path, dents[cur].name, g_buf + 1, PATH_MAX);
-                               /* Keep the copy buf in sync */
-                               copybufpos = 0;
-                               appendfpath(g_buf + 1, r);
-
-                               g_buf[r] = '\'';
-                               g_buf[r + 1] = '\0';
-
-                               writecp(g_buf, r + 1); /* Truncate NULL from end */
-                               if (copier)
-                                       spawn(copier, g_buf, NULL, NULL, F_NOTRACE);
-
-                               g_buf[r] = '\0';
-                               printmsg(g_buf + 1);
                        } else {
                                r = mkpath(path, dents[cur].name, newpath, PATH_MAX);
                                /* Keep the copy buf in sync */
@@ -3012,9 +2980,8 @@ nochange:
                                writecp(newpath, r - 1); /* Truncate NULL from end */
                                if (copier)
                                        spawn(copier, newpath, NULL, NULL, F_NOTRACE);
-
-                               printmsg(newpath);
                        }
+                       printmsg(newpath);
                        goto nochange;
                case SEL_COPYMUL:
                        if (!ndents)
@@ -3113,14 +3080,6 @@ nochange:
                        if (cfg.filtermode)
                                presel = FILTER;
                        goto begin;
-               case SEL_QUOTE:
-                       cfg.quote ^= 1;
-                       DPRINTF_D(cfg.quote);
-                       if (cfg.quote)
-                               printmsg("quotes on");
-                       else
-                               printmsg("quotes off");
-                       goto nochange;
                case SEL_OPEN: // fallthrough
                case SEL_ARCHIVE:
                        if (!ndents)
@@ -3569,10 +3528,6 @@ int main(int argc, char *argv[])
        /* Get the clipboard copier, if set */
        copier = getenv("NNN_COPIER");
 
-       /* Enable quotes if opted */
-       if (getenv("NNN_QUOTE_ON"))
-               cfg.quote = 1;
-
        if (getenv("HOME"))
                g_tmpfplen = xstrlcpy(g_tmpfpath, getenv("HOME"), MAX_HOME_LEN);
        else if (getenv("TMPDIR"))
index 0f82937dc7b6ed00c8fab6f8850cfdaeb3416e4a..f6c8a148b37d22f2940d93a86e27a75a4fc0062a 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -75,7 +75,6 @@ enum action {
        SEL_MV,
        SEL_RMMUL,
        SEL_RM,
-       SEL_QUOTE,
        SEL_OPEN,
        SEL_NEW,
        SEL_RENAME,
@@ -210,8 +209,6 @@ static struct key bindings[] = {
        { 'X',   SEL_RMMUL,     "",     "" },
        /* Delete currently selected */
        { CONTROL('X'),   SEL_RM,        "",     "" },
-       /* Toggle quote on while copy */
-       { CONTROL('T'),   SEL_QUOTE,     "",     "" },
        /* Open in a custom application */
        { CONTROL('O'),   SEL_OPEN,      "",     "" },
        /* Create a new file */