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

[playback] choking on column name #2435

Closed
saulpw opened this issue Jun 29, 2024 · 8 comments
Closed

[playback] choking on column name #2435

saulpw opened this issue Jun 29, 2024 · 8 comments
Labels

Comments

@saulpw
Copy link
Owner

saulpw commented Jun 29, 2024

In the attached I'm trying to create a macro that will show Reddit dumps consistently. My goal is to hide all columns but 5 and create an iso column.

https://asciinema.org/a/sKvTyL5MfBqdeZCE5t9xTpOTo

m
C
| ^(author|created_utc|selftext|title|url)$
gt
c width
ge 0
q
c created
= e2iso(created_utc)
^ created
h
-
m

Originally posted by @reagle in #2102 (comment)

@midichef
Copy link
Contributor

The problem is in the commands that are saved in the macro file. The quit command is not saved. That's because quit is in nonLogged:

nonLogged = '''forget exec-longname undo redo quit

Along the same lines, go-* commands are not saved in macros. I wonder if they should be? For people used to macros in vi, it's reasonable to expect.

@reagle
Copy link
Contributor

reagle commented Jun 30, 2024

Oh. I don’t use vi and missed this if this was documented somewhere. From that perspective, and given how important opening and quitting sheets are, I don’t see why those commands wouldn’t be saved. I was trying to create a robust and concise macro via the column sheet. Perhaps I could think of an alternative. Would commands related to sheets be saved? For example, jumping into the previous sheet, or going into the Sheets sheet?

@saulpw
Copy link
Owner Author

saulpw commented Jun 30, 2024

Part of the issue is that macros are almost identical to cmdlogs. I think it works pretty well, but maybe we should ignore the nonLogged check for macros?

Also I think it's reasonable to make sheet quits, if not other movements, to be loggable commands for all cmdlogs. I hoped the sheet/col/row fields would suffice instead of recording the literal go- commands, but I can see how go-col (which takes a regex) might be nice to record by default. As long as we don't wind up recording every arrow key and fidget.

@midichef
Copy link
Contributor

midichef commented Jun 30, 2024

Would commands related to sheets be saved? For example, jumping into the previous sheet, or going into the Sheets sheet?

No, jump-prev is not saved in macros or command logs, because the prefix jump is also in nonLogged:

show error errors statuses options threads jump

But sheets-stack and sheets-all will be saved.

For a solution that you can use right now, you can edit the macro or cmdlog file yourself, to manually add quit-sheet to the command file:
{"sheet": "", "col": "", "row": "", "longname": "quit-sheet", "input": "", "comment": "quit current sheet"}
The macro file would be a .vdj file in visidata_dir, which by default is ~/.visidata/.

@reagle
Copy link
Contributor

reagle commented Jul 1, 2024

Part of the issue is that macros are almost identical to cmdlogs. I think it works pretty well, but maybe we should ignore the nonLogged check for macros?

@saulpw, the exclusion of quit and jump commands explains my failures at the beginning of the year to use VDJ to restore my work. (I then moved to VDS but that leads to duplicated files and a small annoyance #2309).

I think it's reasonable to make sheet quits, if not other movements, to be loggable commands for all cmdlogs. I hoped the sheet/col/row fields would suffice instead of recording the literal go- commands, but I can see how go-col (which takes a regex) might be nice to record by default. As long as we don't wind up recording every arrow key and fidget.

Yes please; I'd err on the side of inclusion. I was using c and r commands to avoid fragile arrow commands, but I still don't see the problem with including any command that might affect things. It might lead to bloated command logs, but that's better than things not working; and in macros, people can take care to use concise pathways.

For a solution that you can use right now, you can edit the macro or cmdlog file yourself, to manually add quit-sheet to the command file

Thanks @midichef, good tip!

@saulpw
Copy link
Owner Author

saulpw commented Sep 1, 2024

I still don't see the problem with including any command that might affect things. It might lead to bloated command logs, but that's better than things not working; and in macros, people can take care to use concise pathways.

In the first implementation, every arrow movement was included, and it was untenable. Not just bloated--movements obscured all other commands, and by a large margin. The whole design of the cmdlog (with sheet/col/row) was my attempt to make the cmdlog meaningful by factoring out these movement commands, so if we're thinking of including them all, we should really consider redesigning the whole thing (maybe we just play back keystrokes).

Before we embark on that, let's add back in the jump- commands and go-col/go-row, etc, and see if we can get a functioning cmdlog with some smaller tweaks.

@reagle
Copy link
Contributor

reagle commented Sep 2, 2024

add back in the jump- commands and go-col/go-row

That'd be appreciated! I wonder if the sidebar could show warning/info about this when a macro command is started?

@anjakefala anjakefala added the 3.1 label Sep 22, 2024
@saulpw
Copy link
Owner Author

saulpw commented Sep 23, 2024

Okay, I made it so that all commands are recorded in a macro (even movements), but kept it as it is with the cmdlog. Also the replay status now shows when a macro is being recorded. Extra help during macro recording would be fine, if someone wants to write a draft that would be appreciated.

@saulpw saulpw closed this as completed Sep 23, 2024
saulpw added a commit that referenced this issue Sep 23, 2024
add even commands nonloggable commands to the current macro when recording.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants