;;; -*- mode: lisp; 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/etc/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 (defvar emacs-custom-build (string-equal emacs-version "24.1.1") "Mark if we are using a custom build of emacs.") ;; To make further customizing easier these variables abstract ;; directory structure. (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 needed if 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 (and emacs-custom-build (file-exists-p "/usr/share/emacs/site-lisp/debian-startup.el")) (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) ;;(setq-default fill-column 68) ; shrink auto-fill column a bit (setq browse-url-browser-function 'browse-url-generic) (setq browse-url-generic-program "/opt/google/chrome/google-chrome") ;; 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 ~/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:" (getenv "HOME") "/.smackage/bin:" (getenv "HOME") "/.cabal/bin:" "/opt/cell/toolchain/bin:" (getenv "PATH")))) ;; rebind quit to C-x-q (I keep hitting C-x-c by accident) (global-unset-key (kbd "C-x C-c")) (global-set-key (kbd "C-x C-q") 'save-buffers-kill-emacs) ;; remove suspend (which freezes emacs when your WM has no "dock") (global-unset-key (kbd "C-z")) (global-unset-key (kbd "C-x C-z")) ;; enable ansi color output in shell (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) ;; update the file time-stamp on saving (add-hook 'before-save-hook 'time-stamp) ;;}}} ;;{{{ Helper functions ;;; Commentary ;; ;; This section contain some functions that I find useful ;; Binding to go to the previous window. (global-set-key (kbd "C-x p") 'previous-other-window) (defun previous-other-window () (interactive) (other-window -1)) ;;; 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")))) ;; Map C-x C-i to indent-region-by-string: (global-set-key (kbd "C-x C-i") 'indent-region-by-string) (defun indent-region-by-string (start end arg) "Indent each nonblank line in the region. With no argument, indent each line with Tab. With argument ARG, indent each line by that string. Called from a program, takes three args: START, END and STR. Note: region is also untabified." (interactive "r\nsIndent region by string: ") (save-excursion (goto-char end) (setq end (point-marker)) (goto-char start) (beginning-of-line) (untabify (point) end) (while (< (point) end) (insert arg) (forward-line 1)) (move-marker end nil))) ;;}}} ;;{{{ 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'. ;; (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 Colors ;; This section contains color 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) ;; Colors ;; (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 (when (locate-library "mew") (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))) ;;}}} ;;{{{ Encryption ;; Emacs 23: bundled EasyPG (require 'epa) (epa-file-enable) ;; http://emacswiki.org/emacs/PasswordGenerator (require 'cl) ;; defines defun* macro for keyword parameters (defun* make-password (length &optional (upper t) (lower t) (number t) (symbol nil) (ambiguous nil)) "Return a string of LENGTH random characters. If UPPER is non-nil, use uppercase letters. If lower is non-nil, use lowercase letters. If NUMBER is non-nil, use numbers. If SYMBOL is non-nil, use one of \"!\"#$%&'()*+'-./:;<=>?@`{}|~\". If AMBIGUOUS is nil, avoid characters like \"l\" and \"1\", \"O\" and \"0\"." (interactive (make-password-prompt-for-args)) (let ((char-list (make-password-char-list upper lower number symbol ambiguous)) position password) (random t) (loop for i from 1 to length do (setq position (random (length char-list)) password (concat password (string (nth position char-list))))) (if (interactive-p) (let* ((strength (make-password-strength length upper lower number symbol ambiguous)) (bits (car strength)) (number (cadr strength))) (message "The password \"%s\" is one of 10^%d possible and has a bit equivalence of %d" password (round number) (round bits))) (insert password)))) (defun make-password-char-list (upper lower number symbol ambiguous) (let* ((upper-chars-ambiguous '(?I ?O ?G)) (upper-chars (loop for i from ?A to ?Z unless (member i upper-chars-ambiguous) collect i)) (lower-chars-ambiguous '(?l ?o)) (lower-chars (loop for i from ?a to ?z unless (member i lower-chars-ambiguous) collect i)) (number-chars-ambiguous '(?0 ?1 ?6)) (number-chars (loop for i from ?0 to ?9 unless (member i number-chars-ambiguous) collect i)) (symbol-chars '(?! ?@ ?# ?$ ?% ?& ?* ?( ?) ?+ ?= ?/ ?{ ?} ?[ ?] ?: ?\; ?< ?>)) (symbol-chars-ambiguous '(?_ ?- ?| ?, ?. ?` ?' ?~ ?^ ?\")) char-list) (if upper (setq char-list (append char-list upper-chars))) (if lower (setq char-list (append char-list lower-chars))) (if number (setq char-list (append char-list number-chars))) (if symbol (setq char-list (append char-list symbol-chars))) (if ambiguous (setq char-list (append char-list upper-chars-ambiguous lower-chars-ambiguous number-chars-ambiguous symbol-chars-ambiguous))) char-list)) (defun make-password-prompt-for-args () (interactive) (list (string-to-number (read-from-minibuffer "Number of Characters: ")) (y-or-n-p "User uppercase: ") (y-or-n-p "User lowercase: ") (y-or-n-p "User numbers: ") (y-or-n-p "User symbols: ") (y-or-n-p "User ambiguous characters: "))) (defun* make-password-strength (length &optional (upper t) (lower t) (number t) (symbol nil) (ambiguous nil)) "Calculate the number of possible passwords that could be generated given the criteria of LENGTH and use of UPPER, LOWER, NUMBER, SYMBOL, and AMBIGUOUS characters" (interactive (make-password-prompt-for-args)) (let* ((char-list (make-password-char-list upper lower number symbol ambiguous)) (bits (/ (* length (log (length char-list))) (log 2))) (number (/ (* bits (log 2)) (log 10)))) (if (interactive-p) (message "number of combinations is 10^%d with a bit equivalence of %d" (round number) (round bits)) (list bits number)))) ;;}}} ;;{{{ 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))) (setq auto-mode-alist (cons '("\\.[ch]$" . c++-mode) auto-mode-alist)) ; .c,.h files in C++ mode ;; Given a directory (as a dirname and filename), return the dirname of ;; of the first subdirectory of a directory. (defun my-trim-line (str) (let ((end-index (- (length str) 1))) (if (or (< end-index 0) (not (char-equal (elt str end-index) ?\n))) str (substring str 0 end-index)))) (defun my-shell-command (cmd) (my-trim-line (shell-command-to-string cmd))) (defun my-find-checkout () (let ((git-toplevel (my-shell-command "git rev-parse --show-toplevel"))) (unless (string-match "fatal: Not a git repository" git-toplevel) git-toplevel))) (defvar build-arch-latest nil) (defvar build-mode-latest nil) (defvar build-arch-history '("ia32" "x64" "all")) (defvar build-mode-history '("debug" "release" "debug,release")) (defun build (arch mode) (interactive (let* ((arch (if (or (null build-arch-latest) current-prefix-arg) (read-string "arch [ia32]: " nil 'build-arch-history "ia32") build-arch-latest)) (mode (if (or (null build-mode-latest) current-prefix-arg) (read-string "mode [debug]: " nil 'build-mode-history "debug") build-mode-latest))) (list arch mode))) (setq build-arch-latest arch) (setq build-mode-latest mode) (save-excursion (save-some-buffers t) (let* ((start-dir default-directory) (top-dir (my-find-checkout))) (when top-dir (cd top-dir) (unwind-protect (compile (concat "GYP_GENERATORS=make tools/build.py runtime" " --arch=" arch " --mode=" mode)) (cd start-dir)))))) (require 'google-c-style) (add-hook 'c-mode-common-hook 'google-set-c-style) ;;}}} ;;{{{ 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-to-list 'load-path (file-truename "/home/zerny/lib/mlton/ide/emacs")) ;; (require 'esml-du-mlton) (add-hook 'sml-mode-hook (lambda () ;; (def-use-mode) (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")))) ;; (add-hook 'dml-mode-hook ;; (lambda () ;; (setq indent-tabs-mode nil) ;; (local-set-key (kbd "M-SPC") 'just-one-space) ;; (flyspell-prog-mode))) ;; (add-hook 'inferior-dml-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/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 nil ;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"))) (defun texcount () (interactive) (shell-command (concat "texcount " (buffer-file-name)))) ;; AUC TeX (setq-default TeX-PDF-mode t) (when (locate-library "tex-site") (require 'tex-site) ;; query for TeX-master file ;;(setq-default TeX-master nil) ;; 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 ;; 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")) ;; find the cabal agda-mode with: agda-mode locate (add-to-list 'load-path "/home/zerny/.cabal/share/Agda-2.3.0.1/emacs-mode") (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 ;; is in emacs-goodies-el (when (locate-library "markdown-mode") (autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t) (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))) ;;}}} ;;{{{ Twelf / Celf (setq twelf-root "/home/zerny/.smackage/lib/twelf/v1/") (setq twelf-init (concat twelf-root "emacs/twelf-init.el")) (when (file-exists-p twelf-init) (load twelf-init)) ;; (add-to-list 'load-path (concat (getenv "HOME") "/.smackage/lib/twelf/v1/emacs")) ;; (autoload 'twelf-mode "twelf" "Major mode for editing Twelf source." t) ;; ;; (autoload 'twelf-server "twelf" "Run an inferior Twelf server." t) ;; ;; (autoload 'twelf-sml "twelf" "Run an inferior Twelf-SML process." t) ;; (setq auto-mode-alist ;; (append (("\.elf$" . twelf-mode) ;; ("\.quy$" . twelf-mode) ;; ("\.thm$" . twelf-mode) ;; ("\.cfg$" . twelf-mode) ;; ("\.clf$" . twelf-mode)) ;; auto-mode-alist)) ;; ;; (setq twelf-server-program ;; ;; "/afs/cs/project/twelf/research/twelf/bin/twelf-server") ;; ;; (setq twelf-sml-program ;; ;; "/afs/cs/project/twelf/misc/smlnj/bin/sml-cm") ;;}}} ;;{{{ Dart (when nil (defvar dart-lib (concat (getenv "HOME") "/lib/dart")) (defvar dart-bld (concat dart-lib "/bleeding/dart/out/DebugIA32")) (defvar dart-doc (concat dart-bld "/api_docs")) (defvar dart-bin (concat dart-bld "/dart")) (defvar dart-2js (concat dart-bld "/dart2js")) (defvar dart-d8 (concat dart-bld "/d8")) (defvar dart-analyzer (concat dart-bld "/analyzer/bin/dart_analyzer")) (add-to-list 'load-path (concat dart-lib "/dart-mode")) (when (locate-library "dart-mode") (require 'dart-mode) (add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode)) ;; (add-to-list 'compilation-error-regexp-alist-alist ;; '(dart "^'file://\\([^']+\\)': Error: line \\([0-9]+\\) pos \\([0-9]+\\):" 1 2 3 (1 2 3))) (add-hook 'dart-mode-hook (lambda () (flyspell-prog-mode) ;; (add-to-list 'compilation-error-regexp-alist 'dart) (local-set-key [(control c) (control d)] (lambda () (interactive) (browse-url (concat dart-doc "/index.html")))) (local-set-key [(control c) (control c)] (lambda () (interactive) (compile (concat dart-analyzer " " (buffer-file-name))))) (local-set-key [(control c) (control v)] (lambda () (interactive) (compile (concat dart-bin " " (buffer-file-name))))) (local-set-key [(control c) (control j)] (lambda () (interactive) (compile (concat dart-2js " " (buffer-file-name) " && " dart-d8 " out.js")))))))) ;;}}} ;; https://gist.github.com/joannavarrete/5181141 (defun cycle-windows() "cycle the buffer of the windows in cyclic ordering" (interactive) (mapcar (lambda(window) (let ((next-window-buffer (window-buffer (next-window window 0)))) (set-window-buffer (next-window window 0) (window-buffer window)) (set-window-buffer window next-window-buffer))) (butlast (window-list nil 0)))) (load-theme 'wombat t) (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. )