unison icon indicating copy to clipboard operation
unison copied to clipboard

home and end keys should work in ucm

Open stew opened this issue 3 years ago • 1 comments

we had a user asking how to get their and keys doing expected things at the ucm prompt.

By following this page I was able to get these working by putting the following in my ~/.haskeline:

keyseq: "\ESC[H" home
keyseq: "\ESC[F" end

This accomplishes the desired behaviour, but we should set this up for users by default.

@ChrisPenner says:

If anyone wants an easy contribution I think you just need to convert this to runInputTWithPrefs and pass the appropriate Prefs value:

Main.hs lines 60-62

  Line.runInputT
    settings
    (haskelineCtrlCHandling go)

stew avatar Sep 14 '22 23:09 stew

convert this to runInputTWithPrefs and pass the appropriate Prefs value

What would the appropriate Prefs value be? It wouldn't override the settings that I have in my ~/.haskeline file, would it? Don't you take my historyDuplicates: IgnoreAll or editMode: Vi from me! 😛. But seriously though.

ceedubs avatar Sep 15 '22 00:09 ceedubs

If anyone wants an easy contribution I think you just need to convert this to runInputTWithPrefs and pass the appropriate Prefs value:

You can't build this Prefs value programmatically though because Haskeline's Prefs is not an exported module and not only Prefs is not reexported, which results in the only way to build a Prefs value you need is to readPrefs :: FilePath -> IO Prefs (sic!).

What would the appropriate Prefs value be?

It's the one returned from readPrefs <path_of_the_file_with_these_lines>

It wouldn't override the settings that I have in my ~/.haskeline file, would it?

It seems it would, because https://github.com/judah/haskeline/blob/30aafaf7171ba1f42236eea1d69a3c60af99284d/System/Console/Haskeline/InputT.hs#L175 doesn't fall back to readPrefsFromHome, unless we have appended our custom prefs to the existing user's ~/.haskeline content.

To sum this up: in order to get custom prefs taking into account user's custom prefs we need to create a (temporary?) plaintext prefs file, copy ~/.haskeline content there, add Home & End bindings and supply a path to this file to readPrefs.

IMO this issue should be resolved by reporting appropriate issues against haskeline. Thoughts?

develop7 avatar Oct 10 '22 17:10 develop7

To sum this up: in order to get custom prefs taking into account user's custom prefs we need to create a (temporary?) plaintext prefs file, copy ~/.haskeline content there, add Home & End bindings and supply a path to this file to readPrefs.

Hrmm, yeah that's definitely regrettable.

IMO this issue should be resolved by reporting appropriate issues against haskeline. Thoughts?

Agreed, it does seem like we should be able to set reasonable defaults for our own application.

ChrisPenner avatar Oct 11 '22 15:10 ChrisPenner

Agreed, it does seem like we should be able to set reasonable defaults for our own application.

It's true in general, but IMO this particular issue is out of scope of UCM: the Home & End moving caret to the begin and end of the current line respectively is a default behavior of readline (just checked it by running rltest.c of readlines examples), and therefore haskeline should act same way.

in fact this issue is a exact duplicate of https://github.com/judah/haskeline/issues/30 which is closed at the moment but it apparently shouldn't

develop7 avatar Oct 12 '22 18:10 develop7