wasamasa / eyebrowse

A simple-minded way of managing window configs in emacs
GNU General Public License v3.0
437 stars 24 forks source link

Command to (not interactively) rename window configuration #43

Closed Andre0991 closed 8 years ago

Andre0991 commented 8 years ago

I would like to automate the creation of window configurations.

This is useful because I try to follow a routine and so, for example, everyday I study a bit of Emacs Lisp. When I do that, I create a specific window configuration: a scratch buffer, a .org buffer with my annotations and a the Emacs Lisp Manual.

Of course, I don't want to create and resize the windows every time so I created a function that creates this specific window configuration:

  (defun window-group-study-emacs-lisp ()
    (interactive)
    (split-window-right-and-focus)
    (split-window-vertically)
    (shrink-window-horizontally 10)
    (enlarge-window 10)
    (find-file "~/Dropbox/ciencia_da_computacao/emacs_lisp.org")
    (evil-window-down 1)
    (switch-to-buffer "*scratch*")
    (emacs-lisp-mode)
    (evil-window-left 1)
    ;; TODO: (bookmark-jump emacs-lisp-intro)
    )

Obviously, I wouldn't need this if I had Emacs open all the time, but sometimes I restart it to test some stuff and then everything is lost.

I created several functions like the above.

Now, what I would like to automate is the creation of eyebrowse window configurations and tag them when I started Emacs.

Something like

  ;; eyebrowse
  (defun start-all-eyebrowse-workspaces ()
    ;; study lisp workspace
    (eyebrowse-switch-to-window-config-1)
    (window-group-study-emacs-lisp)
    (eyebrowse-rename-window-config "Emacs Lisp")

    ;; study blah
    (eyebrowse-switch-to-window-config-2)
    (window-group-study-blah)
    (eyebrowse-rename-window-config "Blah")

    ;; etc
    )

Currently, this is not possible because eyebrowse-rename-window-config has to be called interactively.

Additionally, it would be nice to have a kind of eyebrowse-create-new-window-config function that doesn't depend on any number. It would make it cleaner to adjust the function that creates all window configurations and it would be handy in creating new ones that I use just sporadically. For example, I could a function to create and tag a workspace that I use just on weekends. It would be the n+1 workspace, where n is the number of workspaces before calling it.

Thanks.

wasamasa commented 8 years ago

Regarding your comment about restoring Emacs state: Did you give desktop-mode a try? It is built into Emacs and does even support restoring Eyebrowse window configs.

Andre0991 commented 8 years ago

I've heard about it.

To be honest, I like restarting Emacs and its side effect of closing all dozens of buffers that it had opened (although probably there's a package to close "inactive" buffers).

Maybe I should just change my workflow instead of trying to automatize eyebrowse, I don know.

wasamasa commented 8 years ago

There is indeed a mode for that, midnight-mode. What I'm hinting at is that automating Emacs is difficult to get right. See ecukes for an example.

Nevertheless I do agree with you there that it's silly that the command doesn't expose the new name as its argument. You could work around it by manipulating the data structure eyebrowse is working with directly for the time being...

wasamasa commented 8 years ago

Another option I can imagine is teaching eyebrowse to open an initial set of workspaces, be it with or without names...

Andre0991 commented 8 years ago

Sure, I'll do this for the time being, and modify the function later.

wasamasa commented 8 years ago

Fixed as of 0.6.8.