terdon

terdon's .emacs

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