;; ;; Jani-Hur's GNU Emacs initialization file ;; http://www.jani-hur.net/.emacs.d/init.el ;; ;; ;; InsertDate (http://www.emacswiki.org/cgi-bin/wiki/InsertDate) ;; (defun insert-date () "Inserts the current date." (interactive) (insert (format-time-string "%a %b %e %T %Z %Y")) ) ;; ;; Use % to match various kinds of brackets (from Perl Best Practices by ;; Damian Conway) ;; (defun match-paren (arg) "" (interactive "p") (let ((prev-char (char-to-string (preceding-char))) (next-char (char-to-string (following-char)))) (cond ((string-match "[[{(<]" next-char) (forward-sexp 1)) ((string-match "[\]})>]" prev-char) (backward-sexp 1)) (t (self-insert-command (or arg 1)))))) (global-set-key "%" 'match-paren) ;; ;; Scroll in place ;; (from http://www.emacswiki.org/cgi-bin/wiki/McMahanEmacsMacros) ;; (defun scroll-down-in-place (n) (interactive "p") (previous-line n) (scroll-down n)) (defun scroll-up-in-place (n) (interactive "p") (next-line n) (scroll-up n)) (global-set-key [(meta down)] 'scroll-up-in-place) (global-set-key [(meta up)] 'scroll-down-in-place) ;; ;; Load cperl mode instead of perl mode ;; (from http://www.emacswiki.org/cgi-bin/wiki/CPerlMode) ;; (defalias 'perl-mode 'cperl-mode) ;; ;; Perl test files start in cperl-mode ;; (add-to-list 'auto-mode-alist '("\\.t\\'". cperl-mode)) ;; ;; C++ ;; ;; ; .icc files are C++ ;; (add-to-list 'auto-mode-alist '("\\.icc\\'". c++-mode)) ;; (defun cpp-find-alternate-file () ;; "Switch .hh/.cc-files. (Idea copied from tuareg mode.)" ;; (interactive) ;; (let ((name (buffer-file-name))) ;; (if (string-match "\\`\\(.*\\)\\.cc\\'" name) ;; (find-file (concat (match-string 1 name) ".hh")) ;; (if (string-match "\\`\\(.*\\)\\.hh\\'" name) ;; (find-file (concat (match-string 1 name) ".cc"))) ;; ) ;; ) ;; ) ;; (defun my-c++-hook () ;; (local-set-key [?\C-c ?\C-a] 'cpp-find-alternate-file)) ;; (add-hook 'c++-mode-hook 'my-c++-hook) ;; ;; HTML ;; ; .ssi files are Apache Server Side Includes (add-to-list 'auto-mode-alist '("\\.ssi\\'". html-mode)) ;; ;; JavaScript uses modified java-mode. ;; (c-add-style "myjava" '("java" (c-basic-offset . 2))) (setq c-default-style '((java-mode . "myjava") (awk-mode . "awk") (other . "gnu"))) (add-to-list 'auto-mode-alist '("\\.js\\'". java-mode)) ;; ;; Show matching parenthesis (parens). ;; (show-paren-mode 1) (setq show-paren-delay 0.5) (setq show-paren-style "mixed") ;; ;; Org-mode (http://orgmode.org) ;; (require 'org-install) (add-to-list 'auto-mode-alist '("TODO" . org-mode)) (define-key global-map "\C-cl" 'org-store-link) (define-key global-map "\C-ca" 'org-agenda) (setq org-log-done t) ;; ;; Global key bindings ;; (global-set-key (kbd "å") 'dabbrev-expand) (global-set-key (kbd "C-c d") 'insert-date) (global-set-key (kbd "C-x o") 'other-frame) ; instead of other-window (global-set-key (kbd "M-g") 'goto-line) ; instead of set-face ... prefix (global-set-key (kbd "C-") 'other-window) ; control-tab ; inspired by http://xahlee.org/emacs/ (global-set-key (kbd "M-0") 'delete-window) ; C-x 0 (global-set-key (kbd "M-1") 'delete-other-windows) ; C-x 1 (global-set-key (kbd "M-2") 'split-window-vertically) ; C-x 2 (global-set-key (kbd "M-a") 'beginning-of-line) ; C-a (global-set-key (kbd "M-b") 'switch-to-buffer) ; C-x b (global-set-key (kbd "M-e") 'end-of-line) ; C-e (global-set-key (kbd "M-s") 'save-buffer) ; C-x C-s (global-set-key (kbd "M-") 'other-frame) ; C-x o (global-set-key (kbd "M-") 'other-frame) ; C-x o ;; ;; Global value for automatic line-wrapping. ;; (setq-default fill-column 78) ;; ;; Turn on column mode so we'll se also column number in the mode line. ;; (column-number-mode 1) ;; ;; Display time (in 24hr format) in mode line. ;; (display-time) (setq display-time-24hr-format t) ;; ;; Turn off unnecessary menu-bar, tool-bar and scroll-bar ;; (menu-bar-mode 0) (tool-bar-mode 0) (scroll-bar-mode -1) ;; ;; Visible bell instead of audible ;; (setq visible-bell t) ;; ;; Default to better frame titles ;; (setq frame-title-format (concat "%b - emacs@" (system-name))) ;; ;; Turn on font-lock mode ;; (when (fboundp 'global-font-lock-mode) (global-font-lock-mode t)) ;; ;; Default frame size ;; ; height is system specific (add-to-list 'default-frame-alist '(width . 80)) ;; ;; Saving Emacs Sessions ;; http://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Emacs-Sessions.html ;; (desktop-save-mode 1) ;; ;; System specific settings ;; ;; (if (string-match "o2fedora5" (system-name)) ;; (progn ;; (setq load-path (cons (concat ;; (getenv "HOME") ;; "/lib/emacs/tuareg-mode-1.45.6") ;; load-path)) ;; (setq load-path (cons (concat ;; (getenv "HOME") ;; "/ossi2/trunk/packages/ocaml/src/emacs") ;; load-path)) ;; (setq auto-mode-alist (cons '("\\.ml\\w?" . tuareg-mode) ;; auto-mode-alist)) ;; (autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t) ;; (autoload 'camldebug "camldebug" "Run the Caml debugger" t) ;; (autoload 'caml-types "caml-types" "Show Caml types" t) ;; ) ;; ) ;; ;; Locally installed packages and other host specific setting ;; (if (string-match "dina" (system-name)) (progn (setq load-path (cons "~/.emacs.d" load-path)) (autoload 'hattrick-ml-mode "hattrick-ml") (add-to-list 'auto-mode-alist '("\\.ht\\(-ml\\)?\\'" . hattrick-ml-mode)) (add-to-list 'auto-mode-alist '("\\.po\\'\\|\\.po\\.". po-mode)) (add-to-list 'default-frame-alist '(height . 48)) ) )