Simulate vim marks to mark a page

I want to simulate vim marks to mark a page and return to it later, e.g press Ctrl-m then t to mark current page as t, and when in other pages, press Ctrl-' and t to return to the marked page, is this possible?
I’ve tried following config but it seems the read -s -n1 m part not working correctly and read
nothing in m.

DestroyFunc MarkPage
AddToFunc MarkPage
+ I PipeRead 'read -s -n1 m; echo InfoStoreAdd mark$m "$[page.nx] $[page.ny]"'

DestroyFunc ReturnToPage
AddToFunc ReturnToPage
+ I PipeRead 'read -s -n1 m; echo GotoPage $[infostore.mark$m]'

Key  m  A  C  MarkPage
Key  quoteright  A  C  ReturnToPage

Issue is PipeRead won’t be able to grab any user input. You may have to do something like https://www.fvwm.org/Archive/Faq/#how-can-i-define-emacs-type-multi-keystroke-fvwm-bindings. You will have to decide which marks you want though. Here is my rough idea (though I haven’t tested it so it might need tweaks) (the previous link contains other solutions you can mess with too):

DestroyFunc AddMarkBindings
AddToFunc AddMarkBindings
+ I Key t A A MarkBinding t
+ I Key 1 A A MarkBinding 1

DestroyFunc AddGotoBindings
AddToFunc AddGotoBindings
+ Key t A A GotoBinding t
+ Key 1 A A GotoBinding 1

DestroyFunc DelMarkBindings
AddToFunc DelMarkBindings
+ I Key t A A -
+ I Key 1 A A -

DestroyFunc InitMarkBindings
AddToFunc InitMarkBindings
+ I AddMarkBindings
+ I Schedule 5000 DelMarkBindings

DestroyFunc InitGotoBindings
AddToFunc InitMarkBindings
+ I AddMarkBindings
+ I Schedule 5000 DelMarkBindings

DestroyFunc MarkBinding
AddToFunc MarkBinding
+ I InfoStoreAdd mark$0 "$[page.nx] $[page.ny]"
+ I DelMarkBindings

DestroyFunc GotoBinding
AddToFunc GotoBinding
+ I GotoPage $[infostore.mark$0]
+ I DelMarkBindings

Key  m  A  C  InitMarkBindings
Key  quoteright  A  C  InitGotoBindings

Hi somiaj, thanks for your suggestion. But I want to mark the page on the fly based on the current works on the page, instead of predefine the marks in config file.

I think all I need is a command that can read a key and store it in infostore, something like read -n1.

I’ve just implemented such a rough command and attached it here for anyone who is interested. I have no Xlib development experiences before, so this patch might be buggy, but I’ve tested it for days and it works as expected on my laptop.

You can use it like:

DestroyFunc MarkPage
AddToFunc MarkPage
+ I InfoStoreRead m
+ I InfoStoreAdd mark$[infostore.m] "$[desk.n] $[page.nx] $[page.ny]"

DestroyFunc ReturnToPage
AddToFunc ReturnToPage
+ I InfoStoreRead m
+ I GotoDeskAndPage $[infostore.mark$[infostore.m]]

Key Return  A C MarkPage
Key slash   A C ReturnToPage

Update: fix the patch sharing url.

1 Like