Skip to content

Instantly share code, notes, and snippets.

@RichardBarrell
Created July 7, 2015 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardBarrell/756116c9ac41c1c1454b to your computer and use it in GitHub Desktop.
Save RichardBarrell/756116c9ac41c1c1454b to your computer and use it in GitHub Desktop.
# setting ALTERNATE_EDITOR to the empty string "" instructs
# emacsclient to invoke Emacs in daemon-mode iff it isn't running already
export EDITOR=emacsclient
export ALTERNATE_EDITOR=""
; full file is at https://github.com/RichardBarrell/dot_emacs/blob/master/dot_emacs.el
; I cribbed this from somewhere.
(defun alist-insert (alist key value)
"Returns a new alist with (key,value) inserted into it."
(let ((newlist nil) (found nil) k v)
(dolist (e alist)
(setq k (car e))
(setq v (cdr e))
(if (equal k key)
(progn (unless found (setq newlist (cons (cons k value) newlist)))
(setq found t))
(setq newlist (cons (cons k v) newlist))))
(unless found
(setq newlist (cons (cons key value) newlist)))
(reverse newlist)))
; use default-frame-alist to set font rendering parameters because
; they will get picked up next time a frame is created, and if you're
; using Emacs in daemon mode, there often won't *be* any frames that
; exist at the time your .emacs is being evaluated :)
(setq default-frame-alist
(alist-insert default-frame-alist 'font-backend "xft"))
(setq default-frame-alist
(alist-insert default-frame-alist 'font "Source Code Pro-11:regular"))
#!/bin/sh
# this is what I usually run to boot Emacs in the gui
# I have mod4 + F2 bound to run this script
exec emacsclient -c -n -F '((fullscreen . maximized))' "$@"
#!/usr/bin/env python
# open a bunch of files in alternating left/right Emacs buffers
import re, os, os.path, sys
esc = re.compile(r'["\\]')
if __name__ == '__main__':
fs = []
for arg in sys.argv[1:]:
arg = os.path.abspath(arg)
fs.append('(other-window 1)(find-file "%s")' % esc.sub(lambda m: '\\'+m.group(0), arg))
ff = '(progn %s)' % "".join(fs)
os.execvp('emacsclient', ('emacsclient', '-n', '-e', ff))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment