From c6ecda5b68c7244168134279929dc29f284b3d8c Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 6 Nov 2013 10:56:11 -0600 Subject: [PATCH] make new file|open variant start you out in the module path where the file currently being edited lives --- .../drracket/drracket/private/unit.rkt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/drracket-pkgs/drracket/drracket/private/unit.rkt b/pkgs/drracket-pkgs/drracket/drracket/private/unit.rkt index 44a5cf02a3..790b819e5d 100644 --- a/pkgs/drracket-pkgs/drracket/drracket/private/unit.rkt +++ b/pkgs/drracket-pkgs/drracket/drracket/private/unit.rkt @@ -6,6 +6,7 @@ racket/path racket/port racket/list + racket/match string-constants framework mrlib/name-message @@ -37,6 +38,7 @@ framework/private/aspell framework/private/logging-timer + setup/collects scribble/xref setup/xref scribble/tag @@ -3761,9 +3763,18 @@ [parent file-menu] [callback (λ (x y) + (define editing-path (send (get-definitions-text) get-filename)) + (define editing-module-path + (and editing-path + (match (path->module-path editing-path) + [`(lib ,(? string? s)) + (define m (regexp-match #rx"^(.*/)[^/]*$" s)) + (and m + (list-ref m 1))]))) (define pth (get-module-path-from-user - #:init (preferences:get 'drracket:open-module-path-last-used) + #:init (or editing-module-path + (preferences:get 'drracket:open-module-path-last-used)) #:pref 'drracket:open-module-path-last-used)) (when pth (handler:edit-file pth)))]) (super file-menu:between-open-and-revert file-menu)