# Does sweeprolog load spurious files?

**URL:** <https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738>\
**Category:** General\
**Created:** [July 24, 2023, 10:43am UTC](https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738 "2023-07-24T10:43:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 24, 2023, 10:43am UTC](https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738/1 "2023-07-24T10:43:48Z")

</div>

Hello, I’m using the new `sweeprolog-mode` in Emacs. When I use `sweeprolog-top-level` (`C-c C-t`) in a project buffer, it brings in buffers that are not related to my project but were opened in the past. For example, when I run the code:  
`source_file(X), atom_prefix(X, '/home')`  
I can see many files that do not belong to my project.  
Is this intentional? And where is this information stored?

---

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 24, 2023, 11:01am UTC](https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738/2 "2023-07-24T11:01:37Z")

</div>

It seems that if I close and reopen emacs the problem goes away, but still I think it should go away when I kill a top-level.

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [July 24, 2023, 11:14am UTC](https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738/3 "2023-07-24T11:14:13Z")

</div>

Hi there,  
In Sweep, each top-level buffer is backed by a separate SWI-Prolog thread, but all these threads as part of the same process and share global resources (such as source\_file/1).  
Hence, top-level buffers are not strongly associated with the project in which you create them.  
That’s something I’d be really interested to improve upon, but the path leading to such per-project top-levels is not that clear. For example, in SWI-Prolog all threads share the same working directory…

---

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 24, 2023, 12:25pm UTC](https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738/4 "2023-07-24T12:25:36Z")

</div>

Thanks @oskardrums, I see the problem; as a stopgap measure, maybe being able to properly kill the prolog process so that we can return at a pristine state would be ok. What do you think? Is this already possible?

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [July 24, 2023, 12:49pm UTC](https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738/5 "2023-07-24T12:49:54Z")

</div>

Yes, `M-x sweeprolog-restart` (or Sweep → Reset Sweep in the menu) should reset the embedded SWI-Prolog runtime.

---

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 24, 2023, 1:58pm UTC](https://swi-prolog.discourse.group/t/does-sweeprolog-load-spurious-files/6738/6 "2023-07-24T13:58:19Z")

</div>

Perfect then, I’ll do that if the need arises. Thank you!
