Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

«cd -» and tab completion for external programs? #45

Open
formbi-kupiec opened this issue Nov 9, 2018 · 6 comments
Open

«cd -» and tab completion for external programs? #45

formbi-kupiec opened this issue Nov 9, 2018 · 6 comments

Comments

@formbi-kupiec
Copy link

No description provided.

@willghatch
Copy link
Owner

I'm not sure what you mean by “tab completion for external programs”. Do you mean completion for the name of a program, or custom completion for flags and such dependent on the program?

I haven't made the completer function visible to users, and I probably should, in which case you could easily have the former. But completion is currently very limited to the point where you might not want to add it. Right now the completion function only receives the current word under the cursor -- it gets no context to know if it's completing a command name, a file name, etc. So any different completions you run would have to run together. I want to fix this in general by using a new line editor, such as making a line-editor mode for remacs or rmacs, perhaps.

Better completion and line editing is definitely on my radar, though I can't say how soon I'll actually get there.

As for «cd -», FYI you could make your own -- here's a simple sketch:

(require (for-syntax racket/base syntax/parse))
(define last-dir-box (box #f))
(define-line-macro cd/tracking
  (syntax-parser
    #:datum-literals (-)
    [(_ -)
     #'(let ([last-dir (unbox last-dir-box)])
         (set-box! last-dir-box (current-directory))
         (current-directory last-dir))]
    [(_ dir)
     #'(begin
         (set-box! last-dir-box (current-directory))
         (current-directory (format "~a" 'dir)))]))

Then cd/tracking would have the behavior you want (though this basic version probably lacks other features you also want). Perhaps I'll roll that functionality into the default cd.

@formbi-kupiec
Copy link
Author

I mean, for example, that typing «em» and TAB should give «emacs». Your example doesn't work :/

@zlee-personal
Copy link
Contributor

Are you using racket -l rash/repl? Tab completion works for me.

@willghatch
Copy link
Owner

Ok, I've just pushed a commit that adds optional command completion, and I'm going to explain how to turn it on here.

The default completion from now until I replace readline will be path completion. But you can use optional command or racket function completion by doing the following (in your rashrc file):

(require readline/readline)
;; NOTE - this is not stable, and WILL completely go away eventually!
(require rash/private/rashrc-lib)
(set-completion-function! (make-composite-completer complete-paths complete-commands complete-namespaced))

But really just paths is probably what you want until a completer can get some context for what sort of thing it should be completing, or at least an ability to add multiple completion keybindings.

I don't think I'm going to put this in the real docs, because I want to replace it ASAP, and I don't think it's really very useful. Maybe early next year I'll have some time to make a line-editor interface for remacs. Maybe. Sorry it's not better until then.

@rcorrear
Copy link

Hi @willghatch, have you had time to improve this since the last message? Rash looks awesome but (to me) it's not really usable without at least some basic completion. Is there any way I can help? (mind you, I'm not a Scheme dev, just find it very appealing).

@willghatch
Copy link
Owner

willghatch commented Jun 27, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants