tpapp / julia-repl

Run an inferior Julia REPL in a terminal inside Emacs
Other
169 stars 35 forks source link

inferior-version is in else-branch of if-let in julia-repl--locate-live-buffer #141

Open steffenhaug opened 1 year ago

steffenhaug commented 1 year ago

Emacs version 28.2, Julia version 1.9. Issue still in latest master.

https://github.com/tpapp/julia-repl/blob/57a15dfafed680ad7d81f779d414e8cb6717417c/julia-repl.el#L146-L152

I'm not awfully familiar with Emacs, so feel free to correct me if this is not a bug. I don't understand why the (when ...) form is in the else-branch of the if-let. I think this makes the function as a whole always return nil, and my particular issue is that this causes infinite recursion in hooks on julia-repl-hook that calls julia-repl-inferior-buffer, as said function will always take the branch for creating a new buffer (which runs the hooks again).

I assume the intention is for these forms to run sequentially? I fixed this by moving the form into the with-current-buffer-form, but as I'm not very proficient I don't know if there are any bad side effects of this, maybe a progn would be better.

tpapp commented 1 year ago

Yes, that form returns nil.

The intention is that functions run in julia-repl-hook just use the current buffer, and it should be ensured that it is a valid buffer. Hooks should not call julia-repl-inferior-buffer at all.

I clarified this, does 9503ef7 address your question?

steffenhaug commented 1 year ago

Yes, that makes sense. Thank you!