# What do people think about the package mode being persistent?

**URL:** https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527
**Category:** General Usage
**Created:** [August 25, 2020, 6:36pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527 "2020-08-25T18:36:33Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [August 25, 2020, 6:36pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/1 "2020-08-25T18:36:33Z")

</div>

The package mode is persistent. Once you hit `]` Julia is in package mode until one hits the backspace.

I find that a bit annoying at times. Especially when I do something in package mode, forget about it, and then try to execute some code in the editor and it pastes it into the package mode making a huge mess.

Any opinions?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [August 25, 2020, 6:39pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/2 "2020-08-25T18:39:43Z")

</div>

You can press up, home and backspace to put what you last wrote into the Julia REPL instead.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [August 25, 2020, 6:45pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/3 "2020-08-25T18:45:43Z")

</div>

Of course. But I mean the case I do

```julia
]st

```

and now I want to type command which is not a package command, and it is not in the history.  
Then, according to my understanding of the workings of the package mode, I have to hit backspace to jump out of the package mode.

---

<div class="post-metadata">

### Author: ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)
#### Post date: [August 25, 2020, 6:53pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/4 "2020-08-25T18:53:36Z")

</div>

I wish it wasn’t. I frequently want to do

```julia
] add SomeNewPackage
using SomeNewPackage

```

and then leave the window alone for a minute. Is there a way to queue up these two commands? I can enter the second one, but the backspace to get out of package mode is not saved, so it doesn’t work.

(I know I can type `using Pkg; Pkg.add("..."` but I don’t.)

---

<div class="post-metadata">

### Author: ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)
#### Post date: [August 25, 2020, 6:54pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/5 "2020-08-25T18:54:02Z")

</div>

I’m fine with this, although I do find it weird that `pkg` persists whereas `shell` does not. That has tripped me up before.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [August 25, 2020, 7:01pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/6 "2020-08-25T19:01:35Z")

</div>

> [@tbeason](#):
>
> I do find it weird that `pkg` persists whereas `shell` does not

This is really strange, and as I do not use the shell I had not perceived until now. I would prefer all modes had the same behaviour.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [August 25, 2020, 7:28pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/7 "2020-08-25T19:28:44Z")

</div>

Yes, this discussion around persistence of modes in the REPL happened in the past. The overall message as far as I remember is that `shell` mode is not persistent to avoid users spending too much time outside Julia writing shell commands when Julia provides most utilities one would need from a shell. The `package` mode on the other hand is more persistent because one is usually interested in typing at least two commands in a workflow: `activate .` and `intantiate`. Also, we usually start a project by typing a bunch of `add Foo`, `add Bar`, so having to re-enter package mode all the time would be annoying.

@PetrKryslUCSD I think your issue is really about the editor or IDE behavior? I have this issue as well now in VS Code where whenever we press `Ctrl+Enter` to send the code to the REPL, it sends it without checking if the REPL is in `package` mode. This wasn’t an issue in Juno for example.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [August 25, 2020, 7:37pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/8 "2020-08-25T19:37:01Z")

</div>

Well, for me the point where I started thinking about this was as I was designing the [https://github.com/PetrKryslUCSD/REPLHistory.jl](https://github.com/PetrKryslUCSD/REPLHistory.jl) package. I realized I couldn’t properly handle  
history that contained `]...` commands. In particular, there is no command to jump out of the package mode (it is a keystroke, not recorded in the command history). So when the history is printed and contains a `]...`, the user must selectively pick the commands to execute. It is not possible to simply copy and paste into the REPL. The package-mode persistence  
will wreak havoc with the execution.

---

<div class="post-metadata">

### Author: ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)
#### Post date: [August 25, 2020, 8:43pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/9 "2020-08-25T20:43:21Z")

</div>

Maybe both of our gripes can be solved by recording the backspace necessary to exit Pkg mode?

---

<div class="post-metadata">

### Author: ![yha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yha/32/3502_2.png) [@yha](https://discourse.julialang.org/u/yha)
#### Post date: [August 25, 2020, 8:47pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/10 "2020-08-25T20:47:53Z")

</div>

> [@juliohm](#):
>
> The overall message as far as I remember is that `shell` mode is not persistent to avoid users spending too much time outside Julia writing shell commands when Julia provides most utilities one would need from a shell.

Interesting. Almost all my use of the REPL shell mode is in the pattern

```julia
]dev SomePackage
(backspace) cd(dirname(Base.find_package("SomePackage")))
;git somecommand
;git somethingelse
...

```

In this pattern, the opposite of the current behavior (only shell mode being persistent) would be the least keystrokes. Even so, I never even noticed the inconsistency between the modes until reading about it now.

---

<div class="post-metadata">

### Author: ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)
#### Post date: [August 25, 2020, 8:49pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/11 "2020-08-25T20:49:28Z")

</div>

Would it be possible to replace `]...` by `pkg"..."` in the history?

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [August 25, 2020, 8:57pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/12 "2020-08-25T20:57:35Z")

</div>

I thought of that. Sort of “do what I meant” instead of “do what I did”.

I think I would have to parse the command and emit a rewrite. Including required use of PackageSpec…

A decent (and much simpler) solution might be to have a command to quit the package mode. I could then emit each package command that starts with `]` followed by a package-mode quitting command.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [August 25, 2020, 9:39pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/13 "2020-08-25T21:39:16Z")

</div>

> [@PetrKryslUCSD](#):
>
> A decent (and much simpler) solution might be to have a command to quit the package mode. I could then emit each package command that starts with `]` followed by a package-mode quitting command.

Yes, this would be great. If it is only for package mode (to return to Julia mode) it should not be too hard to implement, and not break anything.

---

<div class="post-metadata">

### Author: ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)
#### Post date: [August 25, 2020, 9:44pm UTC](https://discourse.julialang.org/t/what-do-people-think-about-the-package-mode-being-persistent/45527/14 "2020-08-25T21:44:53Z")

</div>

Relevant: [https://github.com/JuliaLang/julia/issues/31910](https://github.com/JuliaLang/julia/issues/31910) @BeastyBlacksmith
