Skip to content

Instantly share code, notes, and snippets.

@pratul
Created July 6, 2009 08:23
Show Gist options
  • Save pratul/141341 to your computer and use it in GitHub Desktop.
Save pratul/141341 to your computer and use it in GitHub Desktop.
;; ~/.emacs@foobar - Prashanth <munichlinux@gmail.com> -*- emacs-lisp -*-
;; --------------
;; Common Lisp
;; --------------
(require 'cl)
;; ---------------------
;; General Customisation
;; ---------------------
(defvar *home-dir* "/home/prashanth/")
(setq inhibit-startup-message t)
(add-to-list 'load-path (concatenate 'string *home-dir* ".emacs.d"))
(add-to-list 'load-path (concatenate 'string *home-dir* ".emacs.d/template"))
(add-to-list 'load-path (concatenate 'string *home-dir* ".emacs.d/color-theme"))
(add-to-list 'load-path (concatenate 'string *home-dir* ".emacs.d/php-mode"))
(add-to-list 'load-path (concatenate 'string *home-dir* ".emacs.d/tramp/lisp"))
(add-to-list 'load-path (concatenate 'string *home-dir* ".emacs.d/yasnippet"))
(setq font-lock-maximum-decoration t)
(setq visible-bell t)
(setq require-final-newline t)
(setq resize-minibuffer-frame t)
(setq column-number-mode t)
(setq-default transient-mark-mode t)
(setq next-line-add-newlines nil)
(setq blink-matching-paren t)
(setq blink-matching-delay .25)
(global-font-lock-mode 1 t)
(tool-bar-mode -1)
(menu-bar-mode -1)
(tooltip-mode -1)
(show-paren-mode t)
(set-scroll-bar-mode 'nil)
(savehist-mode 1)
(setq truncate-partial-width-windows nil)
(setq x-select-enable-clipboard t)
;; ----------------------
;; Final newline handling
;; ----------------------
(setq require-final-newline t)
(setq next-line-extends-end-of-buffer nil)
(setq next-line-add-newlines nil)
;; -------------------
;; Everything in UTF-8
;; -------------------
(prefer-coding-system 'utf-8)
(set-language-environment 'UTF-8)
(set-default-coding-systems 'utf-8)
(setq file-name-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq coding-system-for-write 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(setq default-process-coding-system '(utf-8 . utf-8))
;; ----------------------
;; Don't take any backups
;; ----------------------
(setq backup-inhibited t)
;; -----------
;; Frame Setup
;; -----------
(setq initial-frame-alist '((top . 58)
(left . 10)
(width . 155)
(height . 55)))
(setq frame-title-format "%b")
(setq icon-title-format "%b")
;; ---------
;; TAB Setup
;; ---------
(setq-default tab-width 4
standard-indent 4
indent-tabs-mode nil
tab-width 8)
;; -----------------
;; Misc key mappings
;; -----------------
(global-set-key [f1] 'search-forward)
(global-set-key [f3] 'search-backward)
(global-set-key [f2] 'replace-string)
(global-set-key [f4] 'set-justification-full) ;JUSTIFY
(global-set-key [f6] 'kill-ring-save) ;COPY
(global-set-key [f7] 'yank) ;PASTE
(global-set-key [f8] 'kill-region) ;DELETE
(global-set-key [f9] 'save-buffer) ;SAVE
(global-set-key [C-f7] 'compile) ;COMPILE
(global-set-key [C-f1] 'eshell) ;ESHELL
(global-set-key "\C-ca" 'auto-fill-mode)
(global-set-key "\C-cw" 'woman) ;WOMAN
;; 'y' for 'yes', 'n' for 'no'
(fset 'yes-or-no-p 'y-or-n-p)
(setq query-replace-highlight t)
(setq search-highlight t)
(global-set-key (kbd "RET") 'newline-and-indent)
;; -----------------
;; Insert time stamp
;; -----------------
(defun insert-date ()
"Insert current date and time."
(interactive "*")
(insert (current-time-string)))
;; ----------------------------------------
;; Kill current buffer without confirmation
;; ----------------------------------------
(global-set-key "\C-xk" 'kill-current-buffer)
(defun kill-current-buffer ()
"Kill the current buffer, without confirmation."
(interactive)
(kill-buffer (current-buffer)))
;; ---------
;; Automodes
;; ---------
(require 'css-mode)
(setq auto-mode-alist (append '(
("\\.py$" . python-mode)
("\\.conf$" . conf-mode)
("\\.sh$" . shell-script-mode)
("\\.txt$" . text-mode)
("\\.lua$" . lua-mode) ; Lua ;)
("\\.js$" . javascript-mode)
("\\.lisp" . lisp-mode)
("\\.php" . php-mode)
("\\.css" . css-mode)
) auto-mode-alist))
;; ---------
;; Autoloads
;; ---------
(require 'template)
(require 'smooth-scrolling)
(require 'w3m)
(require 'color-theme)
(autoload 'paredit-mode "paredit"
"Minor mode for pseudo-structurally editing Lisp code."
t)
;; -------------
;; Custom colors
;; -------------
(color-theme-initialize)
(color-theme-clarity)
;(set-default-font "DejaVu Sans Mono-10")
;; ------------
;; General Info
;; ------------
(setq user-mail-address "prasanth.gopinath@brijj.com")
(setq user-full-name "Prashanth")
;; --------------------
;; Several useful hooks
;; --------------------
(add-hook 'before-save-hook 'time-stamp)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;; ------
;; Python
;; ------
(setq python-mode-hook
'(lambda () (progn
(set-variable 'py-indent-offset 1)
(set-variable 'py-smart-indentation nil)
(set-variable 'indent-tabs-mode nil))))
(eval-after-load "python-mode"
'(progn
(add-hook 'python-mode-hook 'auto-fill-mode)))
;; -----
;; WoMan
;; -----
(setq-default woman-use-own-frame nil)
(setq-default Man-notify-method 'pushy)
;; Remember
(eval-after-load "remember"
'(progn
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(define-key global-map [(control meta ?r)] 'remember)))
;; -----
;; Tramp
;; -----
(eval-after-load "tramp"
'(progn
(setq tramp-default-method "ssh")))
;; W3M
(eval-after-load "w3m"
'(progn
(setq w3m-toggle-inline-images-permanently t)
(setq w3m-use-cookies t)
(setq browse-url-browser-function 'w3m-browse-url
browse-url-new-window-flag t)))
;; Environment variables for Emacs & Oracle
(setenv "HOME" "/home/prashanth")
;; Cool utility function to refresh all open buffers
(defun revert-all-buffers()
"Refreshs all open buffers from their respective files"
(interactive)
(let* ((list (buffer-list))
(buffer (car list)))
(while buffer
(if (string-match "\\*" (buffer-name buffer))
(progn
(setq list (cdr list))
(setq buffer (car list)))
(progn
(set-buffer buffer)
(revert-buffer t t t)
(setq list (cdr list))
(setq buffer (car list))))))
(message "Refreshing open files"))
;; Custom files
(setq custom-file "~/.emacs-custom.el")
(load custom-file 'noerror)
(put 'upcase-region 'disabled nil)
;;----------------------
;;ibuffer
;;----------------------
;;(iswitchb-default-keybindings)
(iswitchb-mode 1)
(autoload 'iswitchb "iswitchb" "Run iswitchb" t)
(setq read-buffer-function 'iswitchb-read-buffer)
(setq iswitchb-default-method 'samewindow)
(defun iswitchb-local-keys ()
(mapc (lambda (K)
(let* ((key (car K)) (fun (cdr K)))
(define-key iswitchb-mode-map (edmacro-parse-keys key) fun)))
'(("<right>" . iswitchb-next-match)
("<left>" . iswitchb-prev-match)
("<up>" . ignore )
("<down>" . ignore ))))
;;(require 'ido)
;;(ido-mode t)
(add-hook 'iswitchb-define-mode-map 'iswitchb-local-keys)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; M-x webjump
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq webjump-sites '(("hunchentoot" . "file:///home/prashanth/.asdf-install-dir/site/hunchentoot/doc/index.html")
("cl-ppcre" . "file:///home/prashanth/.asdf-install-dir/site/cl-ppcre-1.3.2/doc/index.html")
("html-template" . "file:///home/prashanth/.asdf-install-dir/site/html-template-0.9.1/doc/index.html")
("clsql" . "file:///home/prashanth/Documents/Lisp/clsql/html/index.html")
("s-xml" . "file:///home/prashanth/.asdf-install-dir/site/s-xml/doc/S-XML.html")
("cl-memcached" . "http://common-lisp.net/project/cl-memcached/")
("flexi-streams" . "file:///home/prashanth/.asdf-install-dir/site/flexi-streams-0.14.0/doc/index.html")
("cl-store" . "http://common-lisp.net/project/cl-store/docs/cl-store.html")
("date-calc" . "file:///home/prashanth/.asdf-install-dir/site/index.html")
("cmucl" . "file:///home/prashanth/Documents/Lisp/Books/CMUCL User's Manual/cmu-user/index.html")
("acl" . "file:///opt/acl80/doc/contents.htm")
("mop" . "file:///opt/acl80/doc/mop/contents.html")
("sbcl-user" . "file:///usr/share/doc/sbcl-doc/html/sbcl/index.html")
("sbcl-internals" . "file:///usr/share/doc/sbcl-doc/html/sbcl-internals/index.html")
("cl-cookbook" . "http://cl-cookbook.sourceforge.net/index.html")))
;;;;;;;;;;;;
;;java script
;;;;;;;;;;;
(autoload 'javascript-mode "javascript" nil t)
(add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode))
;;
;; css
;;
(autoload 'css-mode "css-mode")
(setq auto-mode-alist
(cons '("\\.css\\'" . css-mode) auto-mode-alist))
;;
;;php mode
;;
(load-file "/home/prashanth/.emacs.d/php-mode/php-mode.el")
(autoload 'php-mode "php-mode" "PHP editing mode" t)
(add-to-list 'auto-mode-alist '("\\.php3\\'" . php-mode))
(add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))
(autoload 'php-mode "php-mode" "PHP editing mode" t)
;;;;
;;tramp
;;;;
(require 'tramp)
;;(setq tramp-default-method "ssh")
(defun th-rename-tramp-buffer ()
(when (file-remote-p (buffer-file-name))
(rename-buffer
(format "%s:%s"
(file-remote-p (buffer-file-name))
(buffer-name)))))
(add-hook 'find-file-hook
'th-rename-tramp-buffer)
(defadvice find-file (around th-find-file activate)
"Open FILENAME using tramp's sudo method if it's read-only."
(if (and (not (file-writable-p (ad-get-arg 0)))
(y-or-n-p (concat "File "
(ad-get-arg 0)
" is read-only. Open it as root? ")))
(th-find-file-sudo (ad-get-arg 0))
ad-do-it))
(defun th-find-file-sudo (file)
"Opens FILE with root privileges."
'file
(interactive "f")
(set-buffer (find-file (concat "/sudo::" file))))
;;;;;
;;
;;
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "/home/prashanth/.emacs.d/yasnippet/snippets/")
(setq comint-buffer-maximum-size 10240)
;; --------
;; JS2 Mode
;; --------
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(setq js2-use-font-lock-faces t)
;;;;;;
;nav
;;;;
(require 'nav)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment