;; Deal with CUDA files (add-to-list 'auto-mode-alist '("\\.cu$" . c++-mode)) ;; Automatically indent new lines (define-key global-map (kbd "RET") 'newline-and-indent) ;; I love this mode (defun linux-c-mode () (interactive) (c-mode) (c-set-style "K&R") (setq tab-width 8) (setq indent-tabs-mode t) (setq c-basic-offset 8)) ;; Just in case someone set the mode in their files (setq c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "k&r"))) (setq c-basic-offset 8) ;; Display function name on the status bar (which-func-mode t) (add-to-list 'auto-mode-alist '("\\.\\(c\\|h\\)$" . linux-c-mode)) ;; some hack for Mac ;; First of all, I did the following key-remapping: ;; keyboard changed using keyremap4macbook ;; - F1~f12 now is Fn by default, to use their special functions, press fn ;; - Right command is ctrl now ;; - Cap locks is ctrl now (require 'mouse) (xterm-mouse-mode t) (defun track-mouse (e)) (setq mouse-sel-mode t) (mouse-wheel-mode t) ;; Move the annoying but sometime useful backups to a single place (setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/")))) ;; I don't have ispell on my Mac, use aspell instead (setq ispell-program-name "/usr/local/bin/aspell") ;; man current word, useful when needing documentations (global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word)))) ;; to deal with stupid xterm limit of wide terminal win (defun xterm-mouse-event-read () (let ((c (read-char))) (if (> c #x3FFF80) (+ 128 (- c #x3FFF80)) c))) ;; Show line and col numbers, programmers need it (line-number-mode t) (column-number-mode t) ;; Though I may not write Haskell any more... (load "~/emacs-sites/haskell-mode/haskell-site-file") (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) ;; Mousewheel, though I use CLI mode, mouse helps (defun sd-mousewheel-scroll-up (event) "Scroll window under mouse up by five lines." (interactive "e") (let ((current-window (selected-window))) (unwind-protect (progn (select-window (posn-window (event-start event))) (scroll-up 5)) (select-window current-window)))) (defun sd-mousewheel-scroll-down (event) "Scroll window under mouse down by five lines." (interactive "e") (let ((current-window (selected-window))) (unwind-protect (progn (select-window (posn-window (event-start event))) (scroll-down 5)) (select-window current-window)))) (global-set-key (kbd "") 'sd-mousewheel-scroll-up) (global-set-key (kbd "") 'sd-mousewheel-scroll-down) ;; This is really helpful! (global-set-key [f4] 'comment-line) (global-set-key [f5] 'uncomment-line) ;; comment line below the cursos (defun comment-line () (interactive) (beginning-of-line) (setq st (point)) (end-of-line) (setq en (point)) (if (> en st) (comment-region st en)) (next-line 1) ) ;; uncomment line below the cursos (defun uncomment-line () (interactive) (beginning-of-line) (setq st (point)) (end-of-line) (setq en (point)) (if (> en st) (uncomment-region st en)) (next-line 1) ) ;; Don't need to look up-right for current time (display-time) ;; perl mode collapse and unfold (defun perl-outline-mode () "set customized outline minor mode for Perl" (interactive) (setq outline-regexp "sub") ;; using "#!.\\|\\(pac\\)kage\\|sub\\|\\(=he\\)ad\\|\\(=po\\)d" ;; can deal with more block typs such as package and head, ;; but sometime it is not convenient to fold all code outside ;; the function scopes, such as global or constant vars defs. (outline-minor-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; For symbol indexing and source navigation (load-file "/usr/share/emacs/site-lisp/xcscope.el") (require 'xcscope) (setq cscope-do-not-update-database t)