racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
445 stars 93 forks source link

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

Closed jestarray closed 2 years ago

jestarray commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

Metaxal commented 2 years ago

It should be mostly straightforward to adapt the open-recent quickscript to your needs: https://gist.github.com/Metaxal/0bbd874891442aad78fbd0c08a329cd9

If you do write such a script, it would be great if you could share it on the wiki: https://github.com/racket/racket/wiki/Quickscript-Scripts-for-DrRacket

On Fri, Sep 10, 2021 at 8:13 PM sorawee @.***> wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/racket/drracket/issues/508#issuecomment-917147488, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMU2HF54T5GDJLMTKXKTC3UBJKEDANCNFSM5DZROYQQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

squarebat commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

VinayakBector2002 commented 2 years ago

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

Metaxal commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

@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.