Fork me on GitHub
#emacs
<
2023-12-14
>
Nim Sadeh17:12:48

This might be a silly Emacs question: sometimes when I execute some command in Emacs (e.g., projectile-run-project) it pops up a buffer with some process information about the command, which is fine. After that though, C-x o for changing windows stops working. When I do it all my windows grey out. I have to manually click on the window that popped up, close it, and then it works again. What's that about and how do I get around it without using my mouse?

Nim Sadeh17:12:47

I try C-g but that doesn't fix it either

hiredman18:12:53

does emacs still have focus?

hiredman18:12:17

I ask because some desktops like macos will focus newly launched apps, and it has been a long time since I've used macos but it would sometimes treat the jvm process as an app (even adding an icon for it to the dock) even if there was no gui window for it displayed, and if projectile-run-project starts a jvm maybe emacs isn't in focus anymore which would be why it doesn't respond to the keyboard

Nim Sadeh18:12:30

yea emacs still has focus. It responds to the keybaord

Nim Sadeh18:12:44

It regularly happens after specific commands that I run like that one

oyakushev19:12:45

Do you perhaps have (menu-bar-mode -1) in your config?

oyakushev19:12:57

MacOS doesn't like this

Nim Sadeh19:12:27

I am using Prelude, so I see that it has (menu-bar-mode -1) but that prelude-macos which I am presumably running flips that around (menu-bar-mode +1)

oyakushev19:12:21

So M-: menu-bar-mode says t, right?

Nim Sadeh20:12:51

Not sure where to find that - M-: leads to eval on my machine. I ran toggle menu-bar-mode off and on though

oyakushev20:12:38

Yeah, that's what I mean. If you eval menu-bar-mode, which is also a variable, it says whether it is enabled

oyakushev20:12:33

Well, anyway, if you say that prelude-macos enables it back, then it's not it.

Nim Sadeh20:12:52

Yea it says t

Nim Sadeh22:12:17

Example of what it might look like

Nim Sadeh22:12:27

Another silly Emacs question: adding a new file to a clojure project is a whole level of hell in Emacs, so I must be doing it wrong. I use C-x b to switch to a new buffer, add the namespace declaration, and save it. ONce I do that, everything starts breaking apart. Emacs starts insisting that I import clojure/core.clj, everything starts slowing down to a crawl, and as soon as I type anything into the new file I get error buffers popping. What am I supposed to be doing instead?

dpsutton22:12:26

sounds reasonable to me. i just did exactly that with no issues

hiredman22:12:00

are your projects under a symlink'ed directory, I've had some issues where project mode decided would decide depending on if a file was created using the path through the symlink or not would lead to weird behavior

dpsutton22:12:43

i’ve never seen emacs insist importing clojure/core.clj. and error buffers popping, can you say what errors they are reporting?

Nim Sadeh22:12:33

I probably should have noted them down, but I ended up force quitting emacs and trying again... This time it's OK

Nim Sadeh22:12:40

But something similar happened the time before too

Nim Sadeh22:12:43

It's not symlinked

hiredman22:12:30

what do you mean by emacs insisting you import clojure/core.clj?

hiredman22:12:48

are you running a repl with cider and are you using clojure-lsp?

Nim Sadeh22:12:52

The minibuffer pops up with a range of options including importing clojure/core.clj, and if I don't it just pops up again

hiredman22:12:31

so cider is generally dynamic information (it inspects what is in memory in a running process)

hiredman22:12:53

and clojure-lsp is generally static information (static analysis of the text in the files on disk)

hiredman22:12:16

what lsp client are you using?

Nim Sadeh22:12:48

Isn't Emacs the client in this architecture?

hiredman22:12:41

when you create a new file on disk and add an ns form, but haven't eval'ed it yet, there will be a discrepancy between the static and dynamic view (it exists on disk in a file, but doesn't exist in the repl) and I could in some hand wavy way see some cider plugin in or something not finding the namespace in the repl and some how deciding that means the namespace is missing a require of clojure.core (which, if you create a namespace using in-ns for example, it doesn't automatically have clojure.core required)

hiredman22:12:58

emacs is an editor for which multiple lsp clients exist

hiredman22:12:25

eglot is built into recent releases of emacs, but lsp-mode is I think more popular

Nim Sadeh22:12:43

I am using Prelude, which I think is LSP mode

hiredman22:12:23

the above being said, I don't think cider ever prompts to require a namespace, and cider being clojure specific is more likely to use the correct clojure terminology "require" the namespace "clojure.core", where lsp-mode is more generic and likely to say something like "import" the file "clojure/core.clj"

hiredman22:12:56

so I think it is most likely whatever is going on there is coming from lsp-mode and clojure-lsp

hiredman22:12:52

I use eglot (not lsp-mode) and don't use cider, when I open a new file in the project clojure-lsp sees it and asks eglot if it is ok to add the appropriate ns form to the file, and eglot pops up a "is it ok to edit this file?" in the mini buffer, and that is all that happens

Nim Sadeh22:12:51

How do you open a new file in the project?

Nim Sadeh22:12:01

Do you C-x b or do you touch it in a terminal?

hiredman22:12:02

C-x C-f

3
Nim Sadeh22:12:50

That's find file for me, so I think it needs to exist already?

hiredman22:12:58

C-x b might make a new buffer, which is not a file

hiredman22:12:12

find file will create a file if it doesn't exist

1
dpsutton22:12:19

> (find-file FILENAME &optional WILDCARDS) > > Edit file FILENAME. > Switch to a buffer visiting file FILENAME, creating one if none > already exists.

hiredman22:12:58

a buffer in emacs is a view of some text, which may or may not be associated with the contents of a file

Nim Sadeh22:12:10

Thanks - this all is very new to me but I am determined to get good at it

oyakushev08:12:36

Yep, that was your issue right there. When you C-x b a new buffer, Emacs/CIDER doesn't know you want it to be related to a REPL that's currently running (and which one?). When you create a file with C-x C-f in the directory of a project that has a REPL running, then it's inferred.

2
Nim Sadeh17:12:14

I used C-x C-f and it worked like a charm, thanks!

👍 2