-
Notifications
You must be signed in to change notification settings - Fork 332
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
Add :keys
command to list current key bindings.
#918
Conversation
173a2d4
to
7d77992
Compare
Maybe use |
That's an interesting idea, @pauloue, but I'd rather not. A separate command is easier to remember, for me at least. A somewhat more objective argument is that in That said, it's not a hill I'd be willing to die on. Both are OK options to me. |
This mainly merges gokcehan#924 with @laktak's gokcehan#861. This also merges in the `:keys` command (gokcehan#918) as well as and some unrelated minor corrections (currently dd5dc59).
This mainly merges gokcehan#924 with @laktak's gokcehan#861. This also merges in the `:keys` command (gokcehan#918) as well as and some unrelated minor corrections (currently dd5dc59).
Just rebased this on top of master to get rid of conflicts. |
@ilyagr Thanks for the patch and sorry for late reply. I'm going over past patches as part of #950. I'm hesitant about creating a temporary file for this as we have been trying to remove temporary files (e.g. log files). I haven't looked at this in detail but would it be too difficult to avoid the temporary file? |
19601b0
to
52f4a41
Compare
Well, I do remove the temporary file ASAP. :) I'll look into not using one when I have a moment. I'll need to use lower-level functions. Also, I don't know how well it'll work on Windows and have no way of checking. Otherwise, it sounds totally doable. |
@ilyagr How about exporting an environment variable for this purpose (e.g. |
Is it a good idea to have large(?) env. variable that has to be set for every shell invocation? |
You can pipe stdin to the pager. If no pager is defined just print out everything and let the user scroll back in his terminal. |
439bfcf
to
e5e1f1f
Compare
I prefer @laktak stdin approach, though I could live with the environment variable approach. In some ways, @gokcehan 's approach is more flexible, and a kilobyte-long environment variable shouldn't cause any real problems as far as I can tell. Personally, however, I find such variables a bit unsightly. The extra configuration required seems to be a downside to me that might not be worth the extra flexibility. I'll give this a bit of time in case I (or anyone) has more thoughts and until I have the time to look at the details. |
This outputs the result of [`listBinds`] to a temporary file and then pass it to `$PAGER`. A bit of care is taken to remove the temporary file and refresh lf (just in case it's showing `/tmp`). I haven't tested it on Windows, since `lf` doesn't seem to work on `wine`, but I think it should work there too. It would be a bit more elegant to pipe the output directly to `$PAGER` without a temporary file, but that would require larger code changes, which doesn't seem worth it at the moment. [`listBinds`]: https://github.com/gokcehan/lf/blob/e03143299d4596bbc9bb8a2d8a1b0931e3183410/ui.go#L940
@ilyagr Is there a consensus for this patch? I have read the whole discussion again now. I'm not sure how @laktak 's stdin approach should work but I feel like it is better not to mess with stdin/stdout/stderr. Performance overhead of environment variables is a valid concern but we haven't considered it so far with other things (e.g. we also export all options for each command). I wouldn't expect much performance overhead but it might be worth to measure. There might also be some copy-on-write mechanism in the OS to avoid such overheads. We could also work on minimizing Personally I think the extra configuration required is somehow justified. So far I have tried to keep a single documentation so users would not hesitate where to look for when they need help. And to be completely honest, I also fail to see much benefit for adding a |
I ended up busy with other things, but I mean to come back to this (around Christmas, maybe). I use The stdin approach should work. It would be implemented similar to the These are just some quick thoughts, I haven't reached any conclusions yet. |
@ilyagr With all due respect, why do you have bindings for rarely used commands? Can't you just keep them as named commands if you rarely use them? Or bind them under the same prefix to show as menu? (e.g. |
I've actually been using something similar to @gokcehan's idea for a few years with vim and lf:
With that I can document my config like
and generate my own doc with the previous
I prefer this as it is much nicer to read than looking at the "raw" mapping of |
OK, I think there's not a consensus that this feature should be part of There doesn't seem to be much point to reworking this patch to avoid using a temporary file at this point. For the record, @gokcehan , I have binding for commands that I don't use everyday, but use many times in a row when I do use them. For instance I think the idea of combining help with commands that show the config file is a decent one. I don't like the friction it creates, but I might be able to get used to it. @laktak 's version of this idea is clever, though it might be a bit too much work for me to maintain. Thanks, everyone, for your thoughts and for taking a look! |
This outputs the result of
listBinds
to a temporary fileand then pass it to
$PAGER
. A bit of care is taken to removethe temporary file and refresh lf (just in case it's showing
/tmp
).I haven't tested it on Windows, since
lf
doesn't seem to workon
wine
, but I think it should work there too.It would be a bit more elegant to pipe the output directly to
$PAGER
without a temporary file, but that would require largercode changes, which doesn't seem worth it at the moment.
This is also the first Go code I ever wrote, so let me know if something
could be more idiomatic.
Fixes #916.