#7 allow tab completion based on '/'

None
closed
None
5
2013-04-17
2010-06-27
Anonymous
No

I assume that like me, many people that use a console, also use *nix utilities. Some of these (specifically, git), don't operate well when given a path containing back slashes.

It would be nice that completion parses slashes as well as back slashes and completes according to the previous ones.

Discussion

  • Horea Haitonic
    Horea Haitonic
    2010-06-28

    I have considered at some point supporting '/' as a path separator; after giving the issue some thought, my conclusion was that it's not worth it. A few reasons:

    • I want to stay as close to cmd.exe as possible, e.g. copy-paste commands from PyCmd into a batch file, etc. Allowing /-separated paths would create a bad habit for the users (at least for me, it would :) from this point of view

    • '/' is used by many windows programs as an option separator. In some cases, /-arguments work even w/out a separating blank (try running 'dir/w', 'cmd/c ls', etc). Since it's virtually impossible to figure out when this is the case, treating the / as a path separator would be confusing/misleading/plain wrong in some situations.

    • if you want to use forward slashes, there's mingw or cygwin; unfortunately, going that way requires the user to give up -separated paths and internal commands. But my feeling is that you can have either one way or the other -- mixing would add confusion and inconsistency; better try to create a good and consistent habit, in my opinion.

    On the other hand, I use git myself and I thought it works well with -separated paths. Can you give some examples where it doesn't? I'm not talking about specifying URLs, as PyCmd cannot possibly complete those correctly by only looking at the filesystem (some smart, custom completion like the fish shell has would be able to do that for you -- but that's a completely different story and a whole new level of implementation complexity)

     

  • Anonymous
    2010-07-13

    git checkout core\pom.xml
    cygwin warning:
    MS-DOS style path detected: .git/core\pom.xml
    Preferred POSIX equivalent is: .git/core/pom.xml
    CYGWIN environment variable option "nodosfilewarning" turns off this warning.
    Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
    error: pathspec 'core\pom.xml' did not match any file(s) known to git.

     
  • D:\Users\h\tup3> git checkout src\tup\parser.c

    D:\Users\h\tup3>

    Backslashes seem to work fine with my version of git. Not sure about what's different, I don't remember doing any kind of customization.

    Nevertheless, I am now reconsidering supporting forward slashes -- just at the Tab-completion level, w/out any kind of under-the-hood replacing of '\' with '/' prior to executing the command. Would this fit you well enough?

     
  • Blackwell
    Blackwell
    2011-09-14

    Hello.

    I often copy and paste paths presented by Git, and Git outputs paths with /. Further completion on such copied paths is then not possible with PyCmd.

    Couldn't PyCmd extract the last space separated token, note the existence of /, internally replace / with \ and then complete based on that?

    I agree that the effort for this feature should not be excessive, but I am still hoping that a minimal code effort (it should be so minimal to hardly affects reading and understanding the completion code I guess) could result in something usable.

     
  • Brandon McCaig
    Brandon McCaig
    2012-07-30

    I primarily started using PyCmd for the sensible tab completion and history recall. I don't bother with MSYS shells because they don't give you an adequate experience and it's useful to know the cmd.exe commands for other people's systems. In any case, I still use MSYS tools (just add the bin dirs to my PATH), but some of them require UNIX-like paths to work. So I am forced to type the path out manually because tab completion doesn't work in PyCmd for slash-based paths. I don't see any harm from allowing tab completion of slash-based paths. Tab completion doesn't work for Windows-style switches anyway so you're not going to attempt to tab complete them. Also, since I switch back and forth between GNU/Linux and Windows (forcibly) I find myself in GNU/Linux attempting to use backslash-based paths and that interrupts me. If I could use slash-based paths in PyCmd then I could be consistent everywhere. I see no reason not to allow it..

     
  • Horea Haitonic
    Horea Haitonic
    2013-03-21

    I guess the advantages are bigger than the drawbacks, so I gave this a go.

    Snapshots from 21.03.2013 should use '/' to complete if the token to be completed contains a '/'

     
    • Brandon McCaig
      Brandon McCaig
      2013-03-22

      Seems to work for me! Thanks!

      Looking at the patch I wonder how hard it would be to accept a combination of both separators rather than choosing between either/or. I don't really understand exactly what is happening there though. Perhaps a copy could be made, replace slashes with backslashes, and figure out the next completion bit and add that to the original. That's a bit brute forced, but it might be the shortest quick fix.

      It seems pretty legit to end up with a path that has a mix of path separators (e.g., maybe part is from an environment variable or clipboard). Python isn't my thing, but I'll give it a shot if I find the time...

       
  • Horea Haitonic
    Horea Haitonic
    2013-03-22

    How about this behavior: always use the last separator (either \ or /) when completing.

    This would mean that you can complete like this:

    d:\users\horea\wo<Tab> ===> d:\users\horea\work
    d:/users/horea/wo<Tab> ===> d:/users/horea/work
    d:\users\horea/wo<Tab> ===> d:\users\horea/work
    d:/users\horea/wo<Tab> ===> d:/users\horea/work
    d:\users\horea\/wo<Tab> ===> d:\users\horea\/work

    I think this would nicely support most of the use cases while avoiding changing the existing input; and the completed paths seem to be accepted by most commands (I was surprised to find out that paths like "d:\//\Users\horea\///\src" are happily accepted by cd, ls, git etc.).

    Also, this is very easy to implement :D (I already implemented it, for the sake of playing with it; after some small code cleanup it could be readily committed).

     
  • Horea Haitonic
    Horea Haitonic
    2013-03-29

    Are you still interested in this topic, Brandon? What's your opinion on the behavior I suggested above?

     
  • Brandon McCaig
    Brandon McCaig
    2013-03-30

    Sorry for the late reply. I have been exhausted lately. :)

    On Fri, Mar 22, 2013 at 08:12:49AM +0000, Horea Haitonic wrote:

    How about this behavior: always use the last separator (either
    \ or /) when completing.

    This would mean that you can complete like this:

    d:\users\horea\wo<Tab> ===> d:\users\horea\work
    d:/users/horea/wo<Tab> ===> d:/users/horea/work
    d:\users\horea/wo<Tab> ===> d:\users\horea/work
    d:/users\horea/wo<Tab> ===> d:/users\horea/work
    d:\users\horea\/wo<Tab> ===> d:\users\horea\/work

    I think this would nicely support most of the use cases while
    avoiding changing the existing input; and the completed paths
    seem to be accepted by most commands (I was surprised to find
    out that paths like "d:\//\Users\horea\///\src" are happily
    accepted by cd, ls, git etc.).

    Also, this is very easy to implement :D (I already implemented
    it, for the sake of playing with it; after some small code
    cleanup it could be readily committed).

    I'm not sure I understand how it works. It sounds like we're
    basically in agreeance, and discussing implementation details
    now. I may be wrong. If so please clarify. :) Since the work is
    already basically done then it's certainly worth a try. :)

    Regards,

    --
    Brandon McCaig bamccaig@gmail.com bamccaig@castopulence.org
    Castopulence Software https://www.castopulence.org/
    Blog http://www.bamccaig.com/
    perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
    q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
    tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

     
    • Horea Haitonic
      Horea Haitonic
      2013-04-03

      I have committed the change; please get a snapshot >= 20130403 and let me know if it works as expected.

       
  • Brandon McCaig
    Brandon McCaig
    2013-04-03

    On Wed, Apr 03, 2013 at 03:42:15PM +0000, Horea Haitonic wrote:

    I have committed the change; please get a snapshot >= 20130403
    and let me know if it works as expected.

    Seems to work just fine for me. :) Thanks.

    Regards,

    --
    Brandon McCaig bamccaig@gmail.com bamccaig@castopulence.org
    Castopulence Software https://www.castopulence.org/
    Blog http://www.bamccaig.com/
    perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
    q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
    tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

     
  • Horea Haitonic
    Horea Haitonic
    2013-04-17

    • status: open --> closed
    • assigned_to: Horea Haitonic
    • Group: -->