Domanda

How can I open a new window (for example using C-x 3) into a new buffer, rather than a mirrored buffer that just echoes what I type.

So for example, let's say I'm messing around with python and I want to run the script in the shell. As it is currently I do this: C-x 3, M-x shell and then start it up and running. I'd rather just C-x 3 and it automatically opens into shell. I'm really new to Emacs so I don't know where to look for this.

È stato utile?

Soluzione 2

In emacs it is easy to define custom commands and bind it to keys. For instance, if you add this to your init file:

(defun open-shell-at-left ()
  (interactive)         ;; Tell emacs this function can be called interactively
  (split-window-right)  ;; Just what C-x 3 does
  (shell))              ;; Just what M-x shell does

(global-set-key (kbd "C-c 3") 'open-shell-at-left)

You will have what you want when you type C-c 3. In general, you can find documentation about what a key binding does by typing C-h k and the keybinding. From that point, it is easy to chain existing commands into new ones.

Altri suggerimenti

It sounds to me like this, or something similar, is what you are looking for:

(defun pop-to-buff-at-right (buffer)
  "Pop to BUFFER at the right of the current window."
  (interactive "B")
  (pop-to-buffer buffer '(display-buffer-in-side-window
                          (side . right)
                          (inhibit-same-window . t))))

You do not want to just split the window, which is specifically about showing the same buffer twice. You want to switch to another buffer, but you want it to be displayed to the right of the current window.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top