Guest User

terdon's .emacs

a guest
Jun 17th, 2014
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 21.76 KB | None | 0 0
  1. ;; Are we running XEmacs or Emacs?
  2. (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))
  3.  
  4. ;; disable menu bar when running in terminal
  5. (when (not (display-graphic-p))
  6.   (menu-bar-mode -1))
  7.  
  8. ;;;;;;;;;;;;;;;;;;;;;
  9. ;; Disable toolbar ;;
  10. ;;;;;;;;;;;;;;;;;;;;;
  11. (tool-bar-mode -1)
  12.  
  13.  
  14. ;;;;;;;;;;;;;;;;;;;;
  15. ;; Start a server ;;
  16. ;;;;;;;;;;;;;;;;;;;;
  17. ;;(server-start)
  18.  
  19. ;;My libraries, ebib, wordcount etc
  20. (add-to-list 'load-path "~/.emacs-lisp/")
  21.  
  22. ;; ===== Make Text mode the default mode for new buffers =====
  23. ;;(setq major-mode 'text-mode)
  24. ;; ===== Make org mode the default mode for new buffers =====
  25. (setq major-mode 'org-mode)
  26.  
  27. ;;;;;;;;;;;;;;;;;;;;
  28. ;; org mode stuff ;;
  29. ;;;;;;;;;;;;;;;;;;;;
  30. (require 'org-install)
  31. (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
  32.  
  33. (define-key global-map "\C-cl" 'org-store-link)
  34. (define-key global-map "\C-ca" 'org-agenda)
  35. (setq org-log-done t)
  36.  
  37.  
  38.  
  39. ;; disable blinking cursor
  40. (blink-cursor-mode 0)
  41.  
  42. ;; Interpret ANSI color escape codes
  43. (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
  44.  
  45. ;; Set up the keyboard so the delete key on both the regular keyboard
  46. ;; and the keypad delete the character under the cursor and to the right
  47. ;; under X, instead of the default, backspace behavior.
  48. (global-set-key [delete] 'delete-char)
  49. (global-set-key [kp-delete] 'delete-char)
  50. (global-set-key "\C-cc" 'comment-region)
  51. (global-set-key "\C-cb" 'comment-box)
  52. (global-set-key "\C-cu" 'uncomment-region)
  53. (global-set-key "\C-cr" 'query-replace)
  54. (global-set-key "\M-gg" 'goto-line)
  55. (global-set-key "\C-ci" 'ebib-insert-bibtex-key)
  56. (global-set-key "\C-ce" 'ecb-activate)
  57.  
  58. ;;; Compare windows
  59. (global-set-key "\C-cw" 'compare-windows)
  60. ;;; Rebind `C-x C-b' for `buffer-menu'
  61. (global-set-key "\C-x\C-b" 'buffer-menu)
  62. ;; Turn on font-lock mode for Emacs
  63. (cond ((not running-xemacs)
  64.        (global-font-lock-mode t)
  65. ))
  66. ;; use all spaces, no tabs for indentation
  67. (setq-default indent-tabs-mode nil)
  68.  
  69. ;; delete with backspace and delete
  70. (delete-selection-mode t)
  71. (add-hook 'LaTeX-mode-hook 'flyspell-mode)
  72.  
  73. ;; make flyspell mode ignore latex commands
  74. (setq ispell-extra-args '("--dont-tex-check-comments"))
  75.  
  76. ;;(set-default-font "-apple-Monaco-normal-normal-normal-*-14-*-*-*-*-0-iso10646-1")
  77. (set-default-font "Monaco")
  78. ;;(set-default-font "monaco")
  79.  
  80. ;;-*-Monaco-normal-r-*-*-16-*-*-*-*-*-*-*")
  81. ;;;;                   -*-Monaco-medium-r-*-*-10-*-*-*-*-*-*-*
  82. ;; Visual feedback on selections
  83. (setq-default transient-mark-mode t)
  84.  
  85. ;; Always end a file with a newline
  86. (setq require-final-newline t)
  87.  
  88. ;; Stop at the end of the file, not just add lines
  89. (setq next-line-add-newlines nil)
  90.  
  91.  
  92. ;; highlight paired parentheses
  93. (show-paren-mode t )
  94.  
  95.  
  96.  
  97. ;; Pretty parentheses
  98. (when (require 'rainbow-delimiters nil 'noerror)
  99.   (add-hook 'cperl-mode-hook 'rainbow-delimiters-mode))
  100.  
  101. ;;;;;;;;;;;;;;;;;;;;;
  102. ;; auto-install.el ;;
  103. ;;;;;;;;;;;;;;;;;;;;;
  104. ;; (require 'auto-install)
  105. ;; (auto-install-update-emacswiki-package-name t)
  106.  
  107.  
  108. ;;;;;;;;;;;;;;;;;;;;;
  109. ;; perl completion ;;
  110. ;;;;;;;;;;;;;;;;;;;;;
  111. (add-hook 'cperl-mode-hook
  112.           (lambda()
  113.             (require 'perl-completion)
  114.             (perl-completion-mode t)))
  115.  
  116.  
  117.  
  118. ;;;;;;;;;;;;;;;;;;;;
  119. ;; ----- ECB ---- ;;
  120. ;;;;;;;;;;;;;;;;;;;;
  121. (add-to-list 'load-path
  122.              "~/.emacs-lisp/ecb/");;"/usr/share/emacs23/site-lisp/ecb/")
  123. (require 'ecb)
  124. ;;;; activate ecb for the following modes
  125. ;; (dolist (hook '(
  126. ;;      c-mode-hook        
  127. ;;      cperl-mode-hook
  128. ;;      perl-mode-hook
  129. ;;      php-mode-hook      
  130. ;;      js-mode-hook        
  131. ;;      python-mode        
  132. ;;      sh-mode-hook        
  133. ;;      ))
  134. ;;   (add-hook hook 'ecb-activate))
  135.  
  136. ;;; Modify the variable ecb-layout-name to use change the layout
  137. ;;; then C-c . l to refresh the ecb screen
  138. ;;; or just use the function ecb-change-layout
  139. ;;(setq ecb-layout-name "terdon1")
  140. (setq ecb-layout-name "terdon2")
  141. ;(setq initial-buffer-choice user-init-file)
  142.  
  143. ;;; use the icons in the tree displays (t)
  144. (setq ecb-tree-use-image-icons t)
  145.  
  146.  
  147. ;; Enable wheelmouse support by default
  148. (cond (window-system
  149.        (mwheel-install)
  150. ))
  151. (custom-set-variables
  152.   ;; custom-set-variables was added by Custom.
  153.   ;; If you edit it by hand, you could mess it up, so be careful.
  154.   ;; Your init file should contain only one such instance.
  155.   ;; If there is more than one, they won't work right.
  156.  '(case-fold-search t)
  157.  '(current-language-environment "English")
  158.  '(default-input-method "latin-9-prefix")
  159.  '(ebib-preload-bib-files (quote ("~/doc/Papers/moonlighting.bib")))
  160.  '(ecb-fix-window-size (quote width))
  161.  '(ecb-layout-window-sizes (quote (("left6" (ecb-sources-buffer-name 0.15 . 0.17142857142857143) (ecb-methods-buffer-name 0.15 . 0.6) (ecb-history-buffer-name 0.15 . 0.2)))))
  162.  '(ecb-options-version "2.40")
  163.  '(ecb-source-path (quote (("/" "/"))))
  164.  '(ecb-tip-of-the-day nil)
  165.  '(global-font-lock-mode t nil (font-lock))
  166.  '(inhibit-startup-screen t)
  167.  '(safe-local-variable-values (quote ((Local . "american"))))
  168.  '(save-place t nil (saveplace))
  169.  '(show-paren-mode t nil (paren))
  170.  '(tex-dvi-view-command (quote (cond ((eq window-system (quote x)) "evince") ((eq window-system (quote w32)) "yap") (t "dvi2tty * | cat -s"))))
  171.  '(transient-mark-mode t))
  172. (custom-set-faces
  173.   ;; custom-set-faces was added by Custom.
  174.   ;; If you edit it by hand, you could mess it up, so be careful.
  175.   ;; Your init file should contain only one such instance.
  176.   ;; If there is more than one, they won't work right.
  177.  '(cperl-array-face ((((class color) (background light)) (:foreground "OrangeRed"))))
  178.  '(cperl-hash-face ((((class color) (background light)) (:foreground "coral4"))))
  179.  '(cperl-nonoverridable-face ((t (:foreground "RoyalBlue"))))
  180.  '(font-lock-comment-face ((t (:foreground "SlateGray")))))
  181.  
  182.  
  183. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  184. ;; Perl Development Environment, PDE ;;
  185. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  186.   ;; (add-to-list 'load-path "~/.emacs-lisp/Emacs-PDE-0.2.16/lisp")
  187.   ;;    (load "pde-load")
  188.  
  189.  
  190.  
  191. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  192. ;; enable highlighting regions from the keyboard ;;
  193. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  194. (setq transient-mark-mode t)
  195.  
  196.  
  197. ;; Load Ebib mode
  198. (autoload 'ebib "ebib" "Ebib, a BibTeX database manager." t)
  199.  
  200. ;; Load wc mode
  201. (autoload 'wc "wc" "Word Count" t)
  202.  
  203.  
  204. ;; enable wordcount for LaTex
  205. ;; http://superuser.com/questions/125027/word-count-for-latex-within-emacs
  206. (defun latex-word-count ()
  207.   (interactive)
  208.   (shell-command (concat "~/scripts/texcount.pl "
  209.                          ; "uncomment then options go here "
  210.                          (buffer-file-name))))
  211.  
  212. ;; save history across sessions
  213. (require 'recentf)
  214. (recentf-mode 1)
  215. (setq recentf-max-menu-items 50)
  216.  
  217. ;; ralee mode is good for RNA alignment editing
  218. ;; (add-to-list 'load-path "~/.ralee/")
  219. ;; (autoload 'ralee-mode "ralee-mode" "Yay! RNA things" t)
  220. ;; (setq auto-mode-alist (cons '("\\.stk$" . ralee-mode) auto-mode-alist))
  221.  
  222. ;; Show current line and column number
  223. (setq-default column-number-mode t)
  224. (line-number-mode t)
  225.  
  226. ;; Set encoding
  227. (prefer-coding-system 'utf-8)
  228. (setq coding-system-for-read 'utf-8)
  229. (setq coding-system-for-write 'utf-8)
  230.  
  231. ;; tramp for remote file editing
  232. (setq tramp-default-method "ssh")
  233.  
  234.  
  235.  
  236. ;;/lacoloc@badabing:/home/lacoloc/foo1
  237. ;;; Buffer tricks for C-x C-b
  238. (require 'ibuffer)
  239. (setq ibuffer-saved-filter-groups
  240.   (quote (("default"      
  241.            
  242.             ("Coding" ;; prog stuff not already in MyProjectX
  243.               (or
  244.                 (mode . c-mode)
  245.                 (mode . perl-mode)
  246.         (mode . cperl-mode)
  247.                 (mode . python-mode)
  248.                 (mode . emacs-lisp-mode)
  249.         (mode . php-mode)
  250.         (mode . js-mode)
  251.         (mode . shell-script\[sh\]-mode)
  252.         (mode . shell-script\[bash\]-mode)
  253.         (mode . shell-script-mode)
  254.         (mode . shell-script-mode)
  255.         (mode . shell-script-mode)
  256.         (mode . shell-script-mode)
  257.         (name . "\\.sh$")
  258.          
  259.  
  260.                 )
  261.           )
  262.         ("HTML/CSS"
  263.        
  264.           (or
  265.            (mode . myhtml-mode)
  266.            (mode . html-mode)
  267.            (mode . htm-mode)
  268.            (mode . css-mode)
  269.            
  270.           )
  271.  
  272.          )
  273.         ("PlainText"  (mode . text-mode))
  274.         ))))
  275.  
  276.      (add-hook 'ibuffer-mode-hook
  277.            (lambda ()
  278.              (ibuffer-switch-to-saved-filter-groups "default")))
  279. (global-set-key (kbd "C-x C-b") 'ibuffer)
  280.  
  281.  
  282.  
  283. ;;;;;; HTML stuff  ;;;;;;;;;;;
  284. ;;;;;;; Color colors in css and html files
  285. (autoload 'myhtml-mode "myhtml-mode" "My HTML mode." t)
  286. (autoload 'rainbow-mode "rainbow-mode" "Color stuff" t)
  287.  
  288. ;;; set myHTML as default mode
  289. (setq auto-mode-alist (cons '("\\.html$" . myhtml-mode) auto-mode-alist))
  290.  
  291. ;;;  web-mode single mode for web docs
  292. (require 'web-mode)
  293. (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
  294. (add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode))
  295. (add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
  296. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  297. (add-to-list 'auto-mode-alist '("\\.htm\\'" . web-mode))
  298.  
  299. (add-hook 'css-mode-hook 'rainbow-mode)
  300.  
  301. ;;;;;;;;;; HTML keybindings ;;;;;;;;
  302.  
  303. ;;; Ctrl+c Ctrl+d :Delete matching tags. WARNING: if your HTML tags
  304. ;;; are not always matched, it might delete the wrong starting/ending tag
  305.  
  306.  
  307. (add-hook 'myhtml-mode-hook
  308.       (lambda ()
  309.  ;;; sgml-delete-tag function
  310.        
  311.         (local-set-key (kbd "C-c b") 'bold-word)
  312.         (local-set-key (kbd "C-c p") 'insert-p)
  313.         (local-set-key (kbd "M-4") 'tag-image)
  314.         (local-set-key (kbd "M-5") 'wrap-url)
  315.         (local-set-key (kbd "C-c C-d") 'sgml-delete-tag)
  316.        
  317.         )
  318.       )
  319.  
  320.  
  321.  
  322. ;;; Idle highlight stuff
  323. ;; (defun my-coding-hook () (make-local-variable 'column-number-mode) (column-number-mode t)  (idle-highlight t))
  324.  
  325. ;; (add-hook 'emacs-lisp-mode-hook 'my-coding-hook) (add-hook 'ruby-mode-hook 'my-coding-hook) (add-hook 'js2-mode-hook 'my-coding-hook) (add-hook 'perl-mode-hook 'my-coding-hook) (add-hook 'python-mode-hook 'my-coding-hook) (add-hook 'php-mode-hook 'my-coding-hook) (add-hook 'js-mode-hook 'my-coding-hook)  
  326.  
  327. ;;; This was installed by package-install.el.
  328. ;;; This provides support for the package system and
  329. ;;; interfacing with ELPA, the package archive.
  330. ;;; Move this code earlier if you want to reference
  331. ;;; packages in your .emacs.
  332. (when
  333.     (load
  334.      (expand-file-name "~/.emacs.d/elpa/package.el"))
  335.   (package-initialize))
  336.  
  337.  
  338. ;;
  339. (define-key isearch-mode-map (kbd "C-o")
  340.   (lambda ()
  341.     (interactive)
  342.     (let ((case-fold-search isearch-case-fold-search))
  343.       (occur (if isearch-regexp isearch-string
  344.                (regexp-quote isearch-string))))))
  345.  
  346.  
  347. ;;; yasnippet for tab autocomplete
  348. ;;; https://github.com/capitaomorte/yasnippet
  349.  
  350. (add-to-list 'load-path
  351.               "~/.emacs.d/plugins/yasnippet")
  352. (require 'yasnippet)
  353. (yas/global-mode 1)
  354.  
  355.  
  356. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  357. ;; Customize cperl-mode ;;
  358. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  359.  
  360. ;; make cperl-mode always highlight scalar variables
  361.  (setq cperl-highlight-variables-indiscriminately t)
  362.  
  363. ;; Disable whitespace underline
  364. (setq cperl-invalid-face (quote off))
  365.  
  366. ;; Set as default for perl files
  367. (require 'cperl-mode)
  368. ;; Perl file extension associations
  369. (add-to-list 'auto-mode-alist '("\\.pl$" . cperl-mode))
  370. (add-to-list 'auto-mode-alist '("\\.cgi$" . cperl-mode))
  371. (add-to-list 'auto-mode-alist '("\\.pm$" . cperl-mode))
  372. (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
  373. (add-to-list 'auto-mode-alist '("\\.pl$" . cperl-mode))
  374. (add-to-list 'auto-mode-alist '("\\.cgi$" . cperl-mode))
  375. (add-to-list 'auto-mode-alist '("\\.pm$" . cperl-mode))
  376. (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
  377. ;; BSD/Allman indentation style using cperl-mode
  378. (cperl-set-style "BSD")
  379.  
  380. (setq cperl-electric-keywords t) ;; expands for keywords such as
  381.                                      ;; foreach, while, etc...
  382.  
  383. ; Outline-minor-mode key map
  384.  (define-prefix-command 'cm-map nil "Outline-")
  385.  ; HIDE
  386.  (define-key cm-map "q" 'hide-sublevels)    ; Hide everything but the top-level headings
  387.  (define-key cm-map "t" 'hide-body)         ; Hide everything but headings (all body lines)
  388.  (define-key cm-map "o" 'hide-other)        ; Hide other branches
  389.  (define-key cm-map "c" 'hide-entry)        ; Hide this entry's body
  390.  (define-key cm-map "l" 'hide-leaves)       ; Hide body lines in this entry and sub-entries
  391.  (define-key cm-map "d" 'hide-subtree)      ; Hide everything in this entry and sub-entries
  392.  ; SHOW
  393.  (define-key cm-map "a" 'show-all)          ; Show (expand) everything
  394.  (define-key cm-map "e" 'show-entry)        ; Show this heading's body
  395.  (define-key cm-map "i" 'show-children)     ; Show this heading's immediate child sub-headings
  396.  (define-key cm-map "k" 'show-branches)     ; Show all sub-headings under this heading
  397.  (define-key cm-map "s" 'show-subtree)      ; Show (expand) everything in this heading & below
  398.  ; MOVE
  399.  (define-key cm-map "u" 'outline-up-heading)                ; Up
  400.  (define-key cm-map "n" 'outline-next-visible-heading)      ; Next
  401.  (define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
  402.  (define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
  403.  (define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
  404.  (global-set-key "\M-o" cm-map)
  405.  
  406.  
  407.  
  408. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  409. ;; Make TAB expand words. Source:                 ;;
  410. ;; http://emacsblog.org/2007/03/12/tab-completion-everywhere/ ;;
  411. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  412. (defun my-tab-fix ()
  413.   (local-set-key [tab] 'indent-or-expand))
  414.  
  415. (add-hook 'c-mode-hook          'my-tab-fix)
  416. (add-hook 'cperl-mode-hook          'my-tab-fix)
  417. (add-hook 'php-mode-hook          'my-tab-fix)
  418. (add-hook 'js-mode-hook          'my-tab-fix)
  419. (add-hook 'python-mode          'my-tab-fix)
  420. (add-hook 'sh-mode-hook         'my-tab-fix)
  421. (add-hook 'emacs-lisp-mode-hook 'my-tab-fix)
  422. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  423. ;; Define the indent-or-expand function we ;;
  424. ;; just mapped to TAB              ;;
  425. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  426. (defun indent-or-expand (arg)
  427.   "Either indent according to mode, or expand the word preceding
  428. point."
  429.   (interactive "*P")
  430.   (if (and
  431.        (or (bobp) (= ?w (char-syntax (char-before))))
  432.        (or (eobp) (not (= ?w (char-syntax (char-after))))))
  433.       (dabbrev-expand arg)
  434.     (indent-according-to-mode)))
  435.  
  436. ;;; Stop emacs from showing buffer menu when >=3 files opened
  437. (setq inhibit-startup-buffer-menu t)
  438.  
  439.  
  440. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  441. ;; Bury unwanted buffers ;;
  442. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  443.  
  444. ; necessary support function for buffer burial
  445. (defun crs-delete-these (delete-these from-this-list)
  446.   "Delete DELETE-THESE FROM-THIS-LIST."
  447.   (cond
  448.    ((car delete-these)
  449.     (if (member (car delete-these) from-this-list)
  450.         (crs-delete-these (cdr delete-these) (delete (car delete-these)
  451.                              from-this-list))
  452.       (crs-delete-these (cdr delete-these) from-this-list)))
  453.    (t from-this-list)))
  454.                     ; this is the list of buffers I never want to see
  455. (defvar crs-hated-buffers
  456.   '("KILL" "*Compile-Log*" "*Messages*" "*scratch*" "*auto-install"))
  457.                     ; might as well use this for both
  458. (setq iswitchb-buffer-ignore (append '("^ " "*Buffer") crs-hated-buffers))
  459. (defun crs-hated-buffers ()
  460.   "List of buffers I never want to see, converted from names to buffers."
  461.   (delete nil
  462.           (append
  463.            (mapcar 'get-buffer crs-hated-buffers)
  464.            (mapcar (lambda (this-buffer)
  465.                      (if (string-match "^ " (buffer-name this-buffer))
  466.                          this-buffer))
  467.                    (buffer-list)))))
  468. ; I'm sick of switching buffers only to find KILL right in front of me
  469. (defun crs-bury-buffer (&optional n)
  470.   (interactive)
  471.   (unless n
  472.     (setq n 1))
  473.   (let ((my-buffer-list (crs-delete-these (crs-hated-buffers)
  474.                                           (buffer-list (selected-frame)))))
  475.     (switch-to-buffer
  476.      (if (< n 0)
  477.          (nth (+ (length my-buffer-list) n)
  478.               my-buffer-list)
  479.        (bury-buffer)
  480.        (nth n my-buffer-list)))))
  481. (global-set-key [(control tab)] 'crs-bury-buffer)
  482. (global-set-key [(control meta tab)] (lambda ()
  483.                                        (interactive)
  484.                                        (crs-bury-buffer -1)))
  485.  
  486.  
  487.  
  488. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  489. ;;                  ETAGS                 ;;
  490. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  491.   (defun create-tags (dir-name)
  492.      "Create tags file."
  493.      (interactive "DDirectory: ")
  494.      (eshell-command
  495.       (format "find %s -type f -name \"*.[ch]\" | etags -L -" dir-name)))
  496.  
  497.  
  498.   ;;;  Jonas.Jarnestrom<at>ki.ericsson.se A smarter              
  499.   ;;;  find-tag that automagically reruns etags when it cant find a              
  500.   ;;;  requested item and then makes a new try to locate it.                      
  501.   ;;;  Fri Mar 15 09:52:14 2002    
  502.  
  503.   (defadvice find-tag (around refresh-etags activate)
  504.    "Rerun etags and reload tags if tag not found and redo find-tag.              
  505.   If buffer is modified, ask about save before running etags."
  506.   (let ((extension (file-name-extension (buffer-file-name))))
  507.     (condition-case err
  508.     ad-do-it
  509.       (error (and (buffer-modified-p)
  510.           (not (ding))
  511.           (y-or-n-p "Buffer is modified, save it? ")
  512.           (save-buffer))
  513.          (er-refresh-etags extension)
  514.          ad-do-it))))
  515.  
  516.   (defun er-refresh-etags (&optional extension)
  517.   "Run etags on all peer files in current dir and reload them silently."
  518.   (interactive)
  519.   (shell-command (format "etags *.%s" (or extension "el")))
  520.   (let ((tags-revert-without-query t))  ; don't query, revert silently          
  521.     (visit-tags-table default-directory nil)))
  522.  
  523.  
  524. (global-set-key "\M-s" 'tags-search)
  525.  
  526.  
  527. ;;; Delete  buffer
  528. ;;(kill-buffer "*Completions*")
  529.  
  530.  
  531.  
  532. ;;;;;;;; Color theme ;;;;;;;;;;;;;;
  533.  
  534. (defun color-theme-djcb-dark ()
  535.   "dark color theme created by djcb, Jan. 2009."
  536.   (interactive)
  537.   (color-theme-install
  538.     '(color-theme-djcb-dark
  539.        ((foreground-color . "#a9eadf")
  540.          (background-color . "black")
  541.          (background-mode . dark))
  542.        (bold ((t (:bold t))))
  543.        (bold-italic ((t (:italic t :bold t))))
  544.        (default ((t (nil))))
  545.        
  546.        (font-lock-builtin-face ((t (:italic t :foreground "#a96da0"))))
  547.        (font-lock-comment-face ((t (:italic t :foreground "#bbbbbb"))))
  548.        (font-lock-comment-delimiter-face ((t (:foreground "#666666"))))
  549.        (font-lock-constant-face ((t (:bold t :foreground "#197b6e"))))
  550.        (font-lock-doc-string-face ((t (:foreground "#3041c4"))))
  551.        (font-lock-doc-face ((t (:foreground "gray"))))
  552.        (font-lock-reference-face ((t (:foreground "white"))))
  553.        (font-lock-function-name-face ((t (:foreground "#356da0"))))
  554.        (font-lock-keyword-face ((t (:bold t :foreground "#bcf0f1"))))
  555.        (font-lock-preprocessor-face ((t (:foreground "#e3ea94"))))
  556.        (font-lock-string-face ((t (:foreground "#ffffff"))))
  557.        (font-lock-type-face ((t (:bold t :foreground "#364498"))))
  558.        (font-lock-variable-name-face ((t (:foreground "#7685de"))))
  559.        (font-lock-warning-face ((t (:bold t :italic nil :underline nil
  560.                                      :foreground "yellow"))))
  561.        (hl-line ((t (:background "#112233"))))
  562.        (mode-line ((t (:foreground "#ffffff" :background "#333333"))))
  563.        (region ((t (:foreground nil :background "#555555"))))
  564.        (show-paren-match-face ((t (:bold t :foreground "#ffffff"
  565.                                     :background "#050505")))))))
  566.  
  567.  
  568.  
  569. (add-to-list 'process-coding-system-alist '("zsh" . utf-8))
  570.  
  571. (put 'upcase-region 'disabled nil)
  572.  
  573.  
  574. ;; Informative comments,
  575. ;; comments that I want to keep or whatever
  576. (add-hook 'tex-mode-hook
  577.   (lambda ()
  578.     (font-lock-add-keywords nil
  579.       ;;'(("\\<\\(FIXME\\|TODO\\|HACK\\|fixme\\|todo\\|hack\\)" 1
  580.                 '(("\\(%#.*\\)" 1
  581.         font-lock-warning-face t)))))
  582. (add-hook 'cperl-mode-hook
  583.   (lambda ()
  584.     (font-lock-add-keywords nil
  585.                 '(("\\(#%.*\\)" 1
  586.         font-lock-warning-face t)))))
  587.  
  588. ;;;;;;;;;;;;;;;;;;;;
  589. ;; Enable tabbar  ;;
  590. ;;;;;;;;;;;;;;;;;;;;
  591. (tabbar-mode t)
  592.  
  593.  
  594. ;;; Markdown mode
  595. (autoload 'gfm-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
  596. (setq auto-mode-alist (cons '("\\.text$" . gfm-mode) auto-mode-alist))
  597. (setq auto-mode-alist (cons '("\\.md$" . gfm-mode) auto-mode-alist))
  598. (setq auto-mode-alist (cons '("\\.mdown$" . gfm-mode) auto-mode-alist))
  599. (setq auto-mode-alist (cons '("\\.mdt$" . gfm-mode) auto-mode-alist))
  600. (setq auto-mode-alist (cons '("\\.markdown$" . gfm-mode) auto-mode-alist))
  601.  
  602.  
  603. ;;;;;;;;;;;;;;;;;;
  604. ;; Color themes ;;
  605. ;;;;;;;;;;;;;;;;;;
  606.  
  607. (add-to-list 'load-path "~/.emacs-lisp/emacs-color-theme-solarized")
  608. (color-theme-zenburn)
  609.  
  610. ;; (require 'color-theme-solarized)
  611. ;; (autoload 'color-theme-solarized-light "aa" "bb" t)
  612.  ;; (require 'color-theme-solarized)
  613.  ;; (color-theme-solarized-dark)
  614.  
  615. ;;;;;;;;;;;;;;;;;
  616. ;; LaTeX stuff ;;
  617. ;;;;;;;;;;;;;;;;;
  618. (setq TeX-PDF-mode t)
  619.  
  620. (setq TeX-auto-save t)
  621. (setq TeX-parse-self t)
  622. (setq-default TeX-master nil)
  623.  
  624. (add-hook 'LaTeX-mode-hook 'visual-line-mode)
  625. (add-hook 'LaTeX-mode-hook 'flyspell-mode)
  626. (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
  627.  
  628. (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
  629. (setq reftex-plug-into-AUCTeX t)
  630.  
  631. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  632. ;; Chrome edit with emacs extension ;;
  633. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  634. (add-to-list 'load-path "~/.emacs.d")
  635. (require 'edit-server)
  636. (edit-server-start)
  637.  
  638. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  639. ;; Enable markdown mode for editing SE posts ;;
  640. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  641. ;; Integrate Emacs with Stack Exchange http://stackoverflow.com/a/10386560/789593
  642. (add-to-list 'auto-mode-alist '("stack\\(exchange\\|overflow\\)\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))
  643. (add-to-list 'auto-mode-alist '("superuser\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))
Advertisement
Add Comment
Please, Sign In to add comment