Comments (4)
racket-mode does automatically set current-load-relative-directory
to match the source file, to ensure relative require
s work. But I'm not sure it ought to automatically set current-directory
, as well. Do you think it should? Am I being dense wondering if doing that would cause problems in other cases? e.g. What if you're testing a utility, that works on data in another dir?
BTW, also it depends where your program is intended to find "foo.rkt":
-
Whatever the current directory happens to be?
In that case you may need to change the current working directory. In the racket-mode REPL you can use
,pwd
to see what it is, and,cd
to change it. -
The same directory as the source file?
In that case the program really ought to be the following, which will work regardless of the current directory.
#lang racket (require racket/runtime-path) (define-runtime-path foo.rkt "foo.rkt") (file->string foo.rkt)
from racket-mode.
On IRC zenspider reported the curdir is reset after each run. Maybe this is the same issue.
I think this is because current-directory
is a Racket parameter, and parameters are per-thread.
So this program:
(current-directory (find-system-path 'temp-dir))
(printf "Main thread c-d: ~a\n" (current-directory))
(define thd
(thread
(lambda ()
(current-directory (find-system-path 'home-dir))
(printf "Other thread c-d: ~a\n" (current-directory)))))
(sync thd)
(printf "Main thread c-d: ~a\n" (current-directory))
prints:
Main thread c-d: /tmp
Other thread c-d: /Users/greg/
#<thread:/tmp/foo.rkt:7:3>
Main thread c-d: /tmp
The thing is, the REPL runs your program on its own thread (and custodian). Therefore when that thread changes current-directory
, the value isn't retained, just like in the example above.
I need to think about the best way to handle this.
from racket-mode.
I suspect this is related. I would expect that the pwd
be the same as whatever buffer spawned the process. This would match emacs' other inferior modes.
from racket-mode.
So after mulling this over, and also looking at how DrRacket behaves in this regard, I think the best thing to do is set current-directory
(and current-directory-for-user
and current-load-relative-directory
) to the source file's directory on each Run.
[Note that this doesn't try to do anything about preserving (current-directory)
as it may have been typed in the REPL. On the contrary, on the next Run, the directory will be reset back to that for the source file.]
I'll push a commit with that, to close this issue. However if with that change it's still not behaving as you want, please let me know.
from racket-mode.
Related Issues (20)
- `racket--hash-lang-lookup-pair` can be confused by wrong classification HOT 6
- `racket-hash-lang-mode` should turn off `electric-pair-open-newline-between-pairs`
- Wrapping a region with pairs should not move to end of region HOT 3
- Emacs 30 update `shr-heading`, which breaks `racket-describe` HOT 4
- racket-repl-mode ansi escape code coloring HOT 6
- pretty-print not happening despite `racket-pretty-print` set to `t`? HOT 5
- `racket-repl-goto-error-location` chokes every *even* number of error locations HOT 2
- Using racket-hash-lang-mode with org-mode source blocks HOT 18
- `narrow-to-defun` doesn't work properly HOT 2
- `beginning-of-defun` doesn't work properly when narrowed HOT 6
- FYI: Scribble HTML change HOT 2
- `racket-xp-rename` could use future history
- support macro hiding in racket-stepper mode? HOT 10
- Racket mode is just not working. Can someone please help me? HOT 4
- Identifiers with @ in racket-xp-mode HOT 5
- Regexp-based highlighting of lines HOT 2
- racket-tests/expand-expression passes with racket 8.10 on debian HOT 1
- Length of popup error HOT 2
- Out of range error in narrowed buffer during redisplay using `racket-xp-mode` HOT 7
- REPL: only the first expression/form is evaluated/printed HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from racket-mode.