dotfiles / emacs

Full commit
;;  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)

;; 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/"))
(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 ()
                            (flyspell-mode t)
                            (abbrev-mode t)

;; LaTeX (auctex)
(add-hook 'LaTeX-mode-hook (lambda ()
                             ;; (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)

;; Fill sentences in latex documents. Line per sentence.
(defun auto-fill-by-sentences ()
  (if (looking-back (sentence-end))
      ;; Break at a sentence
    ;; Fall back to the default
(add-hook 'LaTeX-mode-hook (lambda () (setq auto-fill-function 'auto-fill-by-sentences)))

(defadvice LaTeX-fill-region-as-paragraph (around LaTeX-sentence-filling)
  "Start each sentence on a new line."
  (let ((from (ad-get-arg 0))
        (to-marker (set-marker (make-marker) (ad-get-arg 1)))
    (while (< from (marker-position to-marker))
      ;; might have gone beyond to-marker --- use whichever is smaller:
      (ad-set-arg 1 (setq tmp-end (min (point) (marker-position to-marker))))
      (ad-set-arg 0 (setq from (point)))
      (unless (or
               (looking-at "\\s *$"))
    (set-marker to-marker nil)))
(ad-activate 'LaTeX-fill-region-as-paragraph)

;; 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
(add-to-list 'load-path (expand-file-name "~/.dotfiles/emacs.d/undo-tree"))
(require 'undo-tree)