micro icon indicating copy to clipboard operation
micro copied to clipboard

command-edit in scripts

Open ghost opened this issue 1 year ago • 1 comments

Description of the problem or steps to reproduce

i want to turn on relative ruler while executing the jump command. the way i would go about this is as follows: "Ctrl-e": "command:set relativeruler on,command-edit: jump ,command:set relativeruler off"

calling command-edit instantly sends a success state, while expected behavior would be that cancelling the prompt [escape] sends a failure state and completing the prompt [enter] sends a success state

Specifications

Commit hash: d8f7928b OS: Void Linux x86_64 Terminal: urxvt

ghost avatar Sep 05 '24 18:09 ghost

Currently, command and command-edit always return a failure state regardless of the success or failure of the given command. Ideally, they should return the success status of the command? I’m not sure how easy it would be to implement such changes, in any case, you can achieve this with lua.

function myjump(bp)
  rr = bp.Buf.Settings.relativeruler
  bp.Buf.Settings.relativeruler = true
  micro.InfoBar():Prompt("> ", "jump ", "Command", nil, function (resp , canceled)
     if not canceled then
         bp:HandleCommand(resp)
     end
  bp.Buf.Settings.relativeruler = rr
  end)
end

function init()
    config.TryBindKey('yourkey', "lua:initlua.myjump", false)
end

cutelisp avatar Jul 26 '25 21:07 cutelisp