Skip to content

Ctrl+Shift+T to open previously closed tabs #508

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

Closed
jestarray opened this issue Sep 10, 2021 · 13 comments
Closed

Ctrl+Shift+T to open previously closed tabs #508

jestarray opened this issue Sep 10, 2021 · 13 comments

Comments

@jestarray
Copy link

It seems like racket has adopted ctrl+T for new tab, ctrl+W for close tab, similar to browsers like ff and chrome, however ctrl+shif+T is not bound to opening a recently closed tab? I've been using ALT+F T for a while now

@rfindler
Copy link
Member

This would be a really good one to add. I often miss it as well. The "File|Open Recent" menu's top most item is an approximation of that, but not exactly the same (it will be the most recently visited tab)

@sorawee
Copy link
Contributor

sorawee commented Sep 10, 2021

FWIW, I created https://docs.racket-lang.org/drracket-restore-workspace/ that implements this functionality (more or less). You need to create a keybinding yourself however.

I believe @Metaxal also implemented something similar with Quickscript.

@sorawee
Copy link
Contributor

sorawee commented Sep 10, 2021

Oh no, I misread the thread, sorry. Mine restores the entire workspace. The requested feature here restores only one tab.

@Metaxal
Copy link
Contributor

Metaxal commented Sep 13, 2021 via email

@squarebat
Copy link
Contributor

I'd like to take this up. I tried looking up the definitions for the keybindings Ctrl - W and Ctrl - T to get an idea of how I might implement it but couldn't find anything in this repo. Could someone point me to it? Thanks!

@rfindler
Copy link
Member

Great, thanks @squarebat !

I think you'll want to pick one of the methods whose name starts with file-menu:between and add code there to get the actual menu in place. (You'll want to add a string-constant for the label.) As for how the callback should work, there needs to be a list somewhere of the files that have been closed, which gets things added and removed to it. It might be best if that lives in the gui repo, in the framework, specifically part of the group abstraction. Then the method callback can call (possibly new) group methods.

There may be other ways to do this, but some combination of those places (or nearby places) is probably a good place to start to figure out how this functionality should fit in.

@squarebat
Copy link
Contributor

Thanks @rfindler! Will look into it and see what works.

@VinayakBector2002
Copy link

Hi @squarebat!
I would like to help you out with this issue! Please let me know where we can connect to collaborate 😄😄

@Metaxal
Copy link
Contributor

Metaxal commented Oct 24, 2021

Here's a quickscript that should do what you want:
https://gist.github.com/Metaxal/56d288626574debac24b41fb0232bbe1

By default you'll get a menu item in Scripts|Utils, but you can also customize it to add a keyboard shortcut.

It will reopen the last opened file in DrRacket that is not currently open (and that still exists on disk). You can call the script multiple times to reopen several files.

(cc @spdegabrielle )

@squarebat
Copy link
Contributor

@VinayakBector2002 thanks! I'll be looking into this issue today/tommorow and let you know what I learn.

@Metaxal i haven't yet experimented with quickscripts myself, I'll be playing around with this one. I'll see if there is a way to enable it as a keybinding by default, the same way ctrl-w and ctrl-t work. Thanks for helping out!

@squarebat
Copy link
Contributor

@Metaxal I added the reopen-last-tab script and tried to use it, however I get the following error every time i run it -

Error in script file "reopen-last-tab.rkt": namespace-attach-module: module not declared (in the source namespace)
module name: #resolved-module-path:"/usr/share/racket/pkgs/drracket/drracket/tool-lib.rkt"

The error was initially a missing import, which was resolved by creating the utils.rkt file for smart-open-file. However, I can't get past the above error. I thought it was a missing module or a faulty declaration, but that doesn't seem to be it. Same error occurs after removing the call to module on line 34 as well. What could be causing it?

@Metaxal
Copy link
Contributor

Metaxal commented Oct 26, 2021

@squarebat You probably have an old version of Racket (the file quickscript/utils.rkt was added in February). If you upgrade to a new version of Racket and revert the script to its original code it should work. Let me know if it doesn't.

@squarebat
Copy link
Contributor

@Metaxal sorry for the delay, couldn't look into this due to exams. I couldn't fix it by upgrading for some reason, but a clean install did the trick! The script works as expected. I will look into how to add that change to the gui repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants