Last active
November 8, 2021 08:45
-
-
Save Metaxal/56d288626574debac24b41fb0232bbe1 to your computer and use it in GitHub Desktop.
Reopen the last closed file in DrRacket (quickscript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require quickscript | |
quickscript/utils | |
racket/class | |
racket/list | |
framework) | |
;;; Author: Laurent Orseau https://github.com/Metaxal | |
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or | |
;;; [MIT license](http://opensource.org/licenses/MIT) at your option. | |
(script-help-string "Reopen the last closed file") | |
(define-script reopen-last-tab | |
#:label "Reopen last tab" | |
#:menu-path ("&Utils") | |
;#:shortcut #\o | |
;#:shortcut-prefix (ctl shift) ; to customize | |
(λ (selection #:frame drfr) | |
; Get the list of recently opened files | |
(define recent (preferences:get 'framework:recently-opened-files/pos)) | |
(define to-open | |
(for/or ([lf (in-list recent)]) | |
(define f (first lf)) | |
; Find the first file is not already opened... | |
(and (not (send drfr find-matching-tab f)) | |
; ... and still exists | |
(file-exists? f) | |
f))) | |
(when to-open | |
(smart-open-file drfr to-open)) | |
#f)) | |
(module url2script-info racket/base | |
(provide filename url) | |
(define filename "reopen-last-tab.rkt") | |
(define url "https://gist.github.com/Metaxal/56d288626574debac24b41fb0232bbe1")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment