Archive for the ‘emacs’ Category

Sharing one .emacs file for both Carbon or Aquamacs and shell emacs without throwing errors

Posted on January 6th, 2011 in emacs | 2 Comments »

I love running Carbon Emacs locally as it gives me the ability to keep everything in one place. Thanks to gleaning much of my friend Pavel’s emacs settings, my emacs fullscreens (white on black) when loaded and gives me such things as the date, time, and battery life at the bottom. I have more colors than shell emacs, can open remote files using tramp, and most importantly can use my command key as meta. Life is good.

Sometimes though, its faster to just SSH right into a remote machine and work from there if I know I’ll be doing a lot of random file accessing / manipulating. The problem is: I’d love to keep all my .emacs preferences (colors, shortcuts, etc) wherever I go without having to maintain two versions.

Syncing is not really the issue here: rsync or dropbox will do the job, but some of my Carbon Emacs settings will throw errors when loading from shell emacs. I talked to the guys in #emacs on freenode on how to specify a different .emacs file for different version of emacs and it looks like you can’t really change where it gets loaded from. Ultimately, the best answer is to just use a when statement right in your preferences file. display-graphic-p is the key here for detecting a window-system-based emacs:

;; load these only if using window-system emacs
(when (display-graphic-p)
  ;; disables scrollbar
  (scroll-bar-mode -1)
  (menu-bar-mode -1)
  ;; disable the top toolbar
  (tool-bar-mode -1)
  (display-battery-mode 1))

Suspend emacs to the background on a remote box

Posted on December 25th, 2010 in emacs | No Comments »

Though emacs has the ability to run a shell inside (three different ones actually), anything that requires more than just a “dumb terminal” doesn’t work as well as I’d like in these emulated terminals. My research in finding a solution has lead to some creative answers such as using tmux (thanks Takashi) which on its own solves and improves tons of daily workflow situations. I, however, will dedicate that topic in it’s entirety to another entry as it does add some optional complexity to your workflow; too much if you’re looking to solve just this one problem.

What I really want to be able to do is to be working in emacs on a remote machine (via ssh) with all my windows and buffers setup and to drop down to shell occasionally to look something up or run some other scripts and then move back to emacs at will. This is easy if you’re running emacs on your local terminal on OS X: just like any other process like top, use C-z to move emacs to a background process and type fg when you want to move it back to the foreground. All your current windows and buffers are resumed. On the two remote machines I’ve tested C-z just moved you to the previous line. I’ve tried unbinding that key combo, but all I get is a terminal beep. After some research and hanging around the #emacs chan (thanks insomniaSalt) the answer is to drop this in your .emacs file. Now C-z will work as it does on your local terminal:

(global-set-key "\C-z" 'suspend-emacs) ; Stops emacs and return to superior process