Skip to content

Instantly share code, notes, and snippets.

@pwl
Created January 26, 2010 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwl/287282 to your computer and use it in GitHub Desktop.
Save pwl/287282 to your computer and use it in GitHub Desktop.
;;;;;;;;;;;;;;;;
;;; LOADPATH ;;;
;;;;;;;;;;;;;;;;
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "~/.emacs.d/xref")
;; (add-to-list 'exec-path "~/.emacs.d/xref")
;;;;;;;;;;;;;;;;;;
;;; APPEARANCE ;;;
;;;;;;;;;;;;;;;;;;
;; set the color theme
(require 'color-theme)
(color-theme-dark-laptop)
;; turn off the toolbar and menu bar
(menu-bar-mode 0)
(tool-bar-mode 0)
;; enlarge font
(set-face-attribute 'default nil :height 160)
;; full screen on startup
(defun fullscreen (&optional f)
(interactive)
(set-frame-parameter f 'fullscreen
(if (frame-parameter f 'fullscreen) nil 'fullboth)))
(set-face-foreground 'font-lock-warning-face "yellow")
(setq show-trailing-whitespace t)
(font-lock-add-keywords nil
'(("\\<\\(FIXME\\|TODO\\|BUG\\):" 1 font-lock-warning-face t)))
(global-font-lock-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; GENERAL FUNCTIONALITY ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SETTINGS
;; disable backup files
(setq make-backup-files nil)
;; disable auto save mode
(setq auto-save-default nil)
;; enable x-clipboard
(setq x-select-enable-clipboard t)
;;initialize emacs-server
;; (server-start)
;; personal data
(setq user-full-name "Pawel Biernat")
(setq user-mail-address "pawel.biernat@gmail.com")
;; tide the file a bit befor saving it
(setq require-final-newline t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; make all the buffer names uniq depending of the context
(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse)
(setq uniquify-separator "|")
(setq uniquify-after-kill-buffer-p t)
(setq uniquify-ignore-buffers-re "^\\*")
;; TRAMP
;; proxy for shiva
(require 'tramp)
;; (setq tramp-default-method "ssh")
;; (add-to-list 'tramp-default-proxies-alist
;; '("shiva" "biernat" "/ssh:biernat@th.if.uj.edu.pl:"))
;; KEY BINDINGS
(global-set-key (kbd "C-l") 'goto-line) ; [Ctrl]-[L]
;; back to the indentation instead of go back to the beginning of the line
(global-set-key (kbd "C-a") 'back-to-indentation)
;; navigation between the windows
(global-set-key [M-left] 'windmove-left) ; move to left windnow
(global-set-key [M-right] 'windmove-right) ; move to right window
(global-set-key [M-up] 'windmove-up) ; move to upper window
(global-set-key [M-down] 'windmove-down) ; move to downer window
(global-set-key (kbd "C-x C-u") 'jao-selective-display)
(defun jao-selective-display ()
"Activate selective display based on the column at point"
(interactive)
(set-selective-display
(if selective-display
nil
(+ 1 (current-column)))))
(global-set-key (kbd "C-M->") 'selective-display-increment)
(global-set-key (kbd "C-M-<") 'selective-display-decrement)
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-unset-key (kbd "C-x C-z"))
(when window-system (global-unset-key (kbd "C-z")))
;; TODO change incrementation value to be put as argument
(defun selective-display-increment ()
"Increments the value of selective-display variable"
(interactive)
(set-selective-display
(+ (or selective-display 0) 2)))
(defun selective-display-decrement ()
"Decrements the value of selective-display variable"
(interactive)
(set-selective-display
(if (<= (or selective-display 0) 2)
nil
(- selective-display 2))))
;; function that reverts all buffers that are visiting files
(defun revert-all-buffers ()
"Refreshes all open buffers from their respective files"
(interactive)
(let* ((list (buffer-list))
(buffer (car list)))
(while buffer
(when (buffer-file-name buffer)
(progn
(set-buffer buffer)
(revert-buffer t t t)))
(setq list (cdr list))
(setq buffer (car list))))
(message "Refreshing open files"))
;; advice definad for magit-checkout to revert all buffers after
;; checkingout
(defadvice revert-all-buffers-after-checkout
(after magit-checkout (rev))
"Rereads from disk all file-visiting buffers after checking out
different branch"
(revert-all-buffers))
;; activation of the above advice
(ad-activate 'revert-all-buffers-after-checkout)
;; get rid of the annoying "yes" or "no" questions
(defalias 'yes-or-no-p 'y-or-n-p)
;; MINOR MODES
;; linum-mode
;(linum-mode t)
;; flyspell
(autoload 'flyspell-mode
"flyspell" "On-the-fly spelling checker." t)
;; ido-mode
(require 'ido)
(ido-mode t)
(ido-everywhere 1)
(setq ido-enable-flex-matching t)
;; highlight parentheses and symbols (how to add hooks??)
;; (highlight-parentheses-mode t)
;; (highlight-symbol-mode t)
;; automaticaly save the emacs session
(desktop-save-mode 1)
;; automaticaly save minibuffer history
(savehist-mode 1)
;; save the position in file after closing it
(setq save-place-file "~/.emacs.d/saveplace") ;; keep my ~/ clean
(setq-default save-place t) ;; activate it for all buffers
(require 'saveplace) ;; get the package
;; enable the mark highliting
(transient-mark-mode 1)
;; highlight brackets
(show-paren-mode t)
(setq show-paren-style 'expression)
(setq show-paren-delay -1)
(set-face-attribute 'show-paren-match-face nil
:weight 'normal :underline nil :overline nil :slant 'normal)
(set-face-background 'show-paren-match-face "#500000")
;; org-mode hook
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
;; yasnippet
;; (require 'yasnippet-bundle)
;; (yas/initialize)
;; (yas/load-directory "~/.emacs.d/snippets")
;; magit
;; (global-set-key (kbd "C-x g") 'magit-status)
;; (add-hook 'magit-mode-hook '(lambda ()
;; (global-set-key (kbd "M-x") 'smex-major-mode-commands)))
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; ;; smex (M-x enchanter)
;; (require 'smex)
;; (smex-initialize)
;; (global-set-key (kbd "M-x") 'smex)
;; (global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; (global-set-key (kbd "C-c M-x") 'smex-update-and-run)
;; ; old M-x
;; (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
;; (setq smex-save-file "~/.emacs.d/smex.save")
;; (smex-auto-update 1)
;; mouse avoidance mode
(mouse-avoidance-mode 'banish)
;; doxymacs for editing Doxygen config files and Doxymax comments
(require 'doxymacs)
(icomplete-mode 1)
(setq icomplete-compute-delay 0)
(require 'icomplete+)
;;;;;;;;;;;;;;;;;;;
;;; MAJOR MODES ;;;
;;;;;;;;;;;;;;;;;;;
;; ibuffer
(setq ibuffer-saved-filter-groups
'(("default"
("Organization" (or
(mode . diary-mode)
(mode . org-mode)
(mode . org-agenda-mode)))
("Files" (filename . ".*"))
("File Management" (or
(mode . dired-mode)
(mode . shell-mode)))
("Documentation" (or
(mode . help-mode)
(mode . Man-mode))))))
;; AUCTeX
;; completion
(global-set-key "\M-\'" 'TeX-complete-symbol)
(setq LaTeX-command "pdflatex")
; spell checking
(add-hook 'latex-mode-hook 'flyspell-mode)
(add-hook 'tex-mode-hook 'flyspell-mode)
(add-hook 'bibtex-mode-hook 'flyspell-mode)
;; Xrefactory
(load "xrefactory")
;; load recent project
;; TODO: save last project name
(setq xref-current-project "yapdes")
;; (global-set-key (kbd "<XF86Forward>") 'xref-push-and-goto-definition)
;; (global-set-key (kbd "<XF86Back>") 'xref-pop-and-return)
;; view-mode
;; (add-hook 'view-mode-hook
;; '(lambda ()
;; (progn
;; (local-set-key (kbd "C-n") 'scroll-down)
;; (local-set-key (kbd "C-p") 'scroll-up)
;; )
;; )
;; )
;; cc-mode
;; toggle auto newline and hungry delet modes
(add-hook 'c-mode-common-hook
'(lambda ()
(progn
;; turn on the auto and hungry states
(c-toggle-auto-hungry-state 1)
;; hide the content of function definitions by
;; default
;; (set-selective-display 1)
(doxymacs-mode)
(doxymacs-font-lock)
;; set the key bindings for Xrefactory
(local-set-key (kbd "C-m") 'xref-push-and-goto-definition)
(local-set-key (kbd "M-p") 'xref-pop-and-return)
(local-set-key (kbd "M-'") 'xref-completion)
;; compiles dynamically linked library
(global-set-key (kbd "C-c c") 'xref-ide-compile-project)
;; compiles API test
(global-set-key (kbd "C-c h") 'xref-ide-run2)
;; runs API test
(global-set-key (kbd "C-c r") 'xref-ide-run3)
;; generates documentation
(global-set-key (kbd "C-c d d") 'xref-ide-run1)
(font-lock-add-keywords nil
'(("\\<\\(FIXME\\|TODO\\|BUG\\):" 1 font-lock-warning-face t)))
)))
;; shell tweaks
(add-hook 'shell-mode-hook 'compilation-shell-minor-mode)
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(setq gdb-many-windos t)
;; mathematica mode
;; (autoload 'mma-mode "mma.el" "Mathematica package file mode" t)
;; (setq auto-mode-alist
;; (cons '("\\.m\\'" . mma-mode) auto-mode-alist))
(load-library "mathematica")
(setq mathematica-never-start-kernel-with-mode t)
(setq auto-mode-alist
(cons '("\\.m\\'" . mathematica-mode) auto-mode-alist))
;;--------------------------------------------------------------------
;; Lines enabling gnuplot-mode
;; move the files gnuplot.el to someplace in your lisp load-path or
;; use a line like
;; (setq load-path (append (list "/path/to/gnuplot") load-path))
;; these lines enable the use of gnuplot mode
(autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
(autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot mode" t)
;; this line automatically causes all files with the .gp extension to
;; be loaded into gnuplot mode
(setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode)) auto-mode-alist))
;; This line binds the function-9 key so that it opens a buffer into
;; gnuplot mode
(global-set-key [(f9)] 'gnuplot-make-buffer)
;; end of line for gnuplot-mode
;;--------------------------------------------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; EMACS-SET CONFIGURATION ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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.
'(TeX-output-view-style (quote (("^dvi$" ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$") "%(o?)dvips -t landscape %d -o && gv %f") ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "%(o?)dvips %d -o && gv %f") ("^dvi$" ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$") "%(o?)xdvi %dS -paper a4r -s 0 %d") ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "%(o?)xdvi %dS -paper a4 %d") ("^dvi$" ("^a5\\(?:comb\\|paper\\)$" "^landscape$") "%(o?)xdvi %dS -paper a5r -s 0 %d") ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d") ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d") ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d") ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d") ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d") ("^dvi$" "." "%(o?)xdvi %dS %d") ("^pdf$" "." "evince %o") ("^html?$" "." "netscape %o"))))
'(haskell-font-lock-symbols nil)
'(ibuffer-default-sorting-mode (quote filename/process))
'(inhibit-startup-screen t)
'(initial-scratch-message nil)
'(ispell-local-dictionary "en")
'(shell-command-completion-mode t nil (shell-command))
'(tramp-encoding-shell "/bin/sh"))
(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.
'(default ((t (:inherit nil :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 121 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ELPA PACKAGE MANAGEMENT ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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))
(fullscreen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment