Source

dotfiles / emacs

;;===================
;;  Global Settings
;;===================

(savehist-mode t)
(show-paren-mode t)
(column-number-mode t)
(pc-selection-mode t)

;; InteractivelyDoThings
(ido-mode t)
(ido-everywhere t)
(setq ido-enable-flex-matching t)

;; Browse kill ring (M-y)
(browse-kill-ring-default-keybindings)

;; turn off toolbar
(if window-system
    (tool-bar-mode 0))

(setq-default indicate-empty-lines t)
(setq-default indent-tabs-mode nil)
(setq-default show-trailing-whitespace t)
(setq-default make-backup-files nil)
(setq scroll-conservatively 1000)
(setq mouse-wheel-scroll-amount (quote (1)))
(setq require-final-newline 'visit-save)

(set-variable 'sentence-end "\\. ")
(put 'downcase-region 'disabled nil)

;; Paths
(setq abbrev-file-name "~/.emacs.d/abbrev")
(setq desktop-path '("~/.emacs.d"))
(setq desktop-base-file-name "desktop")

;;==========================
;;  Mode-Specific Settings
;;==========================

;; C code indentation style
(setq c-default-style "linux"
      c-basic-offset 4)

;; Org-mode
;(global-set-key "\C-cl" 'org-store-link)
;(global-set-key "\C-ca" 'org-agenda)
;(global-set-key "\C-cb" 'org-iswitchb)
(setq org-agenda-files (list "~/notes/todo.org"))
(setq org-enforce-todo-checkbox-dependencies t)
(setq org-enforce-todo-dependencies t)
(setq org-log-states-order-reversed nil)
(setq org-log-into-drawer t)
(setq org-log-done 'time)
(setq org-log-done-with-time nil)

;; All text-mode-based modes
(add-hook 'text-mode-hook (lambda ()
                            (turn-on-auto-fill)
                            (text-mode-hook-identify)
                            (flyspell-mode t)
                            (abbrev-mode t)
                            ))

;; LaTeX (auctex)
(add-hook 'LaTeX-mode-hook (lambda ()
                             (turn-on-reftex)
                             (TeX-fold-mode)
                             (LaTeX-math-mode)
                             (TeX-PDF-mode)
                             ;; (TeX-source-correlate-mode)
                             ))
(setq TeX-view-program-list '(("Evince" "evince --page-label=%(outpage) %o")))
(setq TeX-view-program-selection '((output-pdf "Evince")))
;;(setq TeX-source-correlate-start-server t)

;; VHDL-mode
(setq vhdl-clock-edge-condition (quote function))
(setq vhdl-standard (quote (93 nil)))

;;=======================
;;  Global Key Bindings
;;=======================

;; Alt-<arrow> moves between windows
(windmove-default-keybindings 'meta)

;; Use Ibuffer for Buffer List
(global-set-key (kbd "C-x C-b") 'ibuffer)

;; Use Scroll-Lock key to toggle scroll-lock-mode
(global-set-key (quote [Scroll_Lock]) 'scroll-lock-mode)

;; Single-line scrolling without moving the point
(global-set-key [(control down)] (lambda () (interactive) (scroll-up   1)) )
(global-set-key [(control up  )] (lambda () (interactive) (scroll-down 1)) )

;;====================
;;  Clipboard Tweaks
;;====================

;; Stops selection with a mouse being immediately injected to the kill ring
(setq mouse-drag-copy-region nil)
;; Stops killing/yanking interacting with primary X11 selection
(setq x-select-enable-primary nil)
;; Makes killing/yanking interact with clipboard X11 selection
(setq x-select-enable-clipboard t)
;; Active region sets primary X11 selection
(setq select-active-regions t)
;; Make mouse middle-click only paste from primary X11 selection, not
;; clipboard and kill ring.
(global-set-key [mouse-2] 'mouse-yank-primary)

;;========================
;;  Compatibility Tweaks
;;========================

;; Fix keys in screen
(global-set-key [select] 'end-of-line-nomark)

(mapc (lambda (map)
        (define-key function-key-map
          (read-kbd-macro (cadr map))
          (read-kbd-macro (car map))))
      '(("<S-up>"       "ESC [1;2A")
        ("<S-down>"     "ESC [1;2B")
        ("<S-right>"    "ESC [1;2C")
        ("<S-left>"     "ESC [1;2D")

        ("<M-up>"       "ESC [1;3A")
        ("<M-down>"     "ESC [1;3B")
        ("<M-right>"    "ESC [1;3C")
        ("<M-left>"     "ESC [1;3D")

        ("<M-S-up>"     "ESC [1;4A")
        ("<M-S-down>"   "ESC [1;4B")
        ("<M-S-right>"  "ESC [1;4C")
        ("<M-S-left>"   "ESC [1;4D")

        ("<C-up>"       "ESC [1;5A")
        ("<C-down>"     "ESC [1;5B")
        ("<C-right>"    "ESC [1;5C")
        ("<C-left>"     "ESC [1;5D")

        ("<C-S-up"      "ESC [1;6A")
        ("<C-S-down"    "ESC [1;6B")
        ("<C-S-right>"  "ESC [1;6C")
        ("<C-S-left>"   "ESC [1;6D")

        ("<C-home>"     "ESC [1;5H")
        ("<C-end>"      "ESC [1;5F")

        ("<S-home>"     "ESC [1;2H")
        ("<S-end>"      "ESC [1;2F")

        ("<C-S-home>"   "ESC [1;6H")
        ("<C-S-end>"    "ESC [1;6F")
        ))

;;=====================
;;  Third-Party Modes
;;=====================

;; Undo Tree
;;   http://www.dr-qubit.org/emacs.php#undo-tree
(add-to-list 'load-path (expand-file-name "~/.dotfiles/emacs.d/undo-tree"))
(require 'undo-tree)
(global-undo-tree-mode)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.