;;; -*- emacs-lisp -*- ;;; ;;; .emacs - Carlos Eduardo Scheidegger ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Keyboard setup (load "~/cvs/src/emacs/.emacs_common") (global-set-key [C-return] 'dabbrev-expand) (global-set-key [delete] 'delete-char) (global-set-key [kp-delete] 'delete-char) (global-set-key "\C-x\C-g" 'goto-line) (global-set-key "\C-xs" 'save-all-buffers) (global-set-key "\M-_" 'redo) (global-set-key "\M-C-k" 'kill-sexp) (global-set-key "\C-s" 'isearch-forward-regexp) (global-set-key "\C-r" 'isearch-backward-regexp) (global-set-key [?\C-'] 'backward-delete-char-untabify) (global-set-key "\C-x\C-c" 'kill-some-buffers) (global-set-key [C-M-t] 'transpose-lines) (global-set-key [M-S-f4] 'new-frame) (global-unset-key [prior]) (global-set-key [prior] 'my-pageup) (global-unset-key [next]) (global-set-key [next] 'my-pagedown) (global-unset-key "\M-v") (global-set-key "\M-v" 'my-pageup) (global-unset-key "\C-v") (global-set-key "\C-v" 'my-pagedown) (global-unset-key [C-backspace]) (global-set-key [C-backspace] 'backward-kill-word) (global-set-key [M-f2] 'nice-shell) (global-set-key [M-f4] 'kill-this-buffer) (global-set-key "\C-xk" 'kill-this-buffer) (global-unset-key "\C-g") (global-set-key "\C-q" 'keyboard-quit) (global-set-key "\C-g\C-t" 'beginning-of-buffer) (global-set-key "\C-g\C-b" 'end-of-buffer) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Misc functions ;; save all, don't ask (defun save-all-buffers () (interactive) (save-some-buffers 1)) (defun set-sane-cursor-color (frame) (select-frame frame) (set-background-color "Black") (set-foreground-color "White") (set-cursor-color "white")) ;; Elisp development ;; Working around non-interactive functions (defun interactive-print (fname) (interactive "S") (princ (eval (list fname)))) (defun gud-kill-buffer () (if (eq major-mode 'gud-mode) (delete-overlay gud-overlay))) (defun end-of-line-indent () (interactive) (end-of-line) (newline-and-indent)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Hook functions (defun my-gud-style () ;; breakpoints (global-set-key [f8] 'gud-remove) (global-set-key [f9] 'gud-break) ;; vai em frente, ateh acabar ou breakpoint (global-set-key [f5] 'gud-cont) ;; step (entra nas funcoes) (global-set-key [f11] 'gud-step) ;; step (pula funcoes) (global-set-key [f10] 'gud-next) ;; finish function (global-set-key [f12] 'gud-finish) ;; comeca o debug (gud-def gud-run "run" nil "Run the program.") (global-set-key [C-f5] 'gud-run)) (defun my-scheme-mode-common-hook () (local-unset-key [C-x C-l]) (global-unset-key [C-x C-l]) (local-set-key [C-x C-l] 'eval-last-sexp) (local-unset-key [C-c C-c]) (local-set-key [C-c C-c] 'comment-region)) ;; The One True Indenting Style (defun my-c-mode-common-hook () (c-set-style "linux") (setq compilation-scroll-output t) (setq compilation-window-height 30) (local-unset-key "\C-c\C-c") (local-set-key "\C-c\C-c" 'compile) (local-unset-key "\C-c\C-d") (local-set-key "\C-c\C-d" 'gdb) (local-unset-key "\C-j") (local-set-key "\C-j" 'end-of-line-indent) (local-unset-key "\C-xh") (local-set-key "\C-xh" 'header-flip) (local-unset-key "\C-xi") (local-set-key "\C-xi" 'insert-guarded-include-dwim) (local-unset-key "\C-x\C-i") (local-set-key "\C-x\C-i" 'insert-guarded-include-dwim) (define-abbrev c++-mode-abbrev-table "iif" "" 'c++-skeleton-if) (define-abbrev c++-mode-abbrev-table "iife" "" 'c++-skeleton-if-else) (define-abbrev c++-mode-abbrev-table "ifor" "" 'c++-skeleton-for) (define-abbrev c++-mode-abbrev-table "itp" "" 'c++-skeleton-template) (define-abbrev c++-mode-abbrev-table "iw" "" 'c++-skeleton-while) (define-abbrev c++-mode-abbrev-table "ido" "" 'c++-skeleton-do) (define-abbrev c++-mode-abbrev-table "icl" "" 'c++-skeleton-class) (define-abbrev c++-mode-abbrev-table "ist" "" 'c++-skeleton-struct) (define-abbrev c++-mode-abbrev-table "isc" "" 'c++-skeleton-short-brief) (define-abbrev c++-mode-abbrev-table "ilc" "" 'c++-skeleton-long-brief) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Skeletons for C++ (define-skeleton c++-skeleton-if "Insert an if () {} region" nil > "if (" _ ") {" > \n "}" > \n) (define-skeleton c++-skeleton-if-else "Insert an if () {} else {}region" nil > "if (" _ ") {" \n "} else {" > \n "}" >) (define-skeleton c++-skeleton-for "Insert a 'for () {}' region" nil > "for ("_") {" > \n "}" > \n) (define-skeleton c++-skeleton-while "Insert a 'while () {}' region" nil > "while ("_") {" > \n "}" > \n) (define-skeleton c++-skeleton-do "Insert a 'do {} while ()' region" nil > "do {" > \n _ > \n "} while ()" > \n) (define-skeleton c++-skeleton-template "Insert a 'template <>' region" nil > "template <"_">" > \n ) (define-skeleton c++-skeleton-class "Insert a 'class {};' region" nil > "class "_" {" > \n "};" > \n ) (define-skeleton c++-skeleton-struct "Insert a 'struct {};' region" nil > "struct "_" {" > \n "};" > \n ) (define-skeleton c++-skeleton-short-brief "Insert a '//! \\brief' comment" nil "//! \\brief " _ ) (define-skeleton c++-skeleton-long-brief "Insert a /*! \\brief .. */ comment" nil "/*! \\brief " > _ \n "*/" > \n ) (setq skeleton-mode-hook nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Add color to the current GUD line (obrigado bruno e google) (defvar gud-overlay (let* ((ov (make-overlay (point-min) (point-min)))) (overlay-put ov 'face 'secondary-selection) ov) "Overlay variable for GUD highlighting.") (defadvice gud-display-line (after my-gud-highlight act) "Highlight current line." (let* ((ov gud-overlay) (bf (gud-find-file true-file))) (save-excursion (set-buffer bf) (move-overlay ov (line-beginning-position) (line-end-position) (current-buffer))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Miscellaneous ;; Fighting the CTS fight (fset 'yes-or-no-p 'y-or-n-p) ;; Are we running XEmacs or Emacs? (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)) (server-start) ;; So we can use emacsclient ;; Enable wheelmouse support by default (cond (window-system (mwheel-install))) (set-background-color "Black") (set-foreground-color "White") (set-cursor-color "White") (tool-bar-mode 0) (menu-bar-mode 0) (scroll-bar-mode -1) (global-font-lock-mode t) (show-paren-mode 1) (transient-mark-mode 1) (global-hl-line-mode) (put 'downcase-region 'disabled nil) ;; Handle compressed files automagically (auto-compression-mode 1) ;;; variables (setq search-whitespace-regexp "[ \t\r\n]+" next-line-add-newlines nil ; Stop at the end of the file, not just add lines require-final-newline t ; Always end a file with a newline tex-dvi-view-command "xdvi" frame-title-format '("GNU Emacs " emacs-version " [%b]") icon-title-format frame-title-format line-number-mode t ; show the current line column-number-mode t ; show the current column font-lock-maximum-decoration t inhibit-startup-message t inhibit-startup-buffer-menu t initial-scratch-message nil scroll-step 1 show-paren-delay 0 default-major-mode 'text-mode ; Default mode for files with no extension x-select-enable-clipboard t term-scroll-show-maximum-output t compilation-read-command nil ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Hooks (add-hook 'gdb-mode-hook 'my-gud-style) (add-hook 'pdb-mode-hook 'my-gud-style) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) (add-hook 'c++-mode-common-hook 'abbrev-mode) (add-hook 'c++-mode-common-hook 'my-c-mode-common-hook) (add-hook 'text-mode-hook 'auto-fill-mode) (add-hook 'kill-buffer-hook 'gud-kill-buffer) (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) (add-hook 'python-mode-hook 'my-python-mode-style) (add-to-list 'auto-mode-alist '("\\.h$" . c++-mode)) (add-to-list 'auto-mode-alist '("\\.inl$" . c++-mode)) (add-to-list 'auto-mode-alist '("\\.ipp$" . c++-mode)) (add-to-list 'after-make-frame-functions 'set-sane-cursor-color) (defun loom-respects-guarded-include-convention (name) (string-match "^loom/" name)) (defun cs7650-respects-guarded-include-convention (name) (string-match "^cs7650/" name)) (add-to-list 'respects-guarded-include-convention-list 'loom-respects-guarded-include-convention) (add-to-list 'respects-guarded-include-convention-list 'cs7650-respects-guarded-include-convention) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Packages and modes (defun py-end-of-line-indent () (interactive) (end-of-line) (py-newline-and-indent)) (defun py-end-of-block () (interactive) (let ((target-indentation (- (current-indentation) py-indent-offset))) (while (> (current-indentation) target-indentation) (next-line)) (previous-line) (end-of-line) (let ((this-indentation (current-indentation))) (py-newline-and-indent) (py-electric-backspace (/ (- this-indentation target-indentation) py-indent-offset))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun my-python-mode-style () (local-unset-key "\C-j") (local-set-key "\C-j" 'py-end-of-line-indent) (local-unset-key "\M-j") (local-set-key "\M-j" 'py-end-of-block) (local-unset-key "\M-r") (local-set-key "\M-r" 'brm-rename) (local-unset-key "\M-s") (local-set-key "\M-s" 'python-find) (local-unset-key "\C-x,") (local-set-key "\C-x," 'python-decrease-hide) (local-unset-key "\C-x.") (local-set-key "\C-x." 'python-increase-hide) ) (add-to-list 'load-path "~/.elisp/") (add-to-list 'load-path "~/.elisp/python-mode-1.0") (require 'python-mode) (require 'python-find) (require 'python-selective-display) ;; Quack - enhanced scheme mode (require 'quack) (add-hook 'scheme-mode-hook 'abbrev-mode) (add-hook 'cmuscheme-load-hook 'my-scheme-mode-common-hook) ;; ERC - An IRC client (very cool) (setq cscheid-erc-directory (cond ((file-directory-p "~/.elisp/erc-5.0.1") "~/.elisp/erc-5.0.1") ((file-directory-p "~/.elisp/erc-4.1") "~/.elisp/erc-4.1") (t nil))) (if cscheid-erc-directory (progn (add-to-list 'load-path cscheid-erc-directory) (autoload 'erc-select "erc" "IRC Client" t) (require 'erc))) ;; Regular undo-redo (emacs undo goes way over my head) (add-to-list 'load-path "~/.elisp/redo") (require 'redo) ;; Haskell mode (add-to-list 'load-path "~/.elisp/haskell-mode-1.44") (setq auto-mode-alist (append auto-mode-alist '(("\\.[hg]s$" . haskell-mode) ("\\.hi$" . haskell-mode) ("\\.l[hg]s$" . literate-haskell-mode)))) (autoload 'haskell-mode "haskell-mode" "Major mode for editing Haskell scripts." t) (autoload 'literate-haskell-mode "haskell-mode" "Major mode for editing literate Haskell scripts." t) (add-hook 'haskell-mode-hook 'turn-on-haskell-font-lock) (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)t (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) (add-hook 'haskell-mode-hook 'turn-on-haskell-ghci) (add-hook 'haskell-mode-hook 'turn-on-haskell-hugs) ;; CSS mode (autoload 'css-mode "css-mode") (add-to-list 'auto-mode-alist '("\\.css$" . css-mode)) ;; caml mode (add-to-list 'load-path "~/.elisp/tuareg-mode-1.45.3") (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) (add-hook 'tuareg-mode-hook (lambda () (local-unset-key "\C-j") (local-set-key "\C-j" 'end-of-line-indent) (local-unset-key "\C-x\C-h") (local-set-key "\C-x\C-h" 'tuareg-find-alternate-file) (local-unset-key "\C-xh") (local-set-key "\C-xh" 'tuareg-find-alternate-file))) ;; applescript mode (autoload 'applescript-mode "applescript-mode" "major mode for editing AppleScript source." t) (add-to-list 'auto-mode-alist '("\\.applescript$" . applescript-mode)) (add-to-list 'auto-mode-alist '("\\.scpt$" . applescript-mode)) ;; CMake mode (autoload 'cmake-mode "cmake-mode") (add-to-list 'auto-mode-alist '("\\CMakeLists.txt$" . cmake-mode)) ;;; Prolog mode (autoload 'run-prolog "prolog" "Start a Prolog sub-process." t) (autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t) (autoload 'mercury-mode "prolog" "Major mode for editing Mercury programs." t) (setq prolog-system 'swi) (setq auto-mode-alist (append '(("\\.pl$" . prolog-mode) ("\\.P$" . prolog-mode) ("\\.m$" . mercury-mode)) auto-mode-alist)) ;;; pymacs ;; (autoload 'pymacs-load "pymacs" nil t) ;; (autoload 'pymacs-eval "pymacs" nil t) ;; (autoload 'pymacs-apply "pymacs") ;; (autoload 'pymacs-call "pymacs") ;; (pymacs-load "bikeemacs" "brm-") ;; (brm-init) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Customize crap ;; (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. ;; '(highlight ((((class color) (min-colors 88) (background dark)) (:background "DeepSkyBlue4")))) ;; '(mode-line ((((class color) (min-colors 88)) (:background "darkred" :foreground "white" :box (:line-width 1 :style released-button))))) ;; '(mode-line-inactive ((default (:inherit mode-line)) (((class color) (min-colors 88) (background dark)) (:background "grey10" :foreground "grey80" :box (:line-width 1 :color "grey40") :weight light)))))