Skip to content

Instantly share code, notes, and snippets.

@Metaxal
Last active November 8, 2021 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Metaxal/56d288626574debac24b41fb0232bbe1 to your computer and use it in GitHub Desktop.
Save Metaxal/56d288626574debac24b41fb0232bbe1 to your computer and use it in GitHub Desktop.
Reopen the last closed file in DrRacket (quickscript)
#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