;; 28th July 2003 ;; Some macros from the Linux-Mandrake Configuration ;; Chmouel Boudjnah . ;; Thanks to Eric Marsden . (defmacro GNUEmacs (&rest x) (list 'if (string-match "GNU Emacs" (version)) (cons 'progn x))) (defmacro XEmacs (&rest x) (list 'if (string-match "XEmacs" (version)) (cons 'progn x))) (defmacro Xlaunch (&rest x) (list 'if (eq window-system 'x)(cons 'progn x))) ;; 29th July 2003 ;; From Alexander Mikhailian's .emacs (http://www.dotemacs.de/dotfiles/AlexanderMikhailian.emacs.html) (defmacro GNULinux (&rest x) (list 'if (string-match "linux" (prin1-to-string system-type)) (cons 'progn x))) (defmacro Windows (&rest x) (list 'if (string-match "windows" (prin1-to-string system-type)) (cons 'progn x))) (defmacro GNUEmacs23 (&rest x) (list 'if (string-match "GNU Emacs 23" (version)) (cons 'progn x))) ;;*************************************************************** ;; Windows specific customization begins. ;;*************************************************************** (Windows ;(set-background-color "DarkSlateGray") ;(set-foreground-color "Wheat") ;(set-cursor-color "White") ;(set-background-color "white smoke") ;(set-foreground-color "black") ;(set-cursor-color "black") (set-background-color "black") (set-foreground-color "white smoke") (set-cursor-color "White") (set-face-foreground 'modeline "black") ;;(set-face-background 'modeline "wheat3") (set-face-background 'modeline "AntiqueWhite3") ;; use this to check the fonts on your system (prin1-to-string (x-list-fonts "*")) ;(set-default-font "-*-Lucida Sans Unicode-normal-r-*-*-13-*-*-*-p-*-iso8859-15") (set-default-font "-outline-Lucida Console-normal-r-normal-normal-13-97-96-96-c-*-iso8859-15") ;;maximize window. (defun w32-maximize-frame () "Maximize the current frame" (interactive) (w32-send-sys-command 61488)) (w32-maximize-frame) ;; GNUSERV ;; For this, copy gnuserv.el into the lisp dir. (basically put it in the load-path) (load "gnuserv") (gnuserv-start) (setenv "GNUSERV_SHOW_EMACS" "1") ; force gnuserv to show emacs window, always (setq gnuserv-frame (selected-frame)) ) ; ;;*************************************************************** ;; Windows specific customization ends. ;;*************************************************************** (GNULinux (server-start) ) ;; started adding to this file on 24th Sept 2001 (setq column-number-mode t) ;; By default turn on colorization. (if (fboundp 'global-font-lock-mode) (global-font-lock-mode 1 t) ) (GNUEmacs (transient-mark-mode 1) ) (setq scroll-step 1) ;; Remove the startup message (setq inhibit-startup-message t) ;; Make all "yes or no" prompts show "y or n" instead (fset 'yes-or-no-p 'y-or-n-p) (global-set-key "\243" 'match-paren) ;M-# ;(global-set-key "%" 'match-paren) (defun match-paren (arg) "Go to the matching parenthesis if on parenthesis " (interactive "p") (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) ((looking-at "\\s\)") (forward-char 1) (backward-list 1)))) ;; Stop at the end of the file, not just add lines (setq next-line-add-newlines nil) ;; no backup files (setq make-backup-files nil) ;; 27th Nov 2001 (global-set-key (kbd "M-&") (quote goto-line)) ;M-& ;; 25th Dec 2001 - My first kbd-macro ;; "\C-x(" \C-y newline "\C-x)" ;; then gave it a name using M-x name-last-kbd-macro ;; then got the lisp code using M-x insert-kbd-macro RET macroname RET ;; Why did I need this? - wanted something similar to the np functionality in vi. ;; This can simulate that functionality - ^u n M-x yank_with_newline. (fset 'yank_with_newline "\C-y\C-m") (setq-default indent-tabs-mode nil) ;; Setup Emacs to run bash as its primary shell. (setq shell-file-name "bash") (setq shell-command-switch "-c") (setq explicit-shell-file-name shell-file-name) (setenv "SHELL" shell-file-name) (setq explicit-sh-args '("-login" "-i")) (if (boundp 'w32-quote-process-args) (setq w32-quote-process-args ?\")) ;; Include only for MS Windows ;; 9th Jan 2002 - I like it this way (set-variable 'c-basic-offset 4) (c-set-offset 'case-label '+) (put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) (setq frame-title-format "%b : %f") ; use C-TAB to switch between Emacs buffers (add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/ibs")) (require 'ibs) (add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp")) (require 'highline) '(highline-vertical t) (put 'narrow-to-region 'disabled nil) (highline-mode) ;; 29th July 2003 (delete-selection-mode t) ;; 29th July 2003 :: The next 2 functions (dos-unix and unix-dos) are from Steve Ackermann's .emacs file. ;;Convert DOS cr-lf to UNIX newline (defun dos-unix () (interactive) (goto-char (point-min)) (while (search-forward "\r" nil t) (replace-match ""))) ;;Convert UNIX newline to DOS cr-lf (defun unix-dos () (interactive) (goto-char (point-min)) (while (search-forward "\n" nil t) (replace-match "\r\n"))) (global-unset-key (kbd "C-/")) (global-set-key (kbd "C-/") (quote comment-region)) (global-set-key (kbd "C-.") (quote uncomment-region)) (add-hook 'text-mode-hook 'flyspell-mode) (add-hook 'latex-mode-hook 'flyspell-mode) (add-hook 'tex-mode-hook 'flyspell-mode) (add-hook 'bibtex-mode-hook 'flyspell-mode) ; Rectangles ! (global-set-key [(control f1)] 'delete-rectangle) ; Delete Rectangle (C-x r d) (global-set-key [(control f2)] 'kill-rectangle) ; Cut Rectangle (C-x r k) (global-set-key [(control f3)] 'yank-rectangle) ; Paste Rectangle (C-x r y) (global-set-key [(control f4)] 'open-rectangle) ; Blank+Shift Rectangle (C-x r o) (global-set-key [(control f5)] 'clear-rectangle) ; Blank Rectangle (C-x r o) (global-set-key [(control f6)] 'kill-region) ; Cut (C-w) (global-set-key [(control f7)] 'kill-ring-save) ; Copy (M-w) (global-set-key [(control f8)] 'yank) ; Paste (C-y) (global-set-key [M-f2] 'narrow-to-region) ; (C-x n n) (global-set-key [M-f3] 'widen) ; (C-x n w) ;; bookmarks ;(setq bm-restore-repository-on-load nil) ;(require 'bm) ;;*************************************************************** ;; From Soam's .emacs - Begin. ;;*************************************************************** (setq auto-mode-alist (append '(("Todo" . text-mode) ("TODO" . text-mode) ("INSTALL" . text-mode) ("README" . text-mode) ("\\.gnuplot\\'" . gnuplot-mode) ("\\.gp\\'" . gnuplot-mode)) auto-mode-alist)) (GNULinux (defun ch-colors (fgcolor bgcolor) "Set both foreground and background color at the same time. This is useful because switching from white-on-black to black-on-white requires a temporary color pair that is visible" (interactive "sForeground:\nsBackground:") (set-background-color bgcolor) (set-foreground-color fgcolor) ) ;; to prevent xterm from misbehaving (define-key function-key-map "\eO1;5A" [C-up]) (define-key function-key-map "\eO1;5B" [C-down]) (define-key function-key-map "\eO1;5C" [C-right]) (define-key function-key-map "\eO1;5D" [C-left]) ;; functions for quickly setting the colors (defun -dark () "" (interactive) (ch-colors "white" "black")) (defun -dark2 () "" (interactive) (ch-colors "grey75" "black")) (defun -bright () "" (interactive) (ch-colors "black" "white")) (defun -normal () "" (interactive) (ch-colors "white" "DarkSlateGray")) (GNUEmacs23 ;;(menu-bar-mode nil) ; get rid of the menu bar... (scroll-bar-mode -1) ; and scrollbars ... (tool-bar-mode -1) ; ...and the tool bar too! ;; use scroll mouse ;(setq mouse-wheel-scroll-amount '(4 . 1)) ;(mouse-wheel-mode 1) (-dark2) ;(set-frame-font "-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso8859-1") ;;(set-frame-font "-*-Andale Mono-normal-r-*-*-10-*-*-*-c-*-iso8859-2") ;;(set-frame-font "-raster-Dina-normal-r-normal-normal-10-75-96-96-c-*-iso8859-1") ;;(set-default-font "6x13") ;(set-default-font "7x14") ;(GNUEmacs23 ; goodness from http://g33k.wordpress.com/, http://peadrop.com/blog/2007/01/06/pretty-emacs/ (sudo apt-get install emacs-snapshot-gtk emacs-snapshot-el) ; start using "emacs-snapshot-gtk --enable-font-backend" ;(set-default-font "Bitstream Vera Sans Mono-10") (set-default-font "Bitstream Vera Sans Mono-12") ) ) (global-set-key (kbd "C-=") 'hippie-expand) ;; keybindings for hideshow (global-set-key [(control f9)] 'hs-hide-block) (global-set-key [(control f10)] 'hs-show-block) (global-set-key [(control f11)] 'hs-hide-level) (global-set-key [(control f12)] 'hs-show-all) ;; load hide-show mode (add-hook 'java-mode-hook 'hs-minor-mode) (add-hook 'c-mode-hook 'hs-minor-mode) (add-hook 'c++-mode-hook 'hs-minor-mode) (add-hook 'lisp-mode-hook 'hs-minor-mode) ;; load hide-show mode ;;(hs-minor-mode) ;; ;; iswitch mode initialization ;; (autoload 'iswitchb "iswitchb" "Run iswitchb" t) ;; (setq read-buffer-function 'iswitchb-read-buffer) ;; (setq iswitchb-default-method 'samewindow) ;; (add-hook 'iswitchb-make-buflist-hook 'iswitchb-summaries-to-end) ;; (iswitchb-default-keybindings) ;;*************************************************************** ;; From Soam's .emacs - End. ;;*************************************************************** ;;*************************************************************** ;; For JDEE - Begin. ;;*************************************************************** ;;;;;(add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/jde/lisp")) ;;;;;(add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/semantic")) ;;;;;(add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/speedbar")) ;;;;;(add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/elib")) ;;;;;(add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/eieio")) ;; If you want Emacs to defer loading the JDE until you open a Java file, ;; edit the following line ;(setq defer-loading-jde nil) ;; to read: (setq defer-loading-jde t) (if defer-loading-jde (progn (autoload 'jde-mode "jde" "JDE mode." t) (setq auto-mode-alist (append '(("\\.java\\'" . jde-mode)) auto-mode-alist))) (require 'jde)) ;; SEMANTIC ;(setq semantic-load-turn-everything-on t) (require 'semantic-load) (setq semanticdb-default-save-directory "~/tools/emacs/cache") ;; ECB ;;;;;(add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/ecb-1.95.1")) (require 'ecb) ;; does this have anything to do with ecb or jdee? (setq truncate-partial-width-windows nil) ;;*************************************************************** ;; For JDEE - END. ;;*************************************************************** ;;*************************************************************** ;; 30th July 2003 ;; HTML Helper mode - BEGIN ;;*************************************************************** (add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/html-helper")) (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t) (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist)) ;; Insert new document HTML template (setq html-helper-do-write-file-hooks t) ;; Enable time stamp (setq html-helper-build-new-buffer t) ;; Insert address (setq html-helper-address-string "Amar Phanishayee") ;; Enable hyperlink prompt (setq tempo-interactive t) ;;*************************************************************** ;; HTML Helper mode - END ;;*************************************************************** ;;*************************************************************** ;; Tiny Tools Setup - BEGIN ;;*************************************************************** (add-to-list 'load-path (expand-file-name "~/tools/emacs/site-lisp/tiny-tools/lisp/tiny")) (require 'tiny-setup) ;; load tinytf (setq tinytf-:mode-prefix-key "z") ; z is the default key anyway. (autoload 'tinytf-mode "tinytf" "" t) (autoload 'turn-on-tinytf-mode-maybe "tinytf" "" t) (setq tinytf-:mode-define-keys-hook '(tinytf-mode-define-keys tinytf-mode-define-f-keys)) (setq auto-mode-alist (cons '("\\.tf$" . tinytf-mode) auto-mode-alist)) ;;*************************************************************** ;; Tiny Tools Setup - END ;;*************************************************************** ;;*************************************************************** ;; Tabbar Setup - BEGIN ;;*************************************************************** (require 'tabbar) ;(global-set-key [(control f10)] 'tabbar-local-mode) ;(global-set-key [(f9)] 'tabbar-backward) ;(global-set-key [(f10)] 'tabbar-forward) (global-set-key [(f6)] 'tabbar-forward-tab) (global-set-key [(f5)] 'tabbar-backward-tab) (global-set-key [(f8)] 'tabbar-forward-group) (global-set-key [(f7)] 'tabbar-backward-group) (tabbar-mode) (setq tabbar-buffer-groups-function 'tabbar-buffer-ignore-groups) (defun tabbar-buffer-ignore-groups (buffer) "Return the list of group names BUFFER belongs to. Return only one group for each buffer." (with-current-buffer (get-buffer buffer) (cond ((or (get-buffer-process (current-buffer)) (memq major-mode '(comint-mode compilation-mode))) '("Process") ) ;; ((member (buffer-name) ;; '("*scratch*" "*Messages*")) ;; '("Common") ;; ) ;; ((eq major-mode 'dired-mode) ;; '("Dired") ;; ) ;; ((memq major-mode ;; '(help-mode apropos-mode Info-mode Man-mode)) ;; '("Help") ;; ) ;; ((memq major-mode ;; '(rmail-mode ;; rmail-edit-mode vm-summary-mode vm-mode mail-mode ;; mh-letter-mode mh-show-mode mh-folder-mode ;; gnus-summary-mode message-mode gnus-group-mode ;; gnus-article-mode score-mode gnus-browse-killed-mode)) ;; '("Mail") ;; ) (t (list "default" ;; no-grouping (if (and (stringp mode-name) (string-match "[^ ]" mode-name)) mode-name (symbol-name major-mode))) ) ))) ;;*************************************************************** ;; Tabbar Setup - END ;;*************************************************************** ;;*************************************************************** ;; AUCTEX Setup - BEGIN ;;*************************************************************** (Windows ;;; From Claus Dethlefsen's .emacs - Start ;;; ----------------------------------------------------------------- ;;; AUC TeX ; (add-to-list 'load-path "~/tools/emacs/site-lisp/auctex/") (add-to-list 'Info-default-directory-list "~/tools/emacs/site-lisp/auctex/doc/") (load "tex-site") ;; had to modify tex.el to read ;; ;; (defvar TeX-command-list ;; (list ;; (list "TeX" "tex \\\\nonstopmode\\\\input %t" 'TeX-run-TeX nil t) ;; Instead of: ;; (list (list "TeX" "tex '\\nonstopmode\\input %t'" 'TeX-run-TeX nil t) ;; ;;; ----------------------------------------------------------------- ;;; Reftex activation (Reftex is included with Emacs 21.1) ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t) (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil) (autoload 'reftex-citation "reftex-cite" "Make citation" nil) (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode (require 'tex-site) ; ;;; ----------------------------------------------------------------- ;;; For setting up printing through Ghostview ;;; Simply Press C-F5 to print current buffer ;;; (From the menu: Tools/print/Postscript print buffer) ; (setq ps-lpr-command "gsprint.exe") ;;; THis line causes ghostscript to query which printer to ;;; use - which you may not need if, for example, you only ;;; have one printer. (setq ps-lpr-switches '("-query")) (setq ps-printer-name t) ; ;;; Bind printing to M-F1 (global-set-key [M-f1] 'ps-print-buffer-with-faces) ;;; ---------------------------------------------------------------------- ;;; Info for Ispell (add-to-list 'Info-default-directory-list "c:/usr/local/info/") ; ;;; ----------------------------------------------------------------- ;;; AUC TeX -- extra goodies ;;; Extra commands for the Command-menu ;;; Halfsize can be called after File. From a postscript file foo.ps, ;;; it produces the file foo.2.ps with 2 pages per sheet. ;;; psnup comes with miktex ; (add-to-list 'TeX-command-list (list "HalfSize" "psnup -2 %f %s.2.ps" 'TeX-run-command nil t) ) ;;; After calling Halfsize, call Smallghostview to view foo.2.ps (add-to-list 'TeX-command-list (list "SmallGhostview" "gsview32.exe %s.2.ps" 'TeX-run-command nil t) ) ;;; Run necessary combinations of latex, bibtex, makeindex etc. (add-to-list 'TeX-command-list (list "All" "texify --tex-opt=--src %s.tex" 'TeX-run-command nil t) ) (add-to-list 'TeX-command-list (list "Clean" "del %s.log *.aux %s.out %s.exa %s.ilg %s.idx %s.ind %s.lof %s.lot %s.toc %s.bbl %s.blg %s.dvi %s.ps %s.2.ps %s.pdf" 'TeX-run-command nil t) ) (add-to-list 'TeX-command-list (list "All pdf" "texify --pdf %s.tex" 'TeX-run-command nil t) ) (add-to-list 'TeX-command-list (list "View pdf" "acrord32.exe %s.pdf" 'TeX-run-command nil t) ) ;;; From Claus Dethlefsen's .emacs - End ) ;;*************************************************************** ;; AUCTEX Setup - END ;;*************************************************************** (custom-set-variables ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(ecb-directory-face (quote ecb-directory-face)) '(ecb-history-face (quote ecb-history-face)) '(ecb-method-face (quote ecb-method-face)) '(ecb-source-face (quote ecb-source-face)) '(ecb-source-path (quote ("D:\\home\\Amar\\Yodlee\\gatherer\\mainline\\v1\\gather\\src" "D:\\home\\Amar\\Yodlee\\gatherer\\gatherer-service\\v1\\gather\\src" "D:\\home\\Amar\\Yodlee\\newarch" "D:\\home\\Amar\\Yodlee\\Orange\\mailwatch\\main"))) '(ecb-tip-of-the-day nil) '(ecb-token-header-face (quote ecb-token-header-face)) '(global-semantic-auto-parse-mode t nil (semantic-util-modes)) '(global-semantic-show-dirty-mode t nil (semantic-util-modes)) '(global-semantic-show-unmatched-syntax-mode t nil (semantic-util-modes)) '(global-semantic-summary-mode t nil (semantic-util-modes)) '(global-senator-minor-mode t nil (senator)) '(highline-line (quote (beyond . 80))) '(jde-bug-jpda-directory "D:\\home\\Amar\\tools\\jpda") '(jde-db-debugger (quote ("JDEbug" "" . "Executable")) t) '(jde-enable-abbrev-mode t) '(jde-jdk-doc-url "http://java.sun.com/j2se/1.3/docs/api/index.html") '(jde-jdk-registry (quote (("1.5" . "C:\\Java\\jdk1.5.0_03\\bin")))) '(semanticdb-project-roots (quote ("d:\\home\\Amar\\Yodlee\\newarch\\core\\main\\src" "d:\\home\\Amar\\Yodlee\\Orange\\mailwatch\\main\\src" "d:\\home\\Amar\\Yodlee\\gatherer\\gatherer-service\\v1\\gather\\src" "d:\\home\\Amar\\Yodlee\\gatherer\\mainline\\v1\\gather\\src"))) '(which-function-mode t nil (which-func))) ;; M-x customize-face ;; M-x list-colors-display (custom-set-faces ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(ecb-directory-face ((((class color) (background dark)) (:inherit ecb-default-highlight-face :background "dimgray")))) '(ecb-history-face ((((class color) (background dark)) (:inherit ecb-default-highlight-face :background "dimgray")))) '(ecb-method-face ((((class color) (background dark)) (:inherit ecb-default-highlight-face :background "dimgray")))) '(ecb-source-face ((((class color) (background dark)) (:inherit ecb-default-highlight-face :background "dimgray")))) '(ecb-token-header-face ((((class color) (background dark)) (:background "dimgray")))) '(flyspell-duplicate ((t (:foreground "green" :underline t :weight bold)))) '(font-lock-keyword-face ((((type tty) (class color)) (:foreground "saddle brown" :weight bold)))) '(highline-face ((t (:background "royal blue" :foreground "white")))) '(highline-vertical-face ((t (:background "slate gray")))) '(region ((nil (:background "royal blue" :foreground "grey")))) '(tabbar-default-face ((t (:inherit variable-pitch :background "grey" :foreground "black" :height 1.0)))) '(tabbar-selected-face ((t (:inherit tabbar-default-face :background "tan" :foreground "black" :box (:line-width 2 :color "white" :style released-button)))))) ; '(region ((((class color) (background light)) (:background "grey75")))) ; '(region ((nil (:background "royal blue" :foreground "black")))) ;; use a single buffer for dired mode (require 'dired-single) (defun my-dired-init () "Bunch of stuff to run for dired, either immediately or when it'sloaded." ;; add other stuff here (define-key dired-mode-map "_" 'joc-dired-single-buffer) (define-key dired-mode-map [mouse-1] 'joc-dired-single-buffer-mouse) (define-key dired-mode-map "^" (function (lambda nil (interactive) (joc-dired-single-buffer ".."))))) ;; if dired's already loaded, then the keymap will be bound (if (boundp 'dired-mode-map) ;; we're good to go; just add our bindings (my-dired-init) ;; it's not loaded yet, so add our bindings to the load-hook (add-hook 'dired-load-hook 'my-dired-init)) (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) ;; enable ruby-mode (autoload 'ruby-mode "ruby-mode" "Load ruby-mode") (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) (add-hook 'ruby-mode-hook 'turn-on-font-lock) (set-variable 'ruby-indent-level 4) ;; Time display doubles as a debug msg that the .emacs loaded without errors! ;; Display time in the mode line (setq display-time-day-and-date t) ;(setq display-time-24hr-format t) (display-time)