Open windows and load specific buffers in emacs lisp - emacs

I'm working on my .emacs configuration for clojure development.
What I want to happen is whenever I open a file called "project.clj" if there is no open buffer called "swank", split the window first horizontally then split the right side vertically. Then from the project.clj buffer run (clojure-jack-in) to start the REPL and (shell) to load a bash shell. When all of this is done I'd like the project.clj file to be in the left window, the shell to be in the top right window, and the REPL to be in the bottom right window.
Also if there's a way to get speedbar to open in a specified window rather than in a new frame, that would be awesome.
I guess my question is: is there a way to specify which window new buffers are opened in?

Ok, how about this answer via ibuffer or via grid-files-sq or GridLayout and (more unrelatedly) desktop remembering suggestions

Related

Horizontally Splited Emacs window modifies both windows

I split a file on Emacs using C-x 2.
When I modify the top window, the bottom window gets modified simultaneously.
How can I modify the top window and not the bottom?
You may have confused the concepts of Windows, buffers and files. Although you split Windows, they show the same buffer and changes are synchronized between the two Windows. If you really want to, you need to create a new buffer or file with the same content.

VSCode - Open terminals in a separate window

in VSCode is it possible to open the terminals in a separate window?
So far my research has pointed to a resounding NO but Im curious if anyone has a solution?
Move terminals between windows
It's now possible to move terminals between windows by detaching via
Terminal: Detach Session in one and attaching to another with
Terminal: Attach to Session. In the future this should help enable
cross-window drag and drop!
Lots of changes in v1.58: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_58.md#terminals-in-the-editor-area
For v1.59 moving the terminal changes - including dragging and dropping onto another window, see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_59.md#drag-and-drop-terminals-across-windows
Drag and drop terminals across windows
Drag terminals from the tabs
list or editor area of one window into the tabs list, editor area, or
panel of another window.
Terminals in the editor area
Terminals can now be created in or moved to the editor area, enabling a multi-dimensional grid layout that persists and remains visible regardless of panel state.
To use terminals in the editor area, there are several options:
Create via the Create Terminal in Editor Area command.
Move a terminal from the panel to the editor by dragging and dropping from the tabs list.
Running Move Terminal into Editor Area with a terminal focused.
Moving into the editor area via the terminal tab context menu action.
The new terminal.integrated.defaultLocation setting can be set to editor to direct newly created terminals to the editor area by default.
Please Try:
File > Open New Window
Ctrl+Shift+P > Terminal: Create New Terminal in Editor Area
You can add keybinding to the commands as per your convenience.
i think that the OP wants to create a separate window for the terminal but still have the separated terminal linked to the code editor in the original window (that's what i want too). so that when you run the code in the editor the output is shown in the terminal in the separate window. but if you simply open up a new window of vscode and either open a terminal there or drag and drop the terminal from the original window into the new window, the new terminal is not the same session of the terminal. it is a separate independent unconnected terminal. running the code in the editor does not show output in the new separate terminal. all you have achieved is creating a new unconnected terminal. which you could have just accomplished by opening up a regular terminal window i.e. the one from windows os main menu, no need even to use vscode.
This answer is now outdated. See this answer for instructions on moving terminal panes between VS Code windows. This answer still works but is no longer a necessary workaround.
You can't detach the panes in VSCode, which IMO is a bit of a pain since Visual Studio can detach panes all day long.
There is a workaround though, you can open a new window in VSCode and maximize the terminal pane in that window.
One reason you'd want to do this is to have the Python terminal on a second monitor while still being able to use Python interactively (shift+enter way). Attaching/detaching didn't work for me, nor can you open separate terminals.
What you can do is simply resize your one window across the screen borders! Then right click on the terminal tab/header and click Move panel to the left and voila!
Try Сtrl+Shift+c.
For me, it opens the folder the script is within in a command prompt window.
Create a new window by going to File → New Window.
Open up a new terminal inside of it.
Go to your folder (cd your\projectfolder\path).
And here you are, you have a terminal for your project inside it's own seperate window.
You can change the terminal to be side-by-side instead of below the editor. And then make your window very wide. It is almost as good as having two windows.
Right click on the TERMINAL tab.
Select "Move Views to Side Panel"
Make your window very wide
It seems VS Code allows you to detach the terminal window, but it then will not show the output from the editor of the window you detached it from.
I have spent a while searching, and there is really no workaround other than to just run whatever file you are trying to debug from a separate terminal from the same CWD. This also means you will need to save the file in the window you are editing the file in every time you want to run it. huge pain.
If you are using PowerShell inside the VSCode terminal, why don't you use the PowerShell console from the start menu. It's basically equivalent to using the terminal in separate windows. Hope it helps.Sample

How to copy text from emacs in one screen session to emacs in another screen session in terminal

I use emacs within screen in SSH for most of my work, and would like to be able to copy text from one session to another. I currently use the mouse to select, but this is problematic for three reasons:
Spacing often gets messed up, particularly tabs
I have to get temporarily out of vertical screen split to copy (lest the other half get copied as well)
I can't copy more than one vertical screen's worth of text
And of course, it slows me down by requiring taking my hands off the keyboard. Is there a way to use some command similar to emacs kill-ring buffers to paste between screen sessions with the keyboard?
I have not used screen for years, so I cannot give you a screen based answer, but there is other things you can try:
If emacs are in same machine, use emacs in daemon mode, and emacsclient. Your can have same emacs session across several screen sessions. Since it is the same emacs session, the kill ring is the same and cut and pasting is trivial (your 3 problems are solved). If files are in different hosts, just open them from the same emacs session in one host via ssh (emacs can open remote files using tramp).
Use tmux as a replacement of screen. It is more scriptable and configurable. You can use copy-mode in tmux to copy and paste tmux buffers, that you can select with emacs-like key combos. While those buffers may span across more than one "tmux page", copy-mode is not able to scroll over emacs buffer (it scrolls over tmux buffer). So thos does not solve your #3 problem.
Create a emacs key binding to "paste" a region of file into a temp file (write-region) and another to read from that same file file.

Menu bar flashes for a moment when Emacs starts

With (menu-bar-mode 0) in my .emacs-file, Emacs (in a terminal) seems to be starting with the menu bar visible, and then within a fraction of a second, the bar disappears.
Is there a way to make Emacs not show the menu bar at all?
No: Emacs first starts by setting up its "frame" (which includes some initial display), then reads the .emacs file. That's why you see this flashing of the menu-bar. Emacs could read the .emacs first, but if the .emacs outputs any message or signals an error, there'd only be stderr to display it, whereas with the current setup, those messages are displayed in the minibuffer and the error can be caught in the "normal" way.
If you're runinng Linux (and I guess any system where Emacs runs in an X server), you can use X resources to tell Emacs you don't want the menu bar. Just put this in your ~/.Xresources file:
emacs.menuBar: off
These resources are used to customize frames appearance and are therefore read by Emacs at the very beginning.
See also:
Emacs manual: Menu Bars
Emacs manual: Table of Resources
man xrdb(1)

How do I keep Emacs org-mode from splitting windows?

I'm a new emacs user using emacs for the awesome org-mode. I have links to all my org files at the top of my pages but everytime I click a link it splits my window, so I only have half of the screen estate available. How do I set it so that emacs does not split the window horizontally but rather opens up a new window for my links?
I'm assuming you mean you want to open the link in a new frame. (Emacs terminology is a bit different from other GUI apps, because Emacs predates X11. What would be called a "window" in other apps is called a "frame" in Emacs, because "window" already had a specific meaning in Emacs, and was used in the names of lots of functions.) What's happening now is that you have a frame containing one window, and Emacs is splitting that window to form two windows.
You need to customize org-link-frame-setup to use find-file-other-frame instead of the default find-file-other-window.
You can do this by typing M-x customize-variable <ENTER> org-link-frame-setup <ENTER>. Click the Value Menu next to find-file-other-window and select find-file-other-frame, then click Save for future sessions.
One option is to tell Emacs to never split windows, which can be done like so:
(setq same-window-regexps '("."))
This will keep your window from splitting, and then you use your regular commands to switch buffers to get back to what you were looking at.
This is as opposed to what it sounds like you were asking for, which was new frames, which IMO doesn't really help if you have limited screen real estate because you're now having to switch frames (graphical windows).