Wednesday, September 28, 2011

;; My init.el file ;; Author: Nirmal ;; Revision: 0.1 ;; Date: April 6, 2011 ;; Descirption: init file for emacs on windows. This file is a comilation of intialization features from different sources ;; Windows specific installation ;; - HOME variable: C:\Emacs\ ;; - PATH variable: C:\cygwin\bin ;; requires Cygwin installation ;;-------------------------------------------------------------------- ;; set the load path ;;-------------------------------------------------------------------- ;;-------------------------------------------------------------------- ;; Color and Display related ;;-------------------------------------------------------------------- ;; color-theme package (add-to-list 'load-path "C:/Emacs/.emacs.d/plugins/color-theme-6.6.0") ;; load extra color-theme packages (load-file "~/.emacs.d/plugins/zenburn.el") (load-file "~/.emacs.d/plugins/color-theme-railscasts.el") (load-file "~/.emacs.d/plugins/color-theme-tango.el") (require 'color-theme) (eval-after-load "color-theme" '(progn (color-theme-initialize) ;; (color-theme-railscasts))) (color-theme-zenburn))) ;; hl-line: highlight the current line (when (fboundp 'global-hl-line-mode) (global-hl-line-mode t)) ;; turn it on for all modes by default ;; ;; To customize the background color ;; (set-face-background 'hl-line "#3f3f3f") ;; ;; see http://www.gnu.org/software/emacs/manual/html_node/emacs/Standard-Faces.html ;; (set-face-background 'modeline "#4466aa") ;; (set-face-background 'modeline-inactive "#555555") ;; (set-face-background 'fringe "#809088") ;; make the frame translucent (defun djcb-opacity-modify (&optional dec) "modify the transparency of the emacs frame; if DEC is t, decrease the transparency, otherwise increase it in 10%-steps" (let* ((alpha-or-nil (frame-parameter nil 'alpha)) ; nil before setting (oldalpha (if alpha-or-nil alpha-or-nil 100)) (newalpha (if dec (- oldalpha 10) (+ oldalpha 10)))) (when (and (>= newalpha frame-alpha-lower-limit) (<= newalpha 100)) (modify-frame-parameters nil (list (cons 'alpha newalpha)))))) ;; C-8 will increase opacity (== decrease transparency) ;; C-9 will decrease opacity (== increase transparency ;; C-0 will returns the state to normal (global-set-key (kbd "C-8") '(lambda()(interactive)(djcb-opacity-modify))) (global-set-key (kbd "C-9") '(lambda()(interactive)(djcb-opacity-modify t))) (global-set-key (kbd "C-0") '(lambda()(interactive) (modify-frame-parameters nil `((alpha . 100))))) ;;-------------------------------------------------------------------- ;; General Settings ;;-------------------------------------------------------------------- ;; Move point to a given line number (global-set-key (kbd "M-g") 'goto-line) ;; ignore case when reading a buffer name (setq read-buffer-completion-ignore-case t) ;; where to save the bookmarks (setq bookmark-default-file "~/.emacs.d/bookmarks.txt") ;; each command that sets a bookmark will also save your bookmarks (setq bookmark-save-flag 1) ;; visually indicate buffer boundaries and scrolling (setq indicate-buffer-boundaries t) ;; highlight trailing whitespaces in all modes ;; (setq-default show-trailing-whitespace t) ;; show line numbers (global-linum-mode 1) ;; show the line number in each mode line (line-number-mode 1) ;; show the column number in each mode line (column-number-mode 1) ;; use inactive face for mode-line in non-selected windows (setq mode-line-in-non-selected-windows t) ;; see what I'm typing *immediately* (setq echo-keystrokes 0.01) ;; searches and matches should ignore case (setq-default case-fold-search t) (setq default-case-fold-search t) ; FIXME obsolete since Emacs 23.2, but ; still needed!? ;; `M-x flush-lines' deletes each line that contains a match for REGEXP ;; visit a file (global-set-key (kbd "") 'find-file) ;; open my Emacs init file (defun my-open-dot-emacs () "Opening `~/.emacs.d/init.el'." (interactive) (find-file "~/.emacs.d/init.el")) (global-set-key (kbd "") 'my-open-dot-emacs) ;; insert date - global key (global-set-key (kbd "C-c .") 'insert-date) (menu-bar-mode t) ;; show the menu... (mouse-avoidance-mode 'jump) ;; mouse ptr when cursor is too close (tool-bar-mode -1) ;; turn-off toolbar (setq search-highlight t ;; highlight when searching... query-replace-highlight t) ;; ...and replacing (fset 'yes-or-no-p 'y-or-n-p) ;; enable y/n answers to yes/no (setq completion-ignore-case t ;; ignore case when completing... read-file-name-completion-ignore-case t) ;; ...filenames too (setq initial-scratch-message ";; scratch buffer created -- happy hacking\n") (setq-default frame-title-format '(:eval (format "%s@%s:%s" (or (file-remote-p default-directory 'user) user-login-name) (or (file-remote-p default-directory 'host) system-name) (file-name-nondirectory (or (buffer-file-name) default-directory))))) (put 'narrow-to-region 'disabled nil) ;; enable... (put 'erase-buffer 'disabled nil) ;; ... useful things (file-name-shadow-mode t) ;; be smart about filenames in mbuf (setq inhibit-startup-message t ;; don't show ... inhibit-startup-echo-area-message t) ;; ... startup messages (setq require-final-newline t) ;; end files with a newline (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. '(ispell-dictionary "british") '(ispell-program-name "~/Aspell/bin/aspell.exe") '(weblogger-config-alist (quote (("default" "http://www.blogger.com/api" "nirmal7878" "" "6046084315726461172"))))) ;;(setq ispell-program-name "~/Aspell/bin/aspell.exe" ;; ispell-extra-args '("--sug-mode=ultra")) (setq text-mode-hook '(lambda() (flyspell-mode t) ; spellchek (sic) on the fly )) ;; compare text in current window with text in next window (global-set-key (kbd "C-c =") 'compare-windows) ;;;;;;;;;;;;;;;; FIXME Conflict with reftex ; Highlighting ; highlight region between point and mark (transient-mark-mode t) ; highlight during query (setq query-replace-highlight t) ; highlight incremental search (setq search-highlight t) ; Don't show matching parens (show-paren-mode 1) ;Make emacs indent code with 4 spaces instead of tabs for C and C++ modes (setq verilog-mode-hook (function (lambda () (setq indent-tabs-mode nil) (setq c-indent-level 4)))) (setq c-mode-hook (function (lambda () (setq indent-tabs-mode nil) (setq c-indent-level 4)))) (setq c++-mode-hook (function (lambda () (setq indent-tabs-mode nil) (setq c-indent-level 4)))) ;;-------------------------------------------------------------------- ;; Dired Mode ;;-------------------------------------------------------------------- ;; Using the Emacs Dired utility, you can compress or uncompress a file by ;; pressing `Z' ;;-------------------------------------------------------------------- ;; Scrolling Related ;;-------------------------------------------------------------------- (load-file "~/.emacs.d/plugins/smooth-scroll.el") (require 'smooth-scroll) (smooth-scroll-mode t) (setq redisplay-dont-pause t scroll-margin 1 scroll-step 1 scroll-conservatively 10 scroll-preserve-screen-position 1) ;;-------------------------------------------------------------------- ;; Cygwin settings ;;-------------------------------------------------------------------- ;; Load cygwin-mount.el package (load-file "~/.emacs.d/plugins/cygwin-mount.el") (setenv "PATH" (concat "c:/cygwin/bin;" (getenv "PATH"))) (setq exec-path (cons "c:/cygwin/bin/" exec-path)) (require 'cygwin-mount) (cygwin-mount-activate) ;; replace DOS shell with Cygwin shell ;; Ref: http://henrykautz.org/Computers/using_the_gnu_development_enviro.htm (defun my-shell-setup () "For bash (cygwin 18) under Emacs 20" (setq comint-scroll-show-maximum-output 'this) (setq comint-completion-addsuffix t) (setq comint-eol-on-send t) (setq comint-file-name-quote-list '(?\ ?\")) (setq w32-quote-process-args ?\") (make-variable-buffer-local 'comint-completion-addsuffix) (setq shell-dirstack-query "cygpath -w `dirs`") (add-hook 'comint-output-filter-functions 'perfect-track-directory nil t) (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m nil t) ) (defun perfect-track-directory (text) (if (string-match "\\w*Working directory is ||\\([^|]+\\)||" text) (cd (substring text (match-beginning 1) (match-end 1))))) (setq shell-mode-hook 'my-shell-setup) (setq process-coding-system-alist (cons '("bash" . undecided-unix) process-coding-system-alist)) (setq exec-path (cons "C:/cygwin/bin" (cons "C:/cygwin/usr/bin" (cons "C:/cygwin/usr/local/bin" exec-path)))) (setenv "PATH" (concat "C:\\cygwin\\bin;C:\\cygwin\\usr\\bin;C:\\cygwin\\usr\\local\\bin" (getenv "PATH"))) (setq shell-file-name "bash") (setenv "SHELL" shell-file-name) (setq explicit-shell-file-name shell-file-name) (cd "~") ;; make shell and emacs in sysnc (global-set-key "\M-\r" 'shell-resync-dirs) ;; Ref: http://www.khngai.com/emacs/cygwin.php (add-hook 'shell-mode-hook 'n-shell-mode-hook) (defun n-shell-mode-hook () "nirmal, shell mode customizations." (local-set-key '[up] 'comint-previous-input) (local-set-key '[down] 'comint-next-input) (local-set-key '[(shift tab)] 'comint-next-matching-input-from-input) (setq comint-input-sender 'n-shell-simple-send) ) (defun n-shell-simple-send (proc command) "Various commands pre-processing before sending to shell." (cond ;; Checking for clear command and execute it. ((string-match "^[ \t]*clear[ \t]*$" command) (comint-send-string proc "\n") (erase-buffer) ) ;; Checking for man command and execute it. ((string-match "^[ \t]*man[ \t]*" command) (comint-send-string proc "\n") (setq command (replace-regexp-in-string "^[ \t]*man[ \t]*" "" command)) (setq command (replace-regexp-in-string "[ \t]+$" "" command)) ;;(message (format "command %s command" command)) (funcall 'man command) ) ;; Send other commands to the default handler. (t (comint-simple-send proc command)) ) ) ;;-------------------------------------------------------------------- ;; Verilog Mode ;; Ref: http://www.veripool.org/wiki/verilog-mode/Installing ;; Ref: http://www.verilog.com/emacs_install.html ;;-------------------------------------------------------------------- (defun prepend-path ( my-path ) (setq load-path (cons (expand-file-name my-path) load-path))) (defun append-path ( my-path ) (setq load-path (append load-path (list (expand-file-name my-path))))) ;; Look first in the directory ~/elisp for elisp files (prepend-path "~/elisp") ;; Load verilog mode only when needed ;; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t ) ;; Any files that end in .v, .dv or .sv should be in verilog mode (add-to-list 'auto-mode-alist '("\\.[ds]?v\\'" . verilog-mode)) ;; Any files in verilog mode should have their keywords colorized (add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1))) ;;-------------------------------------------------------------------- ;; Font Settings ;;-------------------------------------------------------------------- (set-default-font ; "-outline-Consolas-normal-r-normal-normal-13-97-96-96-c-*-iso8859-1") "-outline-Consolas-normal-r-normal-normal-12-90-96-96-c-*-iso8859-1") (put 'dired-find-alternate-file 'disabled nil) ; Use 10-pt Consolas as default font ;(set-face-attribute 'default nil ; :family "Consolas" :height 100) ;;-------------------------------------------------------------------- ;; TRAMP Configuration for remote files ;;-------------------------------------------------------------------- ;; (setq tramp-default-method "pscp") (setq tramp-default-method "plink") ;;(setq tramp-default-method "ssh") (prefer-coding-system 'utf-8) (setq tramp-password-end-of-line "\r\n") (setq tramp-verbose 10) ;; (require 'tramp) ;; (setq tramp-verbose 10) ;; (setq tramp-debug-buffer t) ;; (setq tramp-disable-ange-ftp) ;; (setq tramp-default-method "plink") ;; (setq tramp-ftp-method "scp") ;; (setq tramp-default-user "user-name") ;; (setq tramp-default-host "host-name-or-ip") ;;-------------------------------------------------------------------- ;; open files in dired mode ;;-------------------------------------------------------------------- (defun open-externally (filename) (shell-command (concat "rundll32 shell32,ShellExec_RunDLL " (shell-quote-argument filename)))) (defun is-file-type? (filename type) (string= type (substring filename (- (length filename) (length type))))) (defun should-open-externally? (filename) (let ((file-types '(".pdf" ".doc" ".xls"))) (member t (mapcar #'(lambda (type) (is-file-type? filename type)) file-types)))) (defadvice find-file (around find-file-external-file-advice (filename &optional wildcards)) "Open non-emacs files with an appropriate external program" (if (should-open-externally? filename) (open-externally filename) ad-do-it)) (ad-activate 'find-file) ;;; This was installed by package-install.el. ;;; This provides support for the package system and ;;; interfacing with ELPA, the package archive. ;;; Move this code earlier if you want to reference ;;; packages in your .emacs. (when (load (expand-file-name "~/.emacs.d/elpa/package.el")) (package-initialize)) (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. ) ;;-------------------------------------------------------------------- ;; post blogs to wordpress.com ;; Ref: http://watchingthewatchers.org/indepth/1388286/post-wordpress-blogs-emacs-org-mode ;; To start wrigint a new post, you can now use M-x org2blog/wp-new-entry ;; Or, post a subtree of an existing org file using: M-x org2blog/wp-post-subtree ;;-------------------------------------------------------------------- ;; (add-to-list 'load-path "~/.emacs.d/elpa/xml-rpc-1.6.7") ;; (load-file "~/.emacs.d/elpa/xml-rpc-1.6.7/xml-rpc.el") ;;(setq load-path (cons "c:/emacs/.emacs.d/elpa/xml-rpc-1.6.7/" load-path)) (setq load-path (cons "C:/emacs/.emacs.d/plugins/org2blogs/" load-path)) (require 'org2blog-autoloads) (setq org2blog/wp-blog-alist '(("wordpress" :url "http://shalinirmal.wordpress.com/xmlrpc.php" :username "shalinirmal" :default-title "Hello World" :default-categories ("org2blog" "emacs") :tags-as-categories nil) ("my-blog" :url "http://shalinirmal.server.com/xmlrpc.php" :username "admin")))

No comments: