Advertisement
Guest User

.emacs

a guest
Sep 14th, 2011
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 11.50 KB | None | 0 0
  1. (custom-set-variables    
  2.   ;; custom-set-variables was added by Custom.
  3.   ;; If you edit it by hand, you could mess it up, so be careful.
  4.   ;; Your init file should contain only one such instance.
  5.   ;; If there is more than one, they won't work right.
  6.  '(browse-url-browser-function (quote browse-url-generic))
  7.  '(browse-url-generic-program "firefox")
  8.  '(column-number-mode t)
  9.  '(display-time-mode t)
  10.  '(ibus-python-shell-command-name "python2")
  11.  '(scroll-bar-mode (quote right))
  12.  '(show-paren-mode t)
  13.  '(tool-bar-mode nil))
  14.  
  15. (custom-set-faces
  16.   ;; custom-set-faces was added by Custom.
  17.   ;; If you edit it by hand, you could mess it up, so be careful.
  18.   ;; Your init file should contain only one such instance.
  19.   ;; If there is more than one, they won't work right.
  20.  '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 103 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))
  21.  
  22. (add-to-list 'load-path "/home/favadi/.emacs.d/site-lisp/")
  23.  
  24. ;; Load external file
  25. ;; (load "~/.erc_init.el")
  26.  
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Appearance;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28.  
  29. ; make whitespace-mode use just basic coloring
  30. (setq whitespace-style (quote
  31.   ( spaces tabs newline space-mark tab-mark newline-mark)))
  32.  
  33. ;; make whitespace-mode use “¶” for newline and “▷” for tab.
  34. ;; together with the rest of its defaults
  35. (setq whitespace-display-mappings
  36.  '(
  37.    (space-mark 32 [183] [46]) ; normal space, ·
  38.    (space-mark 160 [164] [95])
  39.    (space-mark 2208 [2212] [95])
  40.    (space-mark 2336 [2340] [95])
  41.    (space-mark 3616 [3620] [95])
  42.    (space-mark 3872 [3876] [95])
  43.    (newline-mark 10 [182 10]) ; newlne, ¶
  44.    (tab-mark 9 [9655 9] [92 9]) ; tab, ▷
  45. ))
  46.  
  47. ;; Hightlight code beetween {}
  48. (setq show-paren-style 'expression)
  49.  
  50. ;;Color theme
  51. ;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/themes/color-theme-example.el")
  52. ;; ;(load-file  "/home/diep/.emacs.d/themes/awesome.el")
  53. ;; (require 'color-theme)
  54. ;; (eval-after-load "color-theme"
  55. ;;   '(progn
  56. ;; (color-theme-initialize)
  57. ;; (color-theme-emacs21)))
  58. ;; (setq color-theme-is-global t)
  59.  
  60. ;;Turn off toolbar and menubar
  61. ;;(menu-bar-mode -1)
  62. ;;(tool-bar-mode -1)
  63.  
  64. ;; turn on highlighting current line
  65. (global-hl-line-mode 1)
  66.  
  67. ;; show (line, column) on mode line
  68. (column-number-mode 1)
  69.  
  70. ;; (global-visual-line-mode 1) ; 1 for on, 0 for off.
  71.  
  72. (line-number-mode 1)
  73.  
  74. (require 'linum)
  75. ;; Number lines in all modes
  76. (global-linum-mode 1)
  77. ;; Apply numbering to specific modes (example for lisp-mode) [cannot use with global-linum-mode]
  78. ;;(add-hook 'lisp-mode-hook (lambda () (linum-mode 1)))
  79.  
  80. (setq-default indent-tabs-mode nil)
  81. (setq-default tab-width 4)
  82. (setq indent-line-function 'insert-tab)
  83.  
  84. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Navigating;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  85. ;;Easy Buffer Switch
  86. ;;(require 'ebs)
  87. ;;     (ebs-initialize)
  88. ;;     (global-set-key [(control tab)] 'ebs-switch-buffer)
  89.  
  90. (iswitchb-mode nil)
  91.  
  92. ;;Switch Beeewen Windows
  93. (global-set-key (kbd "C-x <up>") 'windmove-up)
  94. (global-set-key (kbd "C-x <down>") 'windmove-down)
  95. (global-set-key (kbd "C-x <right>") 'windmove-right)
  96. (global-set-key (kbd "C-x <left>") 'windmove-left)
  97.  
  98. ;;Resize Windows
  99. (global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
  100. (global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
  101. (global-set-key (kbd "S-C-<down>") 'shrink-window)
  102. (global-set-key (kbd "S-C-<up>") 'enlarge-window)
  103.  
  104. ;;Use ibuffer
  105.  
  106. (define-key global-map "\C-x\C-b" 'ibuffer)
  107.  
  108. ;; ;; path-to-anything is the path which has the 'anything' we just cloned
  109. ;; (add-to-list 'load-path "~/.emacs.d/site-lisp/anything/anything-config")
  110. ;; (require 'anything-config)
  111.  
  112. ;; (global-set-key (kbd "C-x b")
  113. ;;   (lambda() (interactive)
  114. ;;     (anything
  115. ;;      :prompt "Switch to: "
  116. ;;      :candidate-number-limit 10                 ;; up to 10 of each
  117. ;;      :sources
  118. ;;      '( anything-c-source-buffers               ;; buffers
  119. ;;         anything-c-source-recentf               ;; recent files
  120. ;;         anything-c-source-bookmarks             ;; bookmarks
  121. ;;         anything-c-source-files-in-current-dir+ ;; current dir
  122. ;;         anything-c-source-locate))))            ;; use 'locate'
  123.  
  124. ;; (global-set-key (kbd "C-c I")  ;; i -> info
  125. ;;   (lambda () (interactive)
  126. ;;     (anything
  127. ;;       :prompt "Info about: "
  128. ;;       :candidate-number-limit 3
  129. ;;       :sources
  130. ;;       '( anything-c-source-info-libc             ;; glibc docs
  131. ;;          anything-c-source-man-pages             ;; man pages
  132. ;;          anything-c-source-info-emacs))))        ;; emacs
  133.  
  134. ;; (add-hook 'emacs-lisp-mode-hook
  135. ;;   (lambda()
  136. ;;   ;; other stuff...
  137. ;;   ;; ...
  138. ;;   ;; put useful info under C-c i
  139. ;;     (local-set-key (kbd "C-c i")
  140. ;;       (lambda() (interactive)
  141. ;;         (anything
  142. ;;           :prompt "Info about: "
  143. ;;           :candidate-number-limit 5
  144. ;;           :sources
  145. ;;           '( anything-c-source-emacs-functions
  146. ;;              anything-c-source-emacs-variables
  147. ;;              anything-c-source-info-elisp
  148. ;;              anything-c-source-emacs-commands
  149. ;;              anything-c-source-emacs-source-defun
  150. ;;              anything-c-source-emacs-lisp-expectations
  151. ;;              anything-c-source-emacs-lisp-toplevels
  152. ;;              anything-c-source-emacs-functions-with-abbrevs
  153. ;;              anything-c-source-info-emacs))))))
  154.  
  155. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Editing;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  156.  
  157. ;;Visual Undo Redo
  158. (require 'redo+)
  159. (global-set-key (kbd "C-+") 'redo)
  160. (setq undo-no-redo t)
  161.  
  162. ;; Set undo, redo shortcuts
  163. (global-set-key (kbd "C-z") 'undo) ; Ctrl+z
  164. (global-set-key (kbd "C-S-z") 'redo) ;  Ctrl+Shift+z
  165.  
  166.  
  167. ;; Set undo, redo shortcuts
  168. (global-set-key (kbd "C-z") 'undo) ; Ctrl+z
  169. (global-set-key (kbd "C-S-z") 'redo) ;  Ctrl+Shift+z
  170.  
  171. (delete-selection-mode 1) ; delete selected text when typing
  172.  
  173. ;; ;; Ibus-el setup
  174. ;; (require 'ibus)
  175. ;; ;; Turn on ibus-mode automatically after loading .emacs
  176. ;; (add-hook 'after-init-hook 'ibus-mode-on)
  177. ;; ;; Choose your key to toggle input status:
  178. ;; (global-set-key (kbd "C-`") 'ibus-toggle)
  179. ;; ;;change cursor color depending on IBus status
  180. ;; (setq ibus-cursor-color '("red" "white" "limegreen"))
  181. ;; ;; Use C-SPC for Set Mark command
  182. ;; (ibus-define-common-key ?\C-\s nil)
  183. ;; ;; Use C-x M-i toggle ibus mode.
  184. ;; (global-set-key (kbd "C-x M-i") 'ibus-mode)
  185.  
  186. ;; Whole line or region mode
  187.  
  188. (put 'kill-ring-save 'interactive-form
  189.      '(interactive
  190.        (if (use-region-p)
  191.            (list (region-beginning) (region-end))
  192.          (list (line-beginning-position) (line-beginning-position 2)))))
  193.  
  194. (put 'kill-region 'interactive-form      
  195.      '(interactive
  196.        (if (use-region-p)
  197.            (list (region-beginning) (region-end))
  198.          (list (line-beginning-position) (line-beginning-position 2)))))
  199.  
  200. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Programming;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  201.  
  202. ;; Original idea from
  203. ;; http://www.opensubscriber.com/message/[email protected]/10971693.html
  204. (defun comment-dwim-line (&optional arg)
  205.   "Replacement for the comment-dwim command.
  206.   If no region is selected and current line is not blank and we are not at the end of the line, then comment current line.
  207.   Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line."
  208.   (interactive "*P")
  209.   (comment-normalize-vars)
  210.   (if (and (not (region-active-p)) (not (looking-at "[ \t]*$")))
  211.       (comment-or-uncomment-region (line-beginning-position) (line-end-position))
  212.     (comment-dwim arg)))
  213.  
  214. (global-set-key "\M-;" 'comment-dwim-line)
  215.  
  216. ;; Auto-complete
  217. (add-to-list 'load-path "/usr/share/emacs/site-lisp/auto-complete")
  218. (require 'auto-complete-config)
  219. (add-to-list 'ac-dictionary-directories "/usr/share/emacs/site-lisp/auto-complete/ac-dict")
  220. (ac-config-default)
  221.  
  222. ;;AutoPairs
  223. ;; (add-to-list 'load-path "~/.emacs.d/site-lisp") ;; comment if autopair.el is in standard load path
  224. (require 'autopair)
  225. (autopair-global-mode) ;; enable autopair in all buffers
  226.  
  227. ;; Python setting
  228.  
  229. ;; Emacs python mode
  230. (autoload 'python-mode "python-mode.el" "Python mode." t)
  231. (setq auto-mode-alist (append '(("/*.\.py$" . python-mode)) auto-mode-alist))
  232.  
  233. ;; Yasnippet
  234. (add-to-list 'load-path "/usr/share/emacs/site-lisp/yas")
  235. (require 'yasnippet) ;; not yasnippet-bundle
  236. (yas/initialize)
  237. (yas/load-directory "/usr/share/emacs/site-lisp/yas/snippets")
  238.  
  239. ;;Ropemacs
  240. (require 'pymacs)
  241. (pymacs-load "ropemacs" "rope-")
  242. ;; End Python setting
  243.  
  244. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Dired;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  245.  
  246. (require 'dired)
  247.  
  248. (define-key global-map "\C-x\C-j" 'dired-jump)
  249.  
  250. ; deleting files goes to OS's trash folder
  251. (setq delete-by-moving-to-trash t) ; “t” for true, “nil” for false
  252.  
  253. ;; allow dired to be able to delete or copy a whole dir.
  254. ;; “always” means no asking. “top” means ask once. Any other symbol means ask each and every time for a dir and subdir.
  255. (setq dired-recursive-copies (quote top))
  256. (setq dired-recursive-deletes (quote top))
  257.  
  258. ;; Now, when you have dired of different dir in 2 panes, and when you press C to copy, the other dir in the split pane will be default destination.
  259. (setq dired-dwim-target t)
  260.  
  261. ;; Make dired use the same buffer for viewing directory, instead of spawning many
  262. (add-hook 'dired-mode-hook
  263.  (lambda ()
  264.   (define-key dired-mode-map (kbd "<return>")
  265.     'dired-find-alternate-file) ; was dired-advertised-find-file
  266.   (define-key dired-mode-map (kbd "^")
  267.     (lambda () (interactive) (find-alternate-file "..")))
  268.   ; was dired-up-directory
  269.  ))
  270. ;; Hiding Hidden Files in Emacs dired
  271. (require 'dired-x)
  272. (setq dired-omit-files "^\\...+$")
  273. (add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1)))
  274.  
  275. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EMMS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  276.  
  277. ;; (require 'emms-setup)
  278. ;; (emms-standard)
  279. ;; (emms-default-players)
  280.  
  281.        
  282. ;; ;; Show the current track each time EMMS
  283. ;; ;; starts to play a track with "NP : "
  284. ;; (add-hook 'emms-player-started-hook 'emms-show)
  285. ;; (setq emms-show-format "NP: %s")
  286.        
  287. ;; ;; When asked for emms-play-directory,
  288. ;; ;; always start from this one
  289. ;; (setq emms-source-file-default-directory "~/zic/")
  290.        
  291. ;; ;; Want to use alsa with mpg321 ?
  292. ;; (setq emms-player-mpg321-parameters '("-o" "alsa"))
  293.  
  294. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Misc.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  295.  
  296. ;;Tetris setting
  297. (defadvice tetris-end-game (around zap-scores activate)
  298.   (save-window-excursion ad-do-it))
  299.  
  300. ;;Setting for Org Mode
  301. ;; The following lines are always needed. Choose your own keys.
  302. (require 'org-install)
  303. (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
  304. (global-set-key "\C-cl" 'org-store-link)
  305. (global-set-key "\C-cc" 'org-capture)
  306. (global-set-key "\C-ca" 'org-agenda)
  307. (global-set-key "\C-cb" 'org-iswitchb)
  308. (setq org-agenda-files (list "~/Dropbox/org/Work.org"
  309.                              "~/Dropbox/org/Personal.org"
  310.                              "~/Dropbox/org/Misc.org"))
  311. (setq org-log-done t)
  312.  
  313. ;; W3m
  314. (setq browse-url-browser-function 'w3m-browse-url)
  315. (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
  316. ;; optional keyboard short-cut
  317. (global-set-key "\C-xm" 'browse-url-at-point)
  318.  
  319. ;; Set starting day to sunday
  320. (setq calendar-week-start-day 1)
  321. (put 'dired-find-alternate-file 'disabled nil)
  322.  
  323. ;; Setting for deft (a not taking mode)
  324. ;; (require 'deft)
  325. ;; (setq deft-extension "txt")
  326. ;; (setq deft-directory "~/Dropbox/deft-notes/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement