I have written some code to create a new buffer, it starts up in fundamental mode, the buffer is to display output from commands.
I am using this to create the buffer
(get-buffer-create "*My Buffer*")
Then I am trying to switch to and change the mode using this.
(display-buffer buffer-name) (special-mode)
My understanding is that this should switch to the buffer and change the mode which is what actually happens with the added side effect the the original buffer I was using also switches to special-mode so both buffers end up in special-mode.
Am i doing this completely wrong ? how can i create a buffer for command output and change the mode of just that buffer ?
This is the working answer.
(display-buffer buffer-name) (with-current-buffer buffer-name (special-mode))