Skip to content

Instantly share code, notes, and snippets.

@delihiros
Created May 8, 2012 04:12
Show Gist options
  • Save delihiros/2632518 to your computer and use it in GitHub Desktop.
Save delihiros/2632518 to your computer and use it in GitHub Desktop.
(setq indent-tabs-mode nil)
(setq load-path
(append
(list
(expand-file-name "~/emacs-setup")
)
load-path))
(setq-default split-width-threshold 77)
(require 'mac-key-mode)
(mac-key-mode 1)
(tool-bar-mode 0)
(scroll-bar-mode -1)
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\M-a" 'anything)
(global-set-key "\C-ch" 'htmlize-file)
(global-set-key "\M-s" 'occur)
(global-set-key "\M-r" 'revert-buffer)
(global-set-key [(super right)] 'shrink-window-horizontally)
(global-set-key [(super left)] 'enlarge-window-horizontally)
(global-set-key [(super up)] 'shrink-window)
(global-set-key [(super down)] 'enlarge-window)
(define-key global-map [(super v)] 'yank)
(define-key global-map [(super c)] 'copy-region-as-kill)
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-style "stroustrup")
(c-toggle-hungry-state 1)))
(global-linum-mode t)
(setq visible-bell t)
(if window-system (server-start))
(iswitchb-mode t)
(set-frame-parameter nil 'alpha '95)
(set-frame-parameter nil 'fullscreen 'fullboth)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super)
(setq pc-select-selection-keys-only t)
(pc-selection-mode 1)
(setq make-backup-files nil)
(setq auto-save-default nil)
(show-paren-mode t)
(add-to-list 'load-path "~/emacs-setup/shell-pop")
(require 'shell-pop)
(shell-pop-set-internal-mode "ansi-term")
(defvar ansi-term-after-hook nil)
(add-hook 'ansi-term-after-hook
'(lambda ()
(define-key term-raw-map "\C-t" 'shell-pop)))
(defadvice ansi-term (after ansi-term-after-advice (org))
"run hook as after advice"
(run-hooks 'ansi-term-after-hook))
(ad-activate 'ansi-term)
(global-set-key "\C-t" 'shell-pop)
;; auto-install
(require 'auto-install)
(add-to-list 'load-path "~/emacs-setup/auto-install")
(setq auto-install-directory "~/emacs-setup/auto-install")
(auto-install-update-emacswiki-package-name t)
;; indented line \C-a
(defun beginning-of-indented-line (current-point)
(interactive "d")
(if (string-match
"\[ \t]+$"
(save-excursion
(buffer-substring-no-properties
(progn (beginning-of-line) (point))
current-point)))
(beginning-of-line)
(back-to-indentation)))
(add-hook 'c-mode-common-hook
'(lambda ()
(setq c-basic-offset 4)))
(add-hook 'c-mode-hook
'(lambda ()
(c-toggle-auto-state t)))
;; anything
(require 'anything-startup)
(require 'anything-config)
(add-to-list 'anything-sources 'anything-c-source-emacs-commands)
;; haskell-mode
(load "~/emacs-setup/haskell-mode/haskell-site-file")
(require 'haskell-mode)
(require 'haskell-cabal)
(add-to-list 'auto-mode-alist '("\\.hs$" . haskell-mode))
(add-to-list 'auto-mode-alist '("\\.lhs$" . literate-haskell-mode))
(add-to-list 'auto-mode-alist '("\\.cabal\\'" . haskell-cabal-mode))
(setq haskell-program-name "ghci")
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
;; ghc-mod
(add-to-list 'exec-path (concat (getenv "HOME") "/.cabal/bin"))
(add-to-list 'load-path "~/.cabal/share/ghc-mod-1.10.15")
(autoload 'ghc-init "ghc" nil t)
(add-hook 'haskell-mode-hook
(lambda () (ghc-init)))
;; haskell-auto-complete
(ac-define-source ghc-mod
'((depends ghc)
(candidates . (ghc-select-completion-symbol))
(symbol . "s")
(cache)))
(defun my-ac-haskell-mode ()
(setq ac-sources '(ac-source-words-in-same-mode-buffers ac-source-dictionary ac-source-ghc-mod)))
(defun my-haskell-ac-init ()
(when (member (file-name-extension buffer-file-name) '("hs" "lhs"))
(auto-complete-mode t)
(setq ac-sources '(ac-source-words-in-same-mode-buffers ac-source-dictionary ac-source-ghc-mod))))
(add-hook 'find-file-hook 'my-haskell-ac-init)
;; color-theme
(add-to-list 'load-path "~/emacs-setup/color-theme")
(require 'color-theme)
(color-theme-initialize)
(color-theme-delihiros)
;; pop-win
(add-to-list 'load-path "~/emacs-setup/popwin-el")
(require 'popwin)
(setq display-buffer-function 'popwin:display-buffer)
;; popup
(add-to-list 'load-path "~/emacs-setup/popup-el")
(require 'popup)
;; auto-complete
(add-to-list 'load-path "~/emacs-setup/auto-complete")
(require 'auto-complete)
(global-auto-complete-mode t)
;; ac-slime
(add-to-list 'load-path "~/emacs-setup/ac-slime")
(require 'ac-slime)
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(require 'flymake)
(defun flymake-cc-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
(push '("\\.cpp$" flymake-cc-init) flymake-allowed-file-name-masks)
(push '("\\.c$" flymake-cc-init) flymake-allowed-file-name-masks)
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted)
(setq flymake-check-was-interrupted t))
(ad-activate 'flymake-post-syntax-check)
;; flymake popup
(global-set-key (kbd "M-e") 'flymake-goto-next-error)
(global-set-key (kbd "M-E") 'flymake-goto-prev-error)
;; Show error message under current line
(require 'popup)
(defun flymake-display-err-menu-for-current-line ()
(interactive)
(let* ((line-no (flymake-current-line-no))
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))))
(when line-err-info-list
(let* ((count (length line-err-info-list))
(menu-item-text nil))
(while (> count 0)
(setq menu-item-text (flymake-ler-text (nth (1- count) line-err-info-list)))
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(if file
(setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")"))))
(setq count (1- count))
(if (> count 0) (setq menu-item-text (concat menu-item-text "\n")))
)
(popup-tip menu-item-text)))))
(if (eq 'unspecified (face-attribute 'popup-tip-face :height))
(set-face-attribute 'popup-tip-face nil :height 1.0))
(if (eq 'unspecified (face-attribute 'popup-tip-face :weight))
(set-face-attribute 'popup-tip-face nil :weight 'normal))
(defun my/display-error-message ()
(let ((orig-face (face-attr-construct 'popup-tip-face)))
(set-face-attribute 'popup-tip-face nil
:height 1.5 :foreground "firebrick"
:background "LightGoldenrod1" :bold t)
(unwind-protect
(flymake-display-err-menu-for-current-line)
(while orig-face
(set-face-attribute 'popup-tip-face nil (car orig-face) (cadr orig-face))
(setq orig-face (cddr orig-face))))))
(defadvice flymake-goto-prev-error (after flymake-goto-prev-error-display-message)
(my/display-error-message))
(defadvice flymake-goto-next-error (after flymake-goto-next-error-display-message)
(my/display-error-message))
(ad-activate 'flymake-goto-prev-error 'flymake-goto-prev-error-display-message)
(ad-activate 'flymake-goto-next-error 'flymake-goto-next-error-display-message)
;; C/C++
(add-hook 'c++-mode-hook
'(lambda ()
(flymake-mode t)))
(add-hook 'c-mode-hook
'(lambda ()
(flymake-mode t)))
;; haskell
(defun flymake-haskell-make-command (temp-file)
(list "make"
(flymake-haskell-make-parameters temp-file)))
(defun flymake-haskell-make-parameters (temp-file)
(list "-s"
"-C"
"."
(concat "CHK_SOURCES=" temp-file)
"SYNTAX_CHECK_MODE=1"
"check-syntax"))
(defun flymake-haskell-default-ghc-command (local-file)
(list "ghc"
(flymake-haskell-default-ghc-parameters
(file-name-nondirectory local-file))))
(defun flymake-haskell-default-ghc-parameters (local-file)
(list "-fno-code" local-file))
(defun makefile-exists-p (path)
(file-exists-p (concat path "Makefile")))
(defun flymake-haskell-init()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(if (makefile-exists-p (file-name-directory buffer-file-name))
(flymake-haskell-make-command temp-file)
(flymake-haskell-default-ghc-command local-file))))
(push '(".+\\hs$" flymake-haskell-init) flymake-allowed-file-name-masks)
(push '(".+\\lhs$" flymake-haskell-init) flymake-allowed-file-name-masks)
(push '("^\\(\.+\.hs\\|\.lhs\\):\\([0-9]+\\):\\([0-9]+\\):\\(\.+\\)" 1 2 3 4)
flymake-err-line-patterns)
(add-hook 'haskell-mode-hook
'(lambda ()
(if (not (null buffer-file-name))
(flymake-mode))))
;; smart-compile
(require 'smart-compile)
(global-set-key "\C-cc" 'smart-compile)
(define-key menu-bar-tools-menu [compile] '("Compile..." . smart-compile))
;; pretty-mode
(add-to-list 'load-path "~/emacs-setup/pretty-mode")
(require 'pretty-mode)
(global-pretty-mode 1)
(require 'fm)
(add-hook 'occur-mode-hook 'fm-start)
(add-hook 'compilation-mode-hook 'fm-start)
(require 'lusty-explorer)
(global-set-key "\C-xb" 'lusty-buffer-explorer)
;; powerline
(defun arrow-right-xpm (color1 color2)
"Return an XPM right arrow string representing."
(format "/* XPM */
static char * arrow_right[] = {
\"12 18 2 1\",
\". c %s\",
\" c %s\",
\". \",
\".. \",
\"... \",
\".... \",
\"..... \",
\"...... \",
\"....... \",
\"........ \",
\"......... \",
\"......... \",
\"........ \",
\"....... \",
\"...... \",
\"..... \",
\".... \",
\"... \",
\".. \",
\". \"};" color1 color2))
(defun arrow-left-xpm (color1 color2)
"Return an XPM right arrow string representing."
(format "/* XPM */
static char * arrow_right[] = {
\"12 18 2 1\",
\". c %s\",
\" c %s\",
\" .\",
\" ..\",
\" ...\",
\" ....\",
\" .....\",
\" ......\",
\" .......\",
\" ........\",
\" .........\",
\" .........\",
\" ........\",
\" .......\",
\" ......\",
\" .....\",
\" ....\",
\" ...\",
\" ..\",
\" .\"};" color2 color1))
(defconst color1 "ivory")
(defconst color2 "DeepSkyBlue4")
(defvar arrow-right-1 (create-image (arrow-right-xpm color1 color2) 'xpm t :ascent 'center))
(defvar arrow-right-2 (create-image (arrow-right-xpm color2 "None") 'xpm t :ascent 'center))
(defvar arrow-left-1 (create-image (arrow-left-xpm color2 color1) 'xpm t :ascent 'center))
(defvar arrow-left-2 (create-image (arrow-left-xpm "None" color2) 'xpm t :ascent 'center))
(setq-default mode-line-format
(list '(:eval (concat (propertize " %b " 'face 'mode-line-color-1)
(propertize " " 'display arrow-right-1)))
'(:eval (concat (propertize " %m " 'face 'mode-line-color-2)
(propertize " " 'display arrow-right-2)))
;; Justify right by filling with spaces to right fringe - 16
;; (16 should be computed rahter than hardcoded)
'(:eval (propertize " " 'display '((space :align-to (- right-fringe 17)))))
'(:eval (concat (propertize " " 'display arrow-left-2)
(propertize " %p " 'face 'mode-line-color-2)))
'(:eval (concat (propertize " " 'display arrow-left-1)
(propertize "%4l:%2c " 'face 'mode-line-color-1)))
))
(make-face 'mode-line-color-1)
(set-face-attribute 'mode-line-color-1 nil
:foreground "blue4"
:background color1)
(make-face 'mode-line-color-2)
(set-face-attribute 'mode-line-color-2 nil
:foreground "SlateGray3"
:background color2)
(set-face-attribute 'mode-line nil
:foreground "ivory"
:background "navy"
:box nil)
(set-face-attribute 'mode-line-inactive nil
:foreground "#ffff"
:background "RoyalBlue")
;; tramp
(setq tramp-default-method "ssh")
;; scheme
(setq scheme-program-name "gosh")
(require 'cmuscheme)
(defun scheme-other-window ()
(interactive)
(switch-to-buffer-other-window
(get-buffer-create "*scheme*"))
(run-scheme scheme-program-name))
(define-key global-map
"\C-c\C-l" 'scheme-other-window)
;; twittering mode
(add-to-list 'load-path "~/emacs-setup/twittering-mode")
(require 'twittering-mode)
(setq twittering-icon-mode t)
;; php-mode
(add-to-list 'load-path "~/emacs-setup/php-mode")
(require 'php-mode)
(add-hook 'php-mode-user-hook
'(lambda ()
(c-set-style "java")))
;; java
(add-to-list 'load-path "~/emacs-setup/malabar-mode")
(require 'malabar-mode)
;; mizar
(require 'mizar)
;; gist
(add-to-list 'load-path "~/emacs-setup/gh.el")
(add-to-list 'load-path "~/emacs-setup/logito")
(add-to-list 'load-path "~/emacs-setup/pcache")
(add-to-list 'load-path "~/emacs-setup/tabulated-list.el")
(add-to-list 'load-path "~/emacs-setup/gist.el")
(require 'gist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment