reddit / emacs
Windows, Frames... great...but sessions?!
[deleted] · 2022-04-24 03:09
One thing I really miss with my Vim + Tmux setup is being able to have multiple sessions running so I can easily switch projects.
At the moment I am using Projectile to switch projects. It kinda works because the buffer list is project specific.
Are there other options?
jcarloz · 2022-04-24 03:27
In doom emacs I use workspaces https://github.com/hlissner/doom-emacs/blob/develop/modules/ui/workspaces/autoload/workspaces.el
[deleted] · 2022-04-24 03:43
Damn. So, I am using normal emacs and building it from scratch.
Is this something I can still use?
mclearc · 2022-04-24 04:09
You might see if this works for you. https://github.com/mclear-tools/tabspaces
thetemp_ · 2022-04-24 04:16
The workspaces module in Doom uses [persp-mode](https://github.com/Bad-ptr/persp-mode.el).
wannaBeTheBestMe · 2022-04-24 04:19
Doom Emacs is a fantastic actively-maintained distribution of Emacs which makes performance improvements (as well as other functional improvements) on vanilla emacs, probably making it faster than your own configuration. The installation process and migrating your config would be simple IMO, so you may want to give it a try... [https://github.com/hlissner/doom-emacs/](https://github.com/hlissner/doom-emacs/)
--Harmony-- · 2022-04-24 04:24
I use exwm and launch different instances or emacs inside exwm.
samsjj · 2022-04-24 05:11
If you are using emacs on terminal with -nw you can still use it with tmux sessions.
You can use VNC server for GUI emacs and can have multiple workspaces.
KrullBorg · 2022-04-24 05:21
Perspective
akirakom · 2022-04-24 08:44
desktop.el is built-in. It allows only one session per Emacs instance at a time, but you can switch between contexts.
Imaltont · 2022-04-24 09:06
Do the built in tabs + projectile work for this purpose, or is the context still not isolated enough with those? Has been part of emacs since 27.1 iirc.
There is also [perspective mode](https://github.com/nex3/perspective-el) that others suggested.
LordOfSwines · 2022-04-24 10:58
Note that emacs also has "project.el" built-in which has project local buffer switching: project-switch-to-buffer (`C-x p b)`
jacmoe · 2022-04-24 12:17
Yes. There's nothing in Doom Emacs that you can't do yourself.
jimehgeek · 2022-04-24 12:40
Would it fair to say that you’re after something that effectively lets you switch between window configurations, similar to how tabs/windows in tmux lets you switch between different sets/panes of terminals?
There’s lots of “workspace” packages for emacs. The most popular is probably `persp-mode`, but there’s also `eyebrowse`, `elscreen`, `escreen` and more. And since Emacs 27.x, there’s also the built-in `tab-bar-mode`.
Personally I use `tab-bar-mode`, and generally give each tab a distinct name based on the project which I’ve got open within that tab. I’ve previously used `persp-mode`, `elscreen`, and `escreen`.
kid_blaze · 2022-04-24 13:18
This. Consistently starts under a second irrespective of number of packages installed owing to aggressive lazy loading and other optimizations in the link below.
https://github.com/hlissner/doom-emacs/blob/master/docs/faq.org#how-does-doom-start-up-so-quickly
So even if you don’t jump ship to doom, you might wanna merge some of these into your DIY distro, hf.
[deleted] · 2022-04-24 13:25
This is exactly what I needed to read. Just watched a vid on Perspective.el too.
amazing
hmeh922 · 2022-04-24 13:37
Second this approach. I don’t use this package but I use a combination of project.el and tab-bar-mode for this purpose and it’s great. I used to use persp-mode but don’t miss it at all. I did have to write some custom code to do it. Maybe this package can replace all that for me. Will take a look.
jimehgeek · 2022-04-24 14:14
Nice, yeah if I recall `persp-mode` is a fork of `perspective.el` with some additional features added. I’ve only tried it briefly myself, but it’s very similar.
If it might help, here’s all the workspace related stuff in my personal config: https://github.com/jimeh/.emacs.d/tree/master/modules/workspaces
I do have a decent number of custom functions and stuff, specially for tab-bar-mode and persp-mode.
Most files in that directory aren’t maintained much right now except for `siren-desktop.el` and `siren-tab-bar.el`. The rest are older thing I used in the past, or briefly tested out and decided we’re promising enough to commit, but not switch to at the time. That said `siren-persp-mode.el` is the most recent file I stopped maintaining, as I switched from persp-mode to tab-bar-mode a bit over a year ago.
00-11 · 2022-04-24 16:09
And if you use [Bookmark+](https://www.emacswiki.org/emacs/BookmarkPlus) then you can easily create [bookmarks to desktops](https://www.emacswiki.org/emacs/BookmarkPlus#DesktopBookmarks) - as many desktops as you like. Jumping to a bookmark puts you in a desktop.
mclearc · 2022-04-24 16:24
Yeah -- basically all that tabspaces does is ensure that you have workspace isolated buffer selection, plus a bunch of helper functions for autonaming tabs based on projects and for adding or removing buffers from tabbed workspaces. But it is all built on project and tab-bar, which is nice. And it also integrates well with consult, if you use that (I think something similar would be true of helm or ivy).
Horrih · 2022-04-24 18:01
I do tmux + emacs in terminal all the time, so unless you want to use some special gui features you don't have to change unless you want to
[deleted] · 2022-04-24 19:30
I was going to test that, but out of the box emacs in the term and tmux key bindings conflict.
I have been using it in the GUI version for that reason.
I am curious, are there any limitations to org mode within the term?
Also, is terminal emacs much different as a platform? I understood emacs to be more than a text editor, so can you leverage its full power in the term?
hmeh922 · 2022-04-24 19:50
Got it. I played around with it a little bit and I don't think I'll use it right now. Some suggestions: Try using whether or not something is a project, rather than whether or not it is has vc to determine whether it warrants a workspace. Also, consider providing a function to open a known project in a new tab. This is what I use:
```
(defun my/project-name (&optional project-root)
"Return the current project name or nil."
(when-let ((project-root (or project-root
(my/project-root))))
(file-name-nondirectory (directory-file-name project-root))))
(defun my/project-root ()
"Return the current project name or nil."
(when-let ((project (project-current)))
(project-root project)))
(defun my/project-tab-switch-project (project-to-switch)
"Switch to project tab and find project file.
Only if the switched to buffer is not of that project."
(interactive (list (project-prompt-project-dir)))
(let* ((new-tab)
(project-name (my/project-name project-to-switch))
(tab-bar-new-tab-choice
(lambda ()
(setq new-tab t)
(unless (string= project-name (my/project-name))
(let ((default-directory project-to-switch))
(project-find-file))))))
(tab-switch project-name)
(tab-rename project-name)
(unless new-tab
(funcall tab-bar-new-tab-choice))))
```
mclearc · 2022-04-24 20:00
Thanks for the feedback!
I don't think we should wed having a workspace to being in a project (maybe we want multiple projects in a workspace or none) but I did think it useful to have the tab named by what is under version control but maybe this isn't the best strategy. As for opening known projects in new tabs there is `tabspaces-switch-to-or-create-workspace`, `tabspaces-open-existing-project-and-workspace`, and `tabspaces-create-new-project-and-workspace`. If you do end up using it more and have any further thoughts just let me know.
samsjj · 2022-04-24 22:49
What key bindings conflict. Are you referring to prefix key in tmux? I have remapped it to ' (backtick) in tmux.conf.
Few features don't work properly on terminal as compared to GUI. Also you may want to turn on (xterm-mouse-mode 1) for terminal.
hmeh922 · 2022-04-25 02:02
Thanks, I'm giving it another shot (and have been sending you a few things via GitHub today...)
Horrih · 2022-04-25 09:00
As said, tmux or emacs keybindings can be changed as needed, but i didn't encounter major conflicts out of the box
And for org mode the main limitation I see is that you can't display images inline or have different font size for headings.
Not an issue for my usage, but it could be for yours