;;; -*- mode: lisp; mode: folding; indent-tabs-mode: nil -*- ;;{{{ LICENSE ;; Copyright (C) 2005 - Ian Zerny, and others where mentioned. ;; If I have wrongfully forgotten to give credit to the original ;; source of something please do inform me of the mistake. ;; ;; This file is free software. You may redistribute it and/or modify ;; it under the terms of the GNU General Public License, version 2 or ;; later as published by the Free Software Foundation. ;; ;; The file is distributed AS IS and WITHOUT ANY WARRANTY. I hope you ;; will find it useful and I welcome feedback and ;; modifications/improvements. ;;}}} ;;; This file contains my configuration for Emacs. ;; ;; The configuration section are grouped with folding-mode. To ;; expand/collapse sections place the point on the section title and ;; right-click or use: C-c @ C-q ;; ;; Note on customizing Emacs. ;; In order to keep it safe, consider putting your configuration in ;; a configuration directory and then symlinking it to the correct ;; location. This way it is easy to make backups and you wont forget ;; the hidden .emacs file the next time you format your drive. ;; (This applies to configuration of other programs too) ;; ;; This is my layout with sym-links from my $HOME dir: ;; $HOME/.emacs -> $HOME/doc/conf/emacs/dot-emacs.el ;; ;; There are many good resources for Emacs. Some that I frequently ;; use are: ;; ;; The official GNU Emacs homepage ;; http://www.gnu.org/software/emacs/ ;; ;; Community Emacs Wiki ;; http://www.emacswiki.org ;; ;;{{{ Setup ;; To make further customizing easier a few variables are defined ;; about the setup structure. (defvar emacs-cvs (string-equal emacs-version "23.0.60.3") "Mark if we are using a custom build emacs.") (defvar emacs-dir (concat (getenv "HOME") "/doc/conf/emacs/") "Directory root for your Emacs stuff.") ;; if you wish to add a new library to emacs just place the dot-el ;; file in this directory and you should then be able to load it. (defvar site-packages-dir (concat emacs-dir "site-packages/") "Directory for additional packages.") ;; add the packages directory to the search path. (add-to-list 'load-path site-packages-dir) ;; hook on to the debian setup to use apt-get packages. ;; this is only needs as I am running a custom built emacs. ;; this adds a dummy path to suppress an error because ;; debian-pkg-add-load-path-item assumes that there exists a ;; /usr/local path in load-path. ;; it also calls debian-startup two times to please debians setup (when emacs-cvs (add-to-list 'load-path "/usr/local/emacs/site-list") (load-file "/usr/share/emacs/site-lisp/debian-startup.el") (debian-startup 'emacs) (debian-startup 'emacs)) ;;}}} ;;{{{ Miscellaneous customizations ;; This section contains miscellaneous customizations that have no ;; other logical home. ;; ;; Requirements: None (setq inhibit-startup-message t) ; dont show the GNU splash screen (transient-mark-mode t) ; show selection from mark (menu-bar-mode -1) ; disable menu bar (mouse-avoidance-mode 'jump) ; jump mouse away when typing (setq visible-bell 1) ; turn off bip warnings (show-paren-mode t) ; turn on highlight paren mode (auto-compression-mode 1) ; browse tar archives (put 'upcase-region 'disabled nil) ; enable ``upcase-region'' (put 'set-goal-column 'disabled nil) ; enable column positioning (setq case-fold-search t) ; make search ignore case (fset 'yes-or-no-p 'y-or-n-p) ;; interactive DO mode (better file open and buffer switching) ;;(ido-mode 1) ;; set window title (setq frame-title-format '("" "%b @ %f")) ;; set smooth scroll (setq scroll-step 1 scroll-conservatively 10000) ;; get rid of all those irritating semantic cache files! ;; (semantic mode is a dependency of the cedet package) (when (locate-library "semantic") (let ((semcach (concat (getenv "HOME") "/local/semantic-cache"))) (unless (file-directory-p semcach) (make-directory semcach)) (setq semanticdb-default-save-directory semcach))) ;; add ~user/bin to the path if it exists (when (and (not (string-match (concat (getenv "HOME") "/bin") (getenv "PATH"))) (file-directory-p (concat (getenv "HOME") "/bin"))) (setenv "PATH" (concat (getenv "HOME") "/bin:" "/opt/cell/toolchain/bin:" (getenv "PATH")))) ;; rebind quit emacs to C-x-q (I keep hitting C-x-c by accident) (global-unset-key [(control x)(control c)]) (global-set-key [(control x)(control q)] 'save-buffers-kill-emacs) (when (locate-library "column-marker") (require 'column-marker) (column-marker-1 80)) ;; enable ansi color output in shell (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) (add-hook 'before-save-hook 'time-stamp) ;;}}} ;;{{{ Helper functions ;;; Commentary ;; ;; This section contain some functions that I find useful ;;; Reload Emacs config ;; By http://www.emacswiki.org/cgi-bin/wiki/JesseWeinstein (defun load-.emacs () "Runs load-file on ~/.emacs" (interactive) (load-file "~/.emacs")) ;;; Scroll line-by-line ;; ;; Used to make scroll-wheel/track-point work. ;; see x11 loader (defun scroll-up-one-line () (interactive) (scroll-up 1)) (defun scroll-down-one-line () (interactive) (scroll-down 1)) ;;; Kill many buffers stuff (defun kill-mode-buffer (mode) "Kills current buffer when major mode is MODE." (if (eq (cdr (assoc 'major-mode (buffer-local-variables))) mode) (kill-buffer (current-buffer)))) (defun kill-mode-buffers () "Kills all buffers with same major mode." ;; (interactive "SMode: ") (interactive) (let ((mode (cdr (assoc 'major-mode (buffer-local-variables))))) (mapc (lambda (buffer) (progn (set-buffer buffer) (kill-mode-buffer mode))) (buffer-list)))) (defun kill-all-buffers () "Kills all emacs buffers." (interactive) (mapc (lambda (b) (kill-buffer b)) (buffer-list))) (defun zsh (&optional new) "Switch to the zsh buffer or start one if none exists." (interactive "P") (if new (ansi-term "/bin/zsh" "zsh") (if (get-buffer "*zsh*") (switch-to-buffer "*zsh*") (ansi-term "/bin/zsh" "zsh")))) ;;}}} ;;{{{ Custom keybindings ;; Move Alt-x to C-x-m ;; (global-set-key "\C-x\C-m" 'execute-extended-command) ;; (global-set-key "\C-c\C-m" 'execute-extended-command) ;; C-w to kill word, move kill region to C-x-k ;; (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) ;; better switch buffer command (global-set-key [(control x) b] 'iswitchb-buffer) ;; The following should have been used to bind scrolling to C-. and ;; C-; but this conflicts with flyspell ;; `flyspell-auto-correct-previous-word' and ;; `flyspell-auto-correct-word'. ;;(when (locate-library ' (global-unset-key [(control ?.)]) (global-unset-key [(control ?\;)]) (global-set-key [(control ?.)] 'scroll-up-one-line) ; C-. (global-set-key [(control ?\;)] 'scroll-down-one-line) ; C-; (add-hook 'flyspell-mode-hook (lambda () (local-set-key [(control ?.)] 'scroll-up-one-line) (local-set-key [(control ?\;)] 'scroll-down-one-line) (global-set-key [(control ?.)] 'scroll-up-one-line) (global-set-key [(control ?\;)] 'scroll-down-one-line))) ;; Global binding to access a zsh shell (global-set-key [(control c) (control s)] 'start-zsh) ;;}}} ;;{{{ Fonts and Colours ;; This section contains colour and font related stuff. ;; Font face ;; (when (equal window-system 'x) ;; (if emacs-cvs ;; (set-face-font 'default "-outline-Consolas-normal-r-normal-*-18-112-96-96-c-*-*") ;; (set-face-font 'default "-misc-fixed-medium-r-*-*-15-*-*-*-*-*-*-*"))) ;; xft support from 23 (set-face-attribute 'default nil :height 120 :family "Consolas") ;; Enable color highlighting (global-font-lock-mode t) (setq font-lock-maximum-decoration t) ;; Colours ;; (set-cursor-color "white") ;; (set-mouse-color "white") ;; (if (locate-library "color-theme") ;; (load (concat emacs-dir "color-theme-pastelmac")) ;; (progn ;; (set-foreground-color "gray90") ;; (set-background-color "black") ;; (set-face-foreground 'region "white") ;; (set-face-background 'region "gray20") ;; )) ;;}}} ;;{{{ X11 (Windowing system specific) ;; This section contains configuration for Emacs when in X11 ;; only run if Emacs is run in an X window ;;(when (equal window-system 'x) (set-scroll-bar-mode nil) ; disable scroll bars (tool-bar-mode -1) ; disable tool bar ;;(put 'scroll-left 'disabled nil) ; right scroll bar ;; enable copy/paste in X (setq x-select-enable-clipboard t) (setq interprogram-paste-function 'x-cut-buffer-or-selection-value) ;; Enable mouse scroll wheel in Emacs windows ;; The name of your mouse-scroll may differ. ;; Use C-h k 'scroll your wheel!' to find the name it is bound to (global-set-key [mouse-4] 'scroll-down-one-line) (global-set-key [mouse-5] 'scroll-up-one-line) ;; (global-set-key (kbd "S-C-") 'shrink-window-horizontally) ;; (global-set-key (kbd "S-C-") 'enlarge-window-horizontally) ;; (global-set-key (kbd "S-C-") 'shrink-window) ;; (global-set-key (kbd "S-C-") 'enlarge-window) ;; XMonad + Emacs ;; might need to set 'same-window-regexps' (when nil (setq special-display-regexps "*") (push '(minibuffer . nil) default-frame-alist) (mapc (lambda (x) (push x minibuffer-frame-alist)) '((name . "minibuffer") (minibuffer . only) (auto-raise . t) (menu-bar-lines . 0) (top . (- 768 20)) (width . 1024)))) ;;) ;;}}} ;;{{{ Email ;; This section contains email related configuration. (setq user-mail-address "ian@zerny.dk") ;; MEW -- Messaging in the Emacs World (autoload 'mew "mew" nil t) (autoload 'mew-send "mew" nil t) (autoload 'mew-user-agent-compose "mew" nil t) (if (boundp 'read-mail-command) (setq read-mail-command 'mew)) (if (boundp 'mail-user-agent) (setq mail-user-agent 'mew-user-agent)) (if (fboundp 'define-mail-user-agent) (define-mail-user-agent 'mew-user-agent 'mew-user-agent-compose 'mew-draft-send-message 'mew-draft-kill 'mew-send-hook)) ;; send all mail to localhost that sends over an ssh tunnel to my smtp ;; server. This makes it possible to send email form any of my ;; addresses regardless of were I am or if port 25 is open. (22 must ;; be open of course). ;; ;; Example of a $HOME/.ssh/config for a SMTP ssh tunnel ;; ## SMTP Tunnel ;; Host mail-tunnel ;; HostName my-host.com ;; User my-user ;; LocalForward 2025 my-host.com:25 ;; KeepAlive yes ;; ;; Create tunnel with: ;; $ ssh -N -f -q mail-tunnel ;; (setq send-mail-function 'smtpmail-send-it) ;; (setq smtpmail-default-smtp-server "localhost" ;; smtpmail-smtp-server smtpmail-default-smtp-server ;; smtpmail-smtp-service 2025 ;; smtpmail-local-domain "localhost") ;;}}} ;;{{{ Spelling ;; This section contains things to help me spell in Emacs. ;; ;; Requires: ;; - ispell-mode (contained in standard GNU Emacs) ;; - flyspell-mode (Is probably standard too) ;; http://www-sop.inria.fr/mimosa/Manuel.Serrano/flyspell/flyspell.html ;; - aspell ;; http://aspell.net/ ;; ;; The file also contains a convenient function to automatically guess ;; the language of a buffer when opened or manually guess an open ;; buffer with: ;; M-x guess-language RET ;; Set aspell as spell program (setq ispell-program-name "aspell") ;; Speed up aspell: ultra | fast | normal (setq ispell-extra-args '("--sug-mode=normal")) ;; Flyspell activation for text mode (add-hook 'text-mode-hook (lambda () (flyspell-mode 1))) ;; Remove Flyspell from some sub modes of text mode (dolist (hook '(change-log-mode-hook log-edit-mode-hook)) (add-hook hook (lambda () (flyspell-mode -1)))) ;;; if emacs does not set up a dictionary automatically this is what ;;; is needed. ;; ;; ;; Add the danish dictionary ;; (require 'ispell) ;; (add-to-list 'ispell-dictionary-alist ;; '("danish" ;; "[a-zA-Z\346\370\345\306\330\305]" ;; "[^a-zA-Z\346\370\345\306\330\305]" ;; "[']" t ("-C" "-d" "danish") "~latin1" iso-8859-1)) ;; (defun my-ispell-danish-dictionary () ;; "Switch to the Danish dictionary." ;; (interactive) ;; (ispell-change-dictionary "danish")) ;; (require 'easymenu) ;; (easy-menu-add-item ;; nil ;; '("tools" "spell") ;; ["Select Danish Dict" my-ispell-danish-dictionary t]) ;;; Language guesser stuff ;; See: http://www.emacswiki.org/cgi-bin/wiki/GuessBufferLanguage ;; ;; The following adds guess-language function. Very helpful when using ;; several languages in Emacs. ;; Language pattern rules, just names some common used words of the ;; languages that will be guessed upon. (defvar guess-language-rules '(("american" ;; "english" . "\\<\\(of\\|the\\|and\\|or\\|how\\)\\>") ("dansk" . "\\<\\(og\\|den\\|det\\|der\\|vi\\|eller\\|være\\|nogle\\|kun\\)\\>"))) ;; main guess method (defun guess-buffer-language () "Guess language in the current buffer." (save-excursion (goto-char (point-min)) (let* ((count (map 'list (lambda (x) (let ((count (count-matches (cdr x)))) (cons (if (stringp count) (string-to-number count) ;; emacs v21 count) ;; emacs v22 (car x)))) guess-language-rules)) (key (car (sort (map 'list 'car count) '>)))) (if (number-or-marker-p key) (cdr (assoc key count)) ;; return first language as default (car (car guess-language-rules)))))) ;; hook the language guesser on to the flyspell mode (add-hook 'flyspell-mode-hook (lambda () (ispell-change-dictionary (guess-buffer-language)))) ;;; interactive wrapper (defun guess-language () "Set the language of this buffer by guess." (interactive) (ispell-change-dictionary (guess-buffer-language))) ;;}}} ;;{{{ C and C++ (require 'cc-mode) ;;(add-hook 'c-mode-hook (lambda () (c++-mode))) (add-hook 'c-mode-common-hook (lambda () (flyspell-prog-mode) (setq tab-width 4) (setq c-basic-offset tab-width) (setq indent-tabs-mode nil))) ;;}}} ;;{{{ CSS (when (locate-library "css-mode") (progn (autoload 'css-mode "css-mode" "Major mode for editing Cascading Style Sheets") (setq auto-mode-alist (cons '("\\.css$" . css-mode) auto-mode-alist)) ;;(setq cssm-indent-function #'cssm-c-style-indenter) (defun css-mode-load () (interactive) (css-mode)) )) ;;}}} ;;{{{ Erlang ;; Configuration for erlang programming ;;; Requirements ;; ;; erlang mode ;; Found in the open source Erlang distribution: ;; http://erlang.org ;; ;; distel (Erlang EXT mode) ;; Extention mode for erlang mode and much more ;; http://fresh.homeunix.net/~luke/distel (when (locate-library "erlang-start") (require 'erlang-start)) ;; distel stuff (add-to-list 'load-path (concat (getenv "HOME") "/src/erlang/distel/svn/elisp")) (when (locate-library "distel") (require 'distel) (distel-setup) ;; (add-hook 'erlang-mode-hook 'distel-erlang-mode-hook) ; now with apt-get (add-hook 'erlang-mode-hook '(lambda () (unless erl-nodename-cache (distel-load-shell)))) (defun distel-load-shell () "Load/reload the erlang shell connection to a distel node" (interactive) ;; Set default distel node name (setq erl-nodename-cache 'distel@localhost) (setq distel-modeline-node "distel") (force-mode-line-update) ;; Start up an inferior erlang with node name `distel' (let ((file-buffer (current-buffer)) (file-window (selected-window))) (setq inferior-erlang-machine-options '("-sname" "distel")) (switch-to-buffer-other-window file-buffer) (inferior-erlang) (select-window file-window) (switch-to-buffer file-buffer)))) ;;}}} ;;{{{ Haskell (when (locate-library "haskell-mode") (require 'inf-haskell) ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-ghci) ;;(add-hook 'literate-haskell-mode-hook 'turn-on-haskell-ghci) (add-hook 'haskell-mode-hook '(lambda () ;; (set-input-method "Agda") ;; enables fancy unicode input (toggled with: C-\) (flyspell-prog-mode))) ) ;;}}} ;;{{{ SML ;;(when (locate-library "sml-mode") ;; (add-to-list 'load-path (concat site-packages-dir "/dProgSprog")) ;; ;; (autoload 'sml-mode "sml-mode" () t) ;; (autoload 'sml-mode "sml-mode-color" () t) ;; (add-to-list 'auto-mode-alist '("\\.sml$" . sml-mode)) ;; (add-to-list 'auto-mode-alist '("\\.sig$" . sml-mode)) ;; (setq sml-prog-name "/usr/bin/sml") (add-hook 'sml-mode-hook (lambda () (setq indent-tabs-mode nil) (local-set-key (kbd "M-SPC") 'just-one-space) (flyspell-prog-mode))) (add-hook 'inferior-sml-mode-hook ;;'sml-shell-hook (lambda () (send-string sml-buffer ;;sml-process-name (concat "use \"" (getenv "HOME") "/etc/sml/inferior-setup.sml\";\n")))) ;; ) ;;}}} ;;{{{ Javascript (when (locate-library "js2") (autoload 'js2-mode "js2" nil t) (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))) ;;}}} ;;{{{ Java ;; Java customizations ;; ;; This section contains stuff to make programming in Java almost ;; bearable. ;; ;; Requirements: ;; - JDE ;; http://jdee.sunsite.dk ;; - CEDET >= 1.0beta3 ;; http://cedet.sourceforge.net ;; - Elib ;; http://cclib.nsu.ru/projects/gnudocs/gnudocs/elib/elib_toc.html ;; - GNU Compiler Collection and the free-java-sdk debian package ;; http://gnu.org/software/gcc ;; http://packages.debian.org/stable/misc/free-java-sdk ;; - or a non-free sun version (shame on you) ;; ;; Java mode is loaded for all .java files, and the jde-abbrevs are ;; turned on. This provides shortcuts for pu->public, st->static and so ;; on. ;; When working on larger projects the classpath may need to be ;; changed. Ether create a new project and use JDE to set the ;; classpath. Or use the convenience function `classpath-add' to add a ;; new directory to the path. ;; Add dependencies to load path (now installed with apt-get) ;; (add-to-list 'load-path (concat emacs-dir "jde/lisp")) ;; (add-to-list 'load-path (concat emacs-dir "cedet/common")) ;; (add-to-list 'load-path (concat emacs-dir "elib")) ;; (load-file (concat emacs-dir "cedet/common/cedet.el")) ;; Simple java mode (add-to-list 'auto-mode-alist '("\.java$" . java-mode)) ;; Hooks (add-hook 'java-mode-hook (lambda () (flyspell-prog-mode) ; spell check comments and strings (setq tab-width 4 ; indentation settings indent-tabs-mode nil c-basic-offset 4 tempo-interactive t))) ;; JDE stuff (when (locate-library "jde") ;; Fix for ``Not set up for parsing'' bug ;; (setq global-senator-minor-mode t) ;; Autoload trigger (setq defer-loading-jde t) (if defer-loading-jde (progn (autoload 'jde-mode "jde" "JDE mode." t) (add-to-list 'auto-mode-alist '("\\.java\\'" . jde-mode))) (require 'jde)) ;; Hooks (add-hook 'jde-mode-hook (lambda () ;; Turn on jde abbrev mode (I know it's ugly) ;; but I need make sure the mode is always on ;; (if (equal (jde-abbrev-mode) "abbreviation mode off") ;; (jde-abbrev-mode)) )) ;; Classpath additions ;; new paths can be added with: ;; M-x classpath-add RET /path/to/file RET (defvar jde-global-classpath nil "* Java Classpath variable") (defun classpath-add (path) "Add a directory to the Java Classpath" (interactive "f") (add-to-list 'jde-global-classpath path)) (classpath-add "./") ;; Set java options (setq free-java-path "/usr/lib/fjsdk" sun-java-path "/usr/lib/jvm/java-1.5.0-sun" jde-jdk-registry `(("1.4" . ,free-java-path) ("1.5" . ,sun-java-path))) (defun jde-free-java () "Use the free java system" (interactive) (setq jde-jdk '("1.4") jde-compiler `("javac" ,(concat free-java-path "/bin/javac")))) (defun jde-sun-java () "Use suns java system" (interactive) (setq jde-jdk '("1.5") jde-compiler `("javac" ,(concat sun-java-path "/bin/javac")))) ;; Set default (jde-free-java) ;; BeanShell stuff (setq bsh-jar "/usr/share/java/bsh.jar") (setq bsh-classpath jde-global-classpath) ) ; when locate-library end ;;}}} ;;{{{ Scala (add-to-list 'load-path (concat site-packages-dir "/scala-mode")) (require 'scala-mode-auto) ;;}}} ;;{{{ Lisp (elisp, cl and scheme) (setq scheme-program-name "/usr/local/bin/petite") (load-file "/home/zerny/etc/emacs/scheme-setup.el") ;; (when (locate-library "mmm-mode") ;; (setq mmm-global-mode 'maybe) ;; (setq mmm-submode-decoration-level 2) ;; (mmm-add-group 'gambit-scheme ;; '((scheme-c ;; :submode c-mode ;; :face mmm-code-submode-face ;; :front "<<\\([a-zA-Z0-9_-]+\\)" ;; :front-offset (end-of-line 1) ;; :back "^~1$" ;; :save-matches 1))) ;; (mmm-add-mode-ext-class 'scheme-mode nil 'gambit-scheme)) ;; (setq use-dprogsprog-setup nil) ;; ;;(when (not use-dprogsprog-setup) ;; ;; Enable color highlighting ;; ;; (global-font-lock-mode t) ;; ;; Turn on parenthesis highlighting ;; ;; (show-paren-mode t) ;; ;; Scheme interpreter (full path or locatable in the PATH environment) ;; (setq scheme-program-name "/usr/local/bin/petite") ;; ;; Helper function to send an entire buffer ;; (defun scheme-send-buffer-and-go () ;; "Send entire content of the buffer to the Inferior Scheme process\ ;; and goto the Inferior Scheme buffer." ;; (interactive) ;; (scheme-send-region-and-go (point-min) (point-max))) ;; ;; Configuration run when scheme-mode is loaded ;; (add-hook 'scheme-mode-hook ;; (lambda () ;; ;; indent with spaces ;; (setq indent-tabs-mode nil) ;; ;; spell-check comments and strings ;; (flyspell-prog-mode) ;; ;; Danvy-style key bindings ;; (local-set-key (kbd "C-c d") 'scheme-send-definition-and-go) ;; (local-set-key (kbd "C-c C-b") 'scheme-send-buffer-and-go) ;; ;; fix indentation of some special forms ;; (put 'cond 'scheme-indent-hook 0) ;; (put 'when 'scheme-indent-hook 1) ;; (put 'unless 'scheme-indent-hook 1) ;; ;; special forms from Petite Chez Scheme ;; (put 'trace-lambda 'scheme-indent-hook 2) ;; (put 'extend-syntax 'scheme-indent-hook 1) ;; (put 'with 'scheme-indent-hook 0) ;; (put 'parameterize 'scheme-indent-hook 0) ;; (put 'define-syntax 'scheme-indent-hook 1) ;; (put 'syntax-case 'scheme-indent-hook 0) ;; ;; special forms from DAIMI Scheme ;; (put 'define-record 'scheme-indent-hook 1) ;; (put 'case-record 'scheme-indent-hook 1) ;; ;; special forms from Gambit Scheme ;; (put 'c-define 'scheme-indent-hook 5) ;; (put 'c-lambda 'scheme-indent-hook 2) ;; (put 'c-declare 'scheme-indent-hook 0) ;; ;; sepcial forms from Meroon ;; (put 'with-access 'scheme-indent-hook 2) ;; (put 'instantiate 'scheme-indent-hook 1))) ;; (add-hook 'inferior-scheme-mode-hook ;; (lambda () ;; ;; Overwrite the standard 'switch-to-buffer' to use ;; ;; 'switch-to-buffer-other-window' ;; (defun switch-to-scheme (eob-p) ;; "Switch to the scheme process buffer. ;; With argument, position cursor at end of buffer." ;; (interactive "P") ;; (if (or (and scheme-buffer (get-buffer scheme-buffer)) ;; (scheme-interactively-start-process)) ;; (switch-to-buffer-other-window scheme-buffer) ;; (error "No current process buffer. See variable `scheme-buffer'")) ;; (when eob-p ;; (push-mark) ;; (goto-char (point-max)))))) ;; ;;(setq petite "/usr/bin/petite") ;; ;;(setq heap-file "/home/zerny/src/ifp-webservices/syntax-checker.heap") ;; ;;(setq command (concat "-h " heap-file " --script " "/web/zerny/ifp/run-syntax-checker.scm")) ;; ;;) ;; (when use-dprogsprog-setup ;; (add-to-list 'load-path (concat site-packages-dir "dProgSprog")) ;; (autoload 'petite-chez-scheme-mode "petite-chez-scheme-mode-color" () t) ;; (defun run-petite-chez-scheme () ;; "Run an inferior Petite Chez Scheme process, input and output via buffer *Petite Chez Scheme*." ;; (interactive) ;; (require 'comint) ;; (pop-to-buffer ;; (make-comint "Petite Chez Scheme" ;; "/bin/sh" ;; nil ;; "-c" ;; "/usr/bin/petite")) ;; ;; (inferior-scheme-mode) ;; (make-local-variable 'comint-prompt-regexp) ;; (setq comint-prompt-regexp "> ") ;; (setq mode-name "Inferior Petite Chez Scheme"))) ;; ;;(folding-add-to-marks-list 'scheme-mode ";;{{{" ";;}}}") ;; ;; paredit for balancing parenthies ;; ;;(add-to-list 'load-path (concat emacs-dir "paredit")) ;; ;;(autoload 'enable-paredit-mode "paredit" ;; ;; "Turns on pseudo-structural editing of Lisp code." t) ;; ;; (defun paredit-mode-loader () ;; ;; (local-set-key [(control ?\')] (lambda () (interactive) (insert "("))) ;; ;; (local-set-key [(control ?\\)] (lambda () (interactive) (insert ")"))) ;; ;; (enable-paredit-mode)) ;; ;; Specify modes for Lisp file extensions ;; (setq auto-mode-alist ;; (append '(("\.lisp$" . lisp-mode) ;; ("\.lsp$" . lisp-mode) ;; ("\.cl$" . lisp-mode) ;; ("\.asd$" . lisp-mode) ;; ("\.system$" . lisp-mode)) auto-mode-alist)) ;; (if use-dprogsprog-setup ;; (setq auto-mode-alist ;; (append '(("\\.ss$" . petite-chez-scheme-mode) ;; ("\\.scm$" . petite-chez-scheme-mode) ;; ("\\.sim$" . petite-chez-scheme-mode)) ;; auto-mode-alist)) ;; (setq auto-mode-alist ;; (append '(("\\.ss$" . scheme-mode) ;; ("\\.scm$" . scheme-mode) ;; ("\\.sim$" . scheme-mode)) ;; auto-mode-alist))) ;; ;; lisp hook ;; (dolist (hook '(lisp-mode-hook ;; emacs-lisp-mode-hook)) ;; (add-hook hook ;; (lambda () ;; ;; load paredit ;; ;; (paredit-mode-loader) ;; ;; flyspell for comments and strings ;; (flyspell-prog-mode) ;; ;; remap navigational keys ;; ;; (local-set-key (kbd "C-t") 'transpose-sexps) ;; ;; (local-set-key (kbd "C-M-t") 'transpose-chars) ;; ;; (local-set-key (kbd "C-b") 'backward-sexp) ;; ;; (local-set-key (kbd "C-M-b") 'backward-char) ;; ;; (local-set-key (kbd "C-f") 'forward-sexp) ;; ;; (local-set-key (kbd "C-M-f") 'forward-char) ;; ;; Common lisp indentation ;; (set (make-local-variable lisp-indent-function) ;; 'common-lisp-indent-function)))) ;;}}} (when 1 ;disabled ;;{{{ Slime ;; set the slime distribution path ;; (add-to-list 'load-path (concat site-packages-dir "slime48")) (autoload 'slime "slime" "Start an inferior^_superior Lisp and connect to its Swank server." t) (autoload 'slime-mode "slime" "SLIME: The Superior Lisp Interaction Mode for Emacs (minor-mode)." t) ;; (eval-after-load "slime" ;; '(progn ;; (slime-setup) ;; (setq slime-lisp-implementations ;; `((s48 ("scheme48") :init slime48-init-command) ;; ,@slime-lisp-implementations)))) ;; (autoload 'slime48-init-command "slime48" ;; "Return a string to initialize Scheme48 running under SLIME.") ;; This snippet lets you specify a scheme48-package local variable, ;; in a file's -*- line or local variables section, and have SLIME48 ;; automatically evaluate code in the right package. For instance, ;; all of my Scheme48 source files start with: ;; ;;; -*- Mode: Scheme; scheme48-package: ... -*- ;; (eval-after-load "slime48" ;; '(add-hook 'slime-mode-hook ;; (lambda () ;; (if (and (boundp 'scheme48-package) ;; scheme48-package) ;; (setq slime-buffer-package ;; (with-output-to-string ;; (princ scheme48-package))))))) ;; (add-hook 'scheme-mode-hook (lambda () (slime-mode +1))) (add-to-list 'load-path (concat site-packages-dir "slime")) (when (locate-library "slime") (require 'slime) (setq common-lisp-hyperspec-root (concat "file:" (getenv "HOME") "/doc/programming/commonlisp/hyperspec/")) ;; hook into lisp mode ;; (add-hook 'lisp-mode-hook (lambda () (slime-mode t))) ;; (add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t))) ;; hook into slime ;; (add-hook 'slime-mode-hook ;; (lambda () ;; ;; Connect on first lisp file ;; ;;(unless (slime-connected-p) ;; ;; (save-excursion (slime))) ;; ;; slime buffer selector ;; (local-set-key "\C-cs" 'slime-selector) ;; )) ;; turn on autodoc mode (slime-setup :autodoc t) ;; Lisp's ============================ (defun sbcl () (interactive) (setq inferior-lisp-program "sbcl")) (defun clisp () (interactive) (setq inferior-lisp-program "clisp -K full")) (defun cmucl () (interactive) (setq inferior-lisp-program "cmucl")) ;; Default lisp (sbcl)) ;;}}} ) ;;{{{ Math (when (locate-library "maxima") ;; Requires: ftp://ftp.ams.org/pub/tex/breqn.tgz ;; Load the imaxima stuff (add-to-list 'load-path (concat site-packages-dir "imaxima")) (setenv "TEXINPUTS" (concat (getenv "TEXINPUTS") (getenv "HOME") "/src/tex/breqn:")) (autoload 'imaxima "imaxima" "Frontend for maxima with Image support" t) ;; Use the normal maxima mode with imaxima ;; (it has more functionality) (setq imaxima-use-maxima-mode-flag t) ;; ====== Imaxima Options ====== ;; More can be found at: ;; http://www.ifa.au.dk/~harder/imaxima-manual.html ;; imaxima-pt-size ;; The type size used in LaTeX: 9 | 10 | 11 | 12 ;; imaxima-fnt-size ;; small | normalsize | large | Large | LARGE | huge | Huge (setq imaxima-fnt-size "LARGE") ;; imaxima-scale-factor ;; Scale all images by this factor. The default is 1.0. ;;(setq imaxima-maxima-options ;; (concat imaxima-maxima-options " --run-string=" ;; "set_plot_option([plot_format, mgnuplot]);")) ) ;;}}} ;;{{{ Printing ;; Remove document header ;;(ps-print-header nil) ;; paper format: ;; a4small, b4, b5, executive, ledger, legal, letter, ;; letter-small, statement, tabloid (setq ps-paper-type 'a4) ;; no color (setq ps-print-color-p nil) ;;}}} ;;{{{ Python ;; Add python-mode dir to load-path ;; (add-to-list 'load-path (concat emacs-dir "python-mode")) (when (locate-library "python-mode") (progn ;; Auto load python mode for file extention .py (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist)) (autoload 'python-mode "python-mode" "Python editing mode." t) ;; Rename jpython to jython (setq py-jpython-command "jython") ;; Set python to version 2.3 ;;(setq py-python-command "python2.3") (add-hook 'python-mode-hook (lambda () ;; Spell check in comment and strings (flyspell-prog-mode) ;; Indent to 2 spaces (setq py-indent-offset 4) ;; fix for python/tramp misbehavior? ;; (wisent-python-default-setup) )) )) ;;}}} ;;{{{ Remote editing ;; Configuration of remote file editing extensions ;; ;; Requirements: ;; - Ange-FTP (Standard in GNU Emacs) ;; - Tramp ;; http://www.gnu.org/software/tramp/ ;; ;; These mode allow one to transparently edit files on remote machines ;; over several protocols. ;; To open a file on `host' as `user' via the default protocol `scp' ;; one would do: ;; C-x-f /user@host:/home/user/my-test-file ;; From thereon the rest is just as editing on our local machine ;; (accept stuff like `svn-status' that will not work over tramp). ;; ;; To open a file over FTP we would instead write: ;; C-x-f /ftp:user@host:/my-test-file ;; ;; Please note that in order to open files via ssh you need to have ;; ssh keys on the remote machine. Tramp will not ask for your ;; password so it will not work without. ;;; Tramp ;; ;; Where to load tramp and it's info (when (locate-library "tramp") (require 'tramp) ;;(require 'tramp-util) ;; (add-to-list 'Info-default-directory-list ;; (concat emacs-dir "tramp/info/")) ;; Default protocol/method (setq tramp-default-method "scp")) ;;; Ange FTP ;; ;; Set Non-Passive hosts. ;; -------------------------------------------------------------------- ;; Tweaked by eraatikidotfi based on code from ;; http://mail.gnu.org/pipermail/help-gnu-emacs/2001-April/006468.html: ;; From: Ehud Karni ehudatunixdotsimonwieseldotcodotil ;; Date: Wed, 18 Apr 2001 19:45:08 +0300 ;; Subject: Ange-ftp: passive mode transfers? (defvar ange-ftp-hosts-no-pasv '("localhost" ; my computer "192.168.1.2" ; local server ) "*List of hosts that do not need PASV (e.g. hosts within your firewall). Used by `ange-ftp-set-passive'.") ; rephrased, added "*" // era (defun ange-ftp-set-passive () "Function to send a PASV command to hosts not named in the variable `ange-ft-hosts-no-pasv'. Intended to be called from the hook variable `ange-ftp-process-startup-hook'." ; rephrased significantly // era (if (not (member host ange-ftp-hosts-no-pasv)) (ange-ftp-raw-send-cmd proc "passive"))) (add-hook 'ange-ftp-process-startup-hook 'ange-ftp-set-passive) ;;}}} ;;{{{ (La)TeX ;; Add tex packages path (setenv "TEXINPUTS" (concat ".:" (getenv "HOME") "/src/tex/:" (getenv "TEXINPUTS"))) ;; Add bibtex reference files path (setenv "BIBINPUTS" (concat ".:" (getenv "HOME") "/src/bib/:" (getenv "BIBINPUTS"))) ;; AUC TeX (when (locate-library "tex-site") (require 'tex-site) ;; compile and use pdf as default (setq-default TeX-PDF-mode t) ;; use evince as the pdf viewer (add-hook 'TeX-mode-hook (lambda () ;; (add-to-list 'TeX-output-view-style ;; '("^pdf$" "." "evince %o")) ;; changed in Ubuntu 11.04 (add-to-list 'TeX-view-program-selection '(output-pdf "evince")) (add-to-list 'TeX-view-program-list '("evince" "evince %o"))))) ;; TeX Preview (when (and (equal window-system 'x) (locate-library "preview-latex")) (load "preview-latex")) ;;}}} ;;{{{ Versioning systems ;; Subversion ;; (require 'vc-svn) ;; Darcs (require 'darcsum) ;;}}} ;;{{{ XML ;; loading script ;; (load (concat emacs-dir "nxml-mode/rng-auto.el")) (when (locate-library "nxml-mode") (progn ;; file types (add-to-list 'auto-mode-alist (cons (concat "\\." (regexp-opt '("xml" "html" "xul" "xsd" "sch" "rng" "xslt" "svg" "rss" "asp" "aspx" "zpt" "cpt" "pt") t) "\\'") 'nxml-mode)) ;; spaces insted of tabs (add-hook 'nxml-mode-hook (lambda () (setq indent-tabs-mode nil))) )) ;;}}} ;;{{{ Chatting (when (locate-library "erc") (require 'erc-services) (erc-services-mode 1) (setq erc-prompt-for-nickserv-password nil) (setq erc-nickserv-passwords '((freenode (("zerny" . "XXX"))))) (erc-spelling-mode 1) (setq erc-spelling-dictionaries '(("irc.freenode.net:6667" "american") ("#openengine" "danish"))) ;; based on macros by Damien Elmes and Riastradh ;; http://www.emacswiki.org/cgi-bin/wiki/ErcStartupFiles#ErcStartupFiles2 ;; auto join channel macro (defmacro erc-autojoin (&rest args) `(add-hook 'erc-after-connect '(lambda (server nick) (cond ,@(mapcar (lambda (servers+channels) (let ((servers (car servers+channels)) (channels (car (cdr servers+channels)))) `((member erc-session-server ',servers) (mapc 'erc-join-channel ',channels)))) args))))) ;; connect to server (defmacro de-erc-connect (command server port nick &rest channels) "Create interactive command `command', for connecting to an IRC server. The command uses interactive mode if passed an argument." (fset command `(lambda (arg) (interactive "p") (erc-autojoin ((,server) ,channels)) (if (not (= 1 arg)) (call-interactively 'erc-select) (erc-select :server ,server :port ,port :nick ,nick))))) (autoload 'erc "erc" "" t) (autoload 'erc-select "erc" "" t) (de-erc-connect erc-openengine "irc.freenode.net" 6667 "zerny" "#openengine") (de-erc-connect erc-freenode "irc.freenode.net" 6667 "zerny" "#haskell" "#xmonad" "#ocaml" "#openengine") (de-erc-connect erc-quakenet "irc.dk.quakenet.org" 6667 "zerny" "#daimi") (de-erc-connect erc-efnet "irc.inet.tele.dk" 6667 "zerny") (setq erc-hide-list '("PART" "MODE" "NICK")) ;; quick setup command (defun irc () "Start to waste time on IRC with ERC." (interactive) ;; open new frame (select-frame (make-frame '((name . "Emacs IRC") (minibuffer . t)))) (call-interactively 'erc-freenode) (sit-for 1) (call-interactively 'erc-quakenet)) ) ;; end when ;;}}} ;;{{{ OpenEngine ;; A few thing to ease our OpenEngine build process (load-file (concat (getenv "HOME") "/src/oe/gambit/conf/emacs/openengine.el")) ;;}}} ;;{{{ dOvs ;; (load-file (concat (getenv "HOME") "/doc/daimi/dovs/work/dovs.el")) ;; ;; Emacs hacks for java development with ant. ;; ;; this comes from the openengine.el file ;; (defun path-parent (path) ;; (let ((new-path (mapconcat 'identity ;; (butlast (split-string path "/")) ;; "/"))) ;; (if (equal (substring path 0 1) "/") ;; (concat "/" new-path) ;; new-path))) (defun find-ant-path (path) (cond ((or (equal "/" path) (equal "" path)) nil) ((file-exists-p (concat path "/build.xml")) path) (t (find-ant-path (path-parent path))))) (defun ant-compile (&optional target) "Compile function that searches recursively backwards for an ant build.xml file. If no file is found invokes `compile' in the default manner." (interactive) (let ((ant-path (find-ant-path (path-parent (buffer-file-name))))) (if ant-path (let ((my-buf (current-buffer)) (com-buf (compile (concat "cd " ant-path " && ant -emacs " target)))) (switch-to-buffer-other-window com-buf) (end-of-buffer) (switch-to-buffer-other-window my-buf) ) ;; default to ordinary compile (call-interactively 'compile)))) (setq ant-bindings (lambda () ;; C-c C-v -- run default compile target (local-set-key [(control c) (control v)] 'ant-compile) ;; C-c C-r -- run ``run'' target (local-set-key [(control c) (control r)] (lambda () (interactive) (ant-compile "run"))) ;; C-c C-t -- run test target (the grep removes unwanted stack output) (local-set-key [(control c) (control t)] (lambda () (interactive) (ant-compile "test | grep -v 'apache\\|reflect\\|org\\.junit'"))))) ;; add key bindings to java mode (add-hook 'java-mode-hook ant-bindings) (add-hook 'scala-mode-hook ant-bindings) ;;}}} ;;{{{ NESL (add-to-list 'load-path (concat (getenv "HOME") "/src/nesl/nesl/emacs")) (when (locate-library "nesl") (require 'nesl) (autoload 'run-nesl "nesl" "Major mode for running a NESL process." t) (autoload 'nesl-mode "nesl-mode" "Major mode for editting NESL code." t) (add-to-list 'auto-mode-alist '("\\.nesl$" . nesl-mode))) ;;}}} ;;{{{ Coq (load-file (concat site-packages-dir "/ProofGeneral/generic/proof-site.el")) (setq coq-prog-name "/home/zerny/lib/coq/bin/coqtop") ;;(setq coq-tags (concat (getenv "HOME") "/etc/coq/theories/TAGS")) (add-to-list 'proof-ready-for-assistant-hook (lambda () (menu-bar-mode t) (tool-bar-mode t))) ;;}}} ;;{{{ GPG ;; http://emacs.wordpress.com/2008/07/18/keeping-your-secrets-secret/ ;; Emacs 23: bundled EasyPG (require 'epa) (epa-file-enable) ;;}}} ;;{{{ Agda (add-to-list 'load-path (concat site-packages-dir "agda")) (require 'agda2) (require 'agda-input) (setq agda2-fontset-name nil) ;;}}} ;;{{{ OCaml (and F#) (add-to-list 'auto-mode-alist '("\\.fs$" . tuareg-mode)) (add-hook 'tuareg-mode-hook '(lambda () ;;(define-key tuareg-mode-map '[(control up)] nil) ;;(define-key tuareg-mode-map '[(control down)] nil)) (setq indent-tabs-mode nil) (flyspell-prog-mode))) ;;}}} ;;{{{ ORG mode (setq my-org-dir (concat (getenv "HOME") "/org/")) (setq org-log-done t) ;; add timestamps when closing (org-remember-insinuate) (setq org-default-notes-file (concat my-org-dir "notes.org")) (define-key global-map "\C-cl" 'org-store-link) (define-key global-map "\C-ca" 'org-agenda) (define-key global-map "\C-cr" 'org-remember) (setq org-agenda-include-diary t) (setq holidays-in-diary-buffer nil) (setq diary-file (concat my-org-dir "diary")) (setq org-agenda-files (map 'list (lambda (f) (concat my-org-dir f ".org")) '("studies" "magnifik" "money" "other"))) ;;}}} ;;{{{ markdown mode (when (locate-library "markdown") (add-to-list 'auto-mode-alist '("\\.text" . markdown-mode))) ;;}}} ;;{{{ BNF ;; from: http://www.reddit.com/r/emacs/comments/af2sg/bnfmode_for_emacs/ (define-generic-mode 'bnf-mode () ;; comment char: inapplicable because # must be at start of line nil ;; keywords '(("^#.*" . 'font-lock-comment-face) ;; comments at start of line ("^<[^ \t\n]*?>" . 'font-lock-function-name-face) ;; LHS nonterminals ("<[^ \t\n]*?>" . 'font-lock-builtin-face) ;; other nonterminals ("::=" . 'font-lock-const-face) ;; "goes-to" symbol ("\|" . 'font-lock-warning-face)) ;; "OR" symbol '("\\.bnf\\'") ;; filename suffixes nil ;; extra function hooks "Major mode for BNF highlighting.") ;;}}} (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. )