Skip to content

Instantly share code, notes, and snippets.

@tychobrailleur
Created January 12, 2012 10:47
Show Gist options
  • Save tychobrailleur/1599834 to your computer and use it in GitHub Desktop.
Save tychobrailleur/1599834 to your computer and use it in GitHub Desktop.
dot emacs
;; Format a pom file - and pretty much any othe file!
(defun format-pom ()
"formats a pom.xml file"
(interactive)
(progn (indent-region (point-min) (point-max))
(delete-trailing-whitespace)))
(defun untabify-all ()
"untabifies a whole buffer"
(interactive)
(save-excursion
(untabify (point-min) (point-max))))
(defun kill-other-buffers ()
"Kill all other buffers."
(interactive)
(mapc 'kill-buffer
(delq (current-buffer)
(remove-if-not 'buffer-file-name (buffer-list)))))
(defun xml-prettify ()
(interactive)
(save-excursion
(shell-command-on-region (point-min) (point-max) "xmllint --format -" (buffer-name) t)
(nxml-mode)
(indent-region begin end)))
(defun valgrind ()
(interactive)
(compilation-minor-mode)
(define-key compilation-minor-mode-map (kbd "")'comint-send-input)
(define-key compilation-minor-mode-map (kbd "S-")'compile-goto-error))
;; Global parameters
(setq show-paren-mode t)
(setq inhibit-startup-screen t)
(setq custom-file "~/emacs/.custom")
(load custom-file)
;; Remove bars
(custom-set-variables
'(tool-bar-mode nil)
'(menu-bar-mode nil))
;; No backup files
(setq make-backup-files nil)
;; No scratch message
(setq initial-scratch-message nil)
;; CUA mode and useful shortcuts
(cua-mode t)
(global-set-key "\C-l" 'goto-line) ; [Ctrl]-[L]
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
;; Buffer menu, and go to other window
(global-set-key (kbd "\C-x\C-b") 'buffer-menu-other-window)
;; Replace "yes or no" with y or n
(defun yes-or-no-p (arg)
"An alias for y-or-n-p, because I hate having to type 'yes' or 'no'."
(y-or-n-p arg))
;; from http://eden.rutgers.edu/~mangesh/emacs.html
;; Frame title bar formatting to show full path of file
(setq-default
frame-title-format
(list '((buffer-file-name " %f" (dired-directory
dired-directory
(revert-buffer-function " %b"
("%b - Dir: " default-directory)))))))
(setq-default
icon-title-format
(list '((buffer-file-name " %f" (dired-directory
dired-directory
(revert-buffer-function " %b"
("%b - Dir: " default-directory)))))))
;; end
(set-default-font "Monospace-10")
;; nxml mode configuration
(setq nxml-slash-auto-complete-flag t)
;; Shell as cygwin
(if (eq system-type 'windows-nt)
(progn
(defun cygwin-shell ()
"Run cygwin bash in shell mode."
(interactive)
(let ((explicit-shell-file-name "C:/dev/cygwin/bin/bash"))
(call-interactively 'shell)))
(defun toggle-full-screen () (interactive) (shell-command "emacs_fullscreen.exe"))
(global-set-key [f11] 'toggle-full-screen)
)
(progn
;; fullscreen
(defun fullscreen (&optional f)
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
(global-set-key (kbd "<f11>") 'fullscreen))
)
; random colour every hour
(add-to-list 'load-path "~/emacs/color-theme")
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(setq color-theme-is-global t)
;;(color-theme-arjen)
(color-theme-charcoal-black)
))
(defun random-color-theme ()
(interactive)
(random t)
(funcall (car (nth (random (length color-themes)) color-themes))))
;;(random-color-theme)
;;(random-color-theme)
;; Can be used to change colour theme every hour.
;;(run-with-timer 1 (* 60 60) 'random-color-theme)
;; TeX
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(if
(file-exists-p "preview-latex.el")
(load "preview-latex.el" nil t t))
(eval-after-load "tex" '(if
(file-exists-p "~/emacs/frenchb.el")
(load-file "~/emacs/frenchb.el")))
(eval-after-load "tex"
'(add-to-list 'TeX-command-list
'("XeLaTeX" "xelatex -interaction=nonstopmode %s"
TeX-run-command t t :help "Run xelatex") t))
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-PDF-mode t)
(setq font-latex-fontify-sectioning 'color)
(setq font-latex-script-display (quote (nil)))
(custom-set-faces
'(font-latex-subscript-face ((t nil)))
'(font-latex-superscript-face ((t nil)))
)
;;
(setq font-latex-deactivated-keyword-classes
'("italic-command" "bold-command" "italic-declaration" "bold-declaration"))
;;font-latex-deactivated-keyword-classes
;; Scheme interpreter
;;(setq scheme-program-name "scm")
(defun switch-to-minibuffer-window ()
"switch to minibuffer window (if active)"
(interactive)
(when (active-minibuffer-window)
(select-window (active-minibuffer-window))))
(global-set-key (kbd "<f6>") 'switch-to-minibuffer-window)
;; Show the time on the status bar.
(setq display-time-24hr-format t)
(display-time)
(column-number-mode t)
;; re-builder syntax
(require 're-builder)
(setq reb-re-syntax 'string)
;; Line Numbers
(defun add-to-load-path (path-string)
(message (format "Passed %S..." path-string))
(if (stringp path-string)
(when (file-exists-p path-string)
(message (format "Adding %S to load-path..." path-string))
(add-to-list 'load-path (expand-file-name path-string)))
(crs-add-to-load-path (car path-string))
(if (cdr path-string)
(crs-add-to-load-path (cdr path-string)))))
(add-to-load-path (expand-file-name "~/.emacs.d"))
(add-to-load-path (expand-file-name "~/emacs"))
(add-to-list 'load-path "~/.emacs.d/cucumber.el")
(autoload 'feature-mode "feature-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.feature$" . feature-mode))
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-to-list 'load-path "~/emacs/ejacs") ; change this to the real location!
(autoload 'js-console "js-console" nil t)
(setq load-path (cons (expand-file-name "~/.emacs.d/rails-reloaded") load-path))
(require 'rails-autoload)
;; Provide line numbers.
(require 'linum)
(setq linum-format "%d ")
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
;; Tab story
(setq c-basic-offset 4)
(setq tab-width 4)
(setq-default indent-tabs-mode nil)
(defun java-mode-untabify ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward "[ \t]+$" nil t)
(delete-region (match-beginning 0) (match-end 0)))
(goto-char (point-min))
(if (search-forward "\t" nil t)
(untabify (1- (point)) (point-max))))
nil)
(add-hook 'java-mode-hook
'(lambda ()
(make-local-variable 'write-contents-hooks)
(add-hook 'write-contents-hooks 'java-mode-untabify)))
(defun valgrind ()
(interactive)
(compilation-minor-mode)
(define-key compilation-minor-mode-map (kbd "")'comint-send-input)
(define-key compilation-minor-mode-map (kbd "S-")'compile-goto-error))
;; (add-hook 'shell-mode-hook 'valgrind)
;; Start a shell. Not.
;;(shell)
;; Showoff mode
(autoload 'showoff-mode "showoff-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.md$" . showoff-mode))
;; Ruby mode
;loads ruby mode when a .rb file is opened.
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist (cons '(".rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".rhtml$" . html-mode) auto-mode-alist))
(setq ruby-insert-encoding-magic-comment nil)
;; js2-mode
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas/global-mode 1)
;; Custom functions
(if (file-exists-p "~/emacs/custom.el")
(load-file "~/emacs/custom.el"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment