Skip to content

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
My .emacs self installing portable config
:;exec emacs -batch -l "$0" -f nic-custom-self-install "$@"
;;; custom.el --- Nic's custom stuff for Emacs
;; Copyright (C) 2012 Nic Ferrier <>
;; Author: Nic Ferrier <>
;; Keywords: local
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <>.
;;; Commentary:
;; This is an attempt to finally make my emacs config portable.
;; The idea is that you set your init.el up by running the command in
;; here `nic-custom-self-install' which you can do by executing this
;; script as a shell script:
;; bash ./nic-custom.el
;; Doing that makes this script the source of all knowledge. Put all
;; local hacks here or use packages.
;;; Code:
(defconst nic-custom-bootstrap
(list '(load-file
(setq custom-file
(or (buffer-file-name)
"The lisp that will be used for the init.el.")
(defun nic-custom-self-install ()
"Self install this code into init.el"
(let ((fmt-obj
";; Init file installed by niccustom.el
;; End init file"
(car nic-custom-bootstrap)))))
(insert fmt-obj))
(write-file (or user-init-file "~/.emacs.d/init.el"))))
;; I really hate brief-mode's keybinding
(fmakunbound 'brief-mode)
;; No need for any other xml mode
(fset 'xml-mode 'nxml-mode)
(defun ispell-lookup (word)
"Lookup a word in the ispell dictionary.
Just uses the minibuffer to read the word."
(interactive "Mword: ")
(with-current-buffer (get-buffer-create "* ispell-lookup *")
(insert word)
(goto-char (point-min))
(switch-to-buffer-other-window (current-buffer))
(defadvice kill-ring-save (before slick-copy activate compile)
"When called interactively with no active region, copy a single line instead."
(if mark-active (list (region-beginning) (region-end))
(message "Copied line")
(list (line-beginning-position)
(line-beginning-position 2)))))
(defadvice kill-region (before slick-cut activate compile)
"When called interactively with no active region, kill a single line instead."
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
(defadvice server-start
(around nic-custome-detect-existing first activate compile)
"Detect if the Emacs server is already running.
If it's running then don't start it."
(unless (file-exists-p
;; Otto work for groovy, Wolf's gradle code uses 4 wide tabs
(add-to-list 'auto-mode-alist '("\\.gradle" . groovy-mode))
(add-hook 'groovy-mode-hook (lambda () (setq tab-width 4)))
(add-hook 'js-mode-hook (lambda () (linum-mode 1)(flyspell-prog-mode)))
(lambda () (linum-mode 1)(flyspell-prog-mode)(rainbow-mode 1)))
(add-hook 'nxml-mode-hook (lambda () (linum-mode 1)(flyspell-prog-mode)))
'("\\.\\(xml\\|xslt\\|xsd\\|rng\\|xhtml\\|html\\)\\'" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.yml" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.pp" . conf-mode))
(add-to-list 'auto-mode-alist '("\\.rake" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.[^.]+rc" . shell-script-mode))
(add-to-list 'auto-mode-alist '("\\.\\(as\\|asant\\)\\'" . java-mode))
(add-to-list 'auto-mode-alist '("\\(Rakefile\\|Capfile\\)" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.md" . markdown-mode))
;; Use this for stuff which is in the package system and can't be
;; started any other way
(add-hook 'after-init-hook 'cycbuf-init)
;; Some personal keys for things that don't have them
(lambda ()
(call-interactively 'magit-status)))
;;(global-set-key "\M-P" 'mdmua-pull)
(global-set-key (kbd "C-'") 'shell-switcher-switch-buffer)
(global-set-key (kbd "C-x 4 '") 'shell-switcher-switch-buffer-other-window)
(global-set-key (kbd "C-M-'") 'shell-switcher-new-shell)
(require 'uniquify)
(require 'dired-x)
(provide 'nic-custom)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.