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.

Wednesday, February 6, 2013

Progress -

On the #emacs irc on freenode. (which is awesome). I was looking for a way to do what I wanted. and I found a package that seems to accomplish 90% of it.

https://github.com/tlh/workgroups.el


All I have to do is get these to update when leaving a frame and remembering the last workgroup, then just load it back, and I am done.

The perfect emacs environment.

Really what I mean is the perfect *terminal* environment, which is also my environment for edited.

Years ago I made a pretty good one, but emacs has grown (v 24) and so have I. So it's time to make something great and make sure to save it.

Here is what I want:

I want emacs to replace: (In short)
My terminal - including using programs like htop and other curses programs.
Tmux - I want all the functionality tmux has, and I think with the right add ons I can get it.
Ssh/ftp - I want emacs to be able (using TRAMP and such) to seamlessly connect and work with my home server and other servers without having to leave my home terminal. And if I need to, have *that* terminal run in emacs.
emacs - Basically this means I want emacs itself to be to the best of it's potential.
My irc client - ERC is great and I don't see why emacs can't fully be used.
Google talk chat - This is a maybe, I have tried this on emacs and enjoyed it a lot, so it will be considered.

What I don't want emacs to replace.

My browser - While good for kicks, w3m-emacs or anything else I've seen doesn't cut it compared to Chrome. Plus I plan to use this in Guake while I view whatever I need to do.
My GUI - I want to live a life with a GUI and a terminal, I am not picking only one.
My operating system - Maybe one day I will mess around with LFS and make a emacs-based OS (with elpa as a package manager) but not yet.

To elaborate, I want these things:
  • Emacs to be able to be detached without closing.
  • Emacs to return to it's old window state when reattaching.
  • Be able to save and switch window configurations like tmux. 
I will return when I have something, bye!