Thursday, February 7, 2013

Perfect emacs, step 1 done.

(Just to be sure, Perfect means perfect *for me*, everyone will have their own perfect dev setup)


I have gotten closer to the perfect emacs setup, I already have had emacs replace tmux and thus my login shell and manager for multiple shells and window.

This has been accomplished totally by using the workgroups package along with some custom elisp functions and .bashrc lines.


Here is my entire init.el file so far;


(workgroups-mode 1) ;; turn on workgroups mode at the start.

(setq wg-morph-on nil) ;; No silly workgroup switching animation


;; Detach function
(defun leave-session ()
  "Leaves session and saves all workgroup states. Will not continue if there is no w\
orkgroups open."
  (interactive)
  (setq last-used-workgroup (wg-current-workgroup))
  (wg-update-all-workgroups)
  (delete-frame)
)
(global-set-key (kbd "") 'leave-session)


This means that when I leave emacs(client) all of my workspaces and pointer positions in them are saved.
And then the rest is done in my .bashrc


function start-emacs() {
    if [ "$TERM" == "eterm-color" ];then
        echo "EMACSEPTION!!!!"
        echo "(Don't run emacs in emacs dawg)"
        return
    fi
    if ./emacs-24.2/lib-src/emacsclient -t -e \
        "(wg-switch-to-workgroup last-used-workgroup)" ; then
        : # Do nothing
    else
        ./emacs-24.2/src/emacs --daemon
        ./emacs-24.2/lib-src/emacsclient -t -e  \
            "(wg-create-workgroup \"Start\")"
    fi
}

alias emacsclient="start-emacs"
alias emacs="start-emacs"

# Allows terminals to run fine *in* emacs.
if [ "$TERM" == "xterm" ];then
    emacs
    exit
fi



What then does is as soon as I login to a ssh session again, I am right where I left off. It is seamless and replaces the need for tmux (or screen or byobu) totally.


You will notice a lot of these things are specific to my installation of emacs (one that I had to compile myself because I don't have root priv on the machine I am ssh'ing into, and they won't update *their* emacs past version 21). If anyone is interested, I will be happy to generalize this and share it on github (I probably will anyway)


So, the next steps for a perfect emacs, as I was coming up with them are below:


Steps for perfect emacs:
 * Install and learn icicles.
 * Setup emacs to automatically use version control for *every* save.           (except when already using git or some *other* vc)
   And *maybe* have one autosave that is different, *maybe*

 * Make binding for common functions, insert-date and compiling code.
 * Find a theme to make Emacs consistent across terminals and themes.
 * Default modes (flyspell, flymake, long-lines) for appropriate buffers.
 * Special way to open files that will open them in their own workspaces. (code will open next to eshell with all the right modes, text will open with flyspell and maybe a thesaurus mode, etc)
 * Learn dired (and if I don't like it, get another file browser for emacs, there are lots)
 * A way to back up all of these settings and load them easily in new computers.


Probably not in that order though, I think the next one to tackle is that auto-version-control everything problem.

Alright everyone, talk to you later.

2 comments:

  1. When you put your Emacs configs on github can you share the link here? :)
    My configs are here https://github.com/ckoch786/dotfiles

    ReplyDelete
    Replies
    1. I plan to put all my config files on github indeed, I just haven't done it yet. Another thing to add to my TODO list.

      Delete