User:MoraSique/.emacs
From RHLUG
File: .emacs
(add-to-list 'load-path "/home/mrozekma/.emacs.d/el")
(setq inhibit-startup-message t)
; Backups
(setq backup-by-copying t)
(custom-set-variables
'(backup-directory-alist (quote (("." . "/home/mrozekma/.emacs.d/backups"))))
'(display-time-mode nil)
'(load-home-init-file t t)
'(menu-bar-mode t)
'(paren-mode (quote blink-paren) nil (paren))
'(tabbar-background-color "black")
'(tool-bar-mode nil)
'(transient-mark-mode t))
; Ido
;(require 'ido)
;(ido-mode t)
; Tramp
(setq tramp-default-method "scp")
; No menu bar
(menu-bar-mode -1)
; Show active region
(transient-mark-mode)
; Line numbers
(require 'linum)
;(global-linum-mode 1)
; Syntax highlighting
(custom-set-faces
'(font-latex-math-face ((((class color) (background light)) (:foreground "purple"))))
'(font-lock-comment-face ((nil (:foreground "red"))))
'(linum ((t (:inherit shadow :foreground "yellow" :weight bold))))
'(minibuffer-prompt ((t (:background "white" :foreground "black"))))
'(mode-line ((t (:background "green" :foreground "black"))))
'(smerge-markers ((((background light)) (:background "grey35"))))
'(tabbar-button ((t (:inherit tabbar-default :background "black" :foreground "grey" :box nil))))
'(tabbar-button-face ((t (:inherit tabbar-default-face :background "black" :foreground "dark red" :box nil))))
'(tabbar-default ((t (:inherit variable-pitch :background "black" :foreground "red" :strike-through t :height 0.8))))
'(tabbar-default-face ((t (:inherit variable-pitch :background "black" :foreground "gray60" :underline nil :height 0.8))))
'(tabbar-selected ((t (:inherit tabbar-default :background "white" :foreground "red" :box nil))))
'(tabbar-selected-face ((t (:inherit tabbar-default-face :background "white" :foreground "blue" :box nil))))
'(tabbar-separator ((t (:inherit tabbar-default :foreground "green" :height 0.7))))
'(tabbar-unselected ((t (:inherit tabbar-default :background "black" :foreground "blue" :box nil)))))
; Highlight parentheses
(require 'highlight-parentheses)
; Tab width
(setq default-tab-width 4)
(setq-default c-basic-offset 4)
(setq-default py-basic-offset 4)
; Allow y/n input instead of yes/no
(fset 'yes-or-no-p 'y-or-n-p)
; Breadcrumb trail
(require 'breadcrumb)
(define-prefix-command 'breadcrumb-prefix)
(global-set-key [(control b)] 'breadcrumb-prefix)
(global-set-key [(control b)(control @)] 'bc-set)
(global-set-key [(control b)(left)] 'bc-previous)
(global-set-key [(control b)(right)] 'bc-next)
(global-set-key [(control b)(control b)] 'bc-list)
(global-set-key [(control b)(control c)] 'bc-clear)
(setq enable-recursive-minibuffers t)
; Scrolling without moving cursor
(defun scroll-down-keep-cursor ()
;; Scroll the text one line down while keeping the cursor
(interactive)
(scroll-down 1))
(defun scroll-up-keep-cursor ()
;; Scroll the text one line up while keeping the cursor
(interactive)
(scroll-up 1))
(global-set-key [(control up)] 'scroll-down-keep-cursor)
(global-set-key [(control down)] 'scroll-up-keep-cursor)
; Snippets
(add-to-list 'load-path "/home/mrozekma/.emacs.d/el/yasnippet-0.5.5")
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "/home/mrozekma/.emacs.d/el/yasnippet-0.5.5/snippets/")
; Backspace deletes the region
(delete-selection-mode 1)
; Show an actual lambda instead of the string "lambda" in lisp and scheme modes
(defun pretty-lambdas ()
(font-lock-add-keywords
nil `(("(\\(lambda\\>\\)"
(0 (progn (compose-region (match-beginning 1) (match-end 1)
,(make-char 'greek-iso8859-7 107))
nil))))))
(add-hook 'emacs-lisp-mode-hook 'pretty-lambdas)
(add-hook 'scheme-mode-hook 'pretty-lambdas)
; Called from todo script
(defun start-todo ()
(global-linum-mode 0)
(find-file "/home/mrozekma/todo")
(org-mode))
; Tabbar
(require 'tabbar)
(tabbar-mode)
; Highlight trailing whitespace
(setq-default show-trailing-whitespace t)
(require 'browse-kill-ring)
; Auto-indent text pasted into programming buffers
(defvar yank-indent-modes '(emacs-lisp-mode
c-mode c++-mode
tcl-mode sql-mode
perl-mode cperl-mode
java-mode jde-mode
lisp-interaction-mode
LaTeX-mode TeX-mode)
"Modes in which to indent regions that are yanked (or yank-popped)")
(defvar yank-advised-indent-threshold 1000
"Threshold (# chars) over which indentation does not automatically occur.")
(defun yank-advised-indent-function (beg end)
"Do indentation, as long as the region isn't too large."
(if (<= (- end beg) yank-advised-indent-threshold)
(indent-region beg end nil)))
(defadvice yank (after yank-indent activate)
"If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)."
(if (and (not (ad-get-arg 0))
(member major-mode yank-indent-modes))
(let ((transient-mark-mode nil))
(yank-advised-indent-function (region-beginning) (region-end)))))
(defadvice yank-pop (after yank-pop-indent activate)
"If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)."
(if (and (not (ad-get-arg 0))
(member major-mode yank-indent-modes))
(let ((transient-mark-mode nil))
(yank-advised-indent-function (region-beginning) (region-end)))))
; Spellchecking
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
(add-hook 'text-mode-hook 'turn-on-flyspell)
(add-hook 'c-mode-common-hook 'flyspell-prog-mode)
(add-hook 'tcl-mode-hook 'flyspell-prog-mode)
(defun turn-on-flyspell ()
"Force flyspell-mode on using a positive arg. For use in hooks."
(interactive)
(flyspell-mode 1))
; Abbreviations
(require 'pabbrev)
(global-pabbrev-mode)
(global-set-key (kbd "<backtab>") 'pabbrev-expand-maybe)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(add-hook 'LateX-mode-hook 'turn-on-reftex)
(add-hook 'latex-mode-hook 'turn-on-reftex)
; PHP major mode
(require 'php-mode)
; Function to compile a TeX document
(defun tex-compile ()
""
(interactive)
(message "LaTeX - Typesetting")
(shell-command-to-string (concat "/home/mrozekma/scripts/tex-compile " (substring buffer-file-name 0 -4)))
(message "LaTeX - Done"))
(define-prefix-command 'my-hotkey-prefix)
(global-set-key [(control x)(control m)] 'my-hotkey-prefix)
(global-set-key [(control x)(control m)(l)] 'global-linum-mode)
(global-set-key [(control x)(control m)(t)] 'tex-compile)
(global-set-key [(control x)(control m)(c)] 'compile)
; Permanently enable narrow-to-region
(put 'narrow-to-region 'disabled nil)

