diff --git a/.emacs.d/.gitignore b/.emacs.d/.gitignore index 5c0dfe3..8fcf383 100644 --- a/.emacs.d/.gitignore +++ b/.emacs.d/.gitignore @@ -1,5 +1,15 @@ +# Packages .cask -elpa + +# Configuration +emacs.el +custom.el + +# Data auto-save-list session.* ac-comphist.dat +eshell +projectile-bookmarks.eld +url +.org-id-locations diff --git a/.emacs.d/emacs.org b/.emacs.d/emacs.org new file mode 100644 index 0000000..e88667c --- /dev/null +++ b/.emacs.d/emacs.org @@ -0,0 +1,345 @@ +#+TITLE: Emacs Configuration + +* Startup + Disable the emacs startup screen. + #+name: startup + #+BEGIN_SRC emacs-lisp + (setq inhibit-startup-screen +1) + #+END_SRC +* Global key bindings + #+name: global-keys + #+BEGIN_SRC emacs-lisp + (global-set-key (kbd "C-,") 'kill-whole-line) + #+END_SRC +* Look and Feel + #+name: look-and-feel + #+BEGIN_SRC emacs-lisp + (load-theme 'twilight 't) + #+END_SRC +* Autocomplete + #+name: autocomplete + #+BEGIN_SRC emacs-lisp + (require 'auto-complete-config) + (ac-config-default) + #+END_SRC +* Package Configuration +** Ido + #+name: packages + #+BEGIN_SRC emacs-lisp + (ido-mode +1) + (setq ido-enable-flex-matching t) + #+END_SRC +** Smex + #+name: packages + #+BEGIN_SRC emacs-lisp + (global-set-key (kbd "M-x") 'smex) + (global-set-key (kbd "M-X") 'smex-major-mode-commands) + #+END_SRC +** Expand Region + #+name: packages + #+BEGIN_SRC emacs-lisp + (global-set-key (kbd "C-=") 'er/expand-region) + #+END_SRC +** Flycheck + #+name: packages + #+BEGIN_SRC emacs-lisp + (add-hook 'after-init-hook #'global-flycheck-mode) + #+END_SRC +** Git-Gutter + #+name: packages + #+BEGIN_SRC emacs-lisp + (global-git-gutter-mode t) + + (defadvice ediff-make-temp-file (before make-temp-file-suspend-ll + activate compile preactivate) + "Disable git-gutter when running ediff" + (global-git-gutter-mode 0)) + + (add-hook 'ediff-cleanup-hook + '(lambda () + (global-git-gutter-mode t))) + + #+END_SRC +** Magit + #+name: packages + #+BEGIN_SRC emacs-lisp + (defun magit-fullscreen () + (defadvice magit-status (around magit-fullscreen activate) + (window-configuration-to-register :magit-fullscreen) + ad-do-it + (delete-other-windows)) + + (defadvice magit-quit-window (around magit-restore-screen activate) + ad-do-it + (jump-to-register :magit-fullscreen))) + + (eval-after-load 'magit '(magit-fullscreen)) + #+END_SRC +** Markdown + #+name: packages + #+BEGIN_SRC emacs-lisp + (setq auto-mode-alist + (cons '("\\.md" . markdown-mode) auto-mode-alist)) + #+END_SRC +** Org +*** Babel +**** Syntax highlighting + #+name: packages + #+BEGIN_SRC emacs-lisp + (setq-default org-src-fontify-natively t) + #+END_SRC +**** Language evaluation + #+name: packages + #+BEGIN_SRC emacs-lisp + (defvar my/org-babel-evaluated-languages + '(emacs-lisp) + "List of languages that may be evaluated in Org documents") + + <> + + (org-babel-do-load-languages + 'org-babel-load-languages + (mapcar (lambda (lang) + (cons lang t)) + my/org-babel-evaluated-languages)) + #+END_SRC +***** Graphviz + #+name: org-babel-languages + #+BEGIN_SRC emacs-lisp + (add-to-list 'org-src-lang-modes (quote ("dot" . graphviz-dot))) + + (add-to-list 'my/org-babel-evaluated-languages 'dot) + #+END_SRC +***** Ditaa + #+name: org-babel-languages + #+BEGIN_SRC emacs-lisp + (add-to-list 'my/org-babel-evaluated-languages 'ditaa) + #+END_SRC +***** PlantUML + #+name: org-babel-languages + #+BEGIN_SRC emacs-lisp + (add-to-list 'my/org-babel-evaluated-languages 'plantuml) + #+END_SRC +***** Mscgen + A message sequence chart renderer. + #+name: org-babel-languages + #+BEGIN_SRC emacs-lisp + (add-to-list 'my/org-babel-evaluated-languages 'mscgen) + #+END_SRC +** Powerline + #+name: packages + #+BEGIN_SRC emacs-lisp + (powerline-default-theme) + #+END_SRC +** Projectile + #+name: packages + #+BEGIN_SRC emacs-lisp + (projectile-global-mode) + #+END_SRC +** Web Mode + #+name: packages + #+BEGIN_SRC emacs-lisp + (add-hook 'web-mode-hook (lambda () + (setq web-mode-markup-indent-offset 4) + (setq web-mode-css-indent-offset 4) + (setq web-mode-code-indent-offset 4))) + #+END_SRC +* Programming +** Lisps + #+name: programming + #+BEGIN_SRC emacs-lisp + ;; SLIME + (if (file-exists-p "~/quicklisp/slime-helper.el") + (load (expand-file-name "~/quicklisp/slime-helper.el"))) + + (setq inferior-lisp-program "clisp") + + (mapcar (lambda (mode-hook) + (eval-after-load "paredit" `(add-hook ',mode-hook #'enable-paredit-mode)) + (eval-after-load "rainbow-delimiters" `(add-hook ',mode-hook #'rainbow-delimiters-mode)) + (eval-after-load "rainbow-identifiers" `(add-hook ',mode-hook #'rainbow-identifiers-mode)) + (add-hook mode-hook (lambda () + (show-paren-mode) + (electric-indent-mode 1) + (paredit-mode 1) + (rainbow-delimiters-mode 1) + (rainbow-identifiers-mode 1))) + ) + '(lisp-mode-hook + emacs-lisp-mode-hook + scheme-mode-hook + lfe-mode-hook + clojure-mode-hook)) + #+END_SRC +** Erlang + #+name: programming + #+BEGIN_SRC emacs-lisp + (add-hook 'erlang-mode-hook + (lambda () + (setq inferior-erlang-machine-options '("-sname" "emacs" + "-hidden")))) + #+END_SRC +** PHP + #+name: programming + #+BEGIN_SRC emacs-lisp + (add-to-list 'auto-mode-alist '("\\.php$" . php-mode)) + (add-to-list 'auto-mode-alist '("\\.inc$" . php-mode)) + + (defun my-php-mode-hook () + "Customize PHP indentation" + + (c-set-offset 'arglist-cont-nonempty 'c-lineup-arglist) + (c-set-offset 'substatement-open 0) + (c-set-offset 'case-label '+)) + + (add-hook 'php-mode-hook 'my-php-mode-hook) + #+END_SRC +* Other functionality +** Rename file and buffer + Taken from [[http://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/][Emacs Redux]] + #+name: other + #+BEGIN_SRC emacs-lisp + ;; emacsredux.com + (defun rename-file-and-buffer () + "Rename the current buffer and file it is visiting." + (interactive) + (let ((filename (buffer-file-name))) + (if (not (and filename (file-exists-p filename))) + (message "Buffer is not visiting a file!") + (let ((new-name (read-file-name "New name: " filename))) + (cond + ((vc-backend filename) (vc-rename-file filename new-name)) + (t + (rename-file filename new-name t) + (rename-buffer new-name) + (set-visited-file-name new-name) + (set-buffer-modified-p nil))))))) + #+END_SRC +** Eval and Replace + Taken from [[http://emacsredux.com/blog/2013/06/21/eval-and-replace/][Emacs Redux]] + #+name: other + #+BEGIN_SRC emacs-lisp + (defun eval-and-replace () + "Replace the preceding sexp with its value." + (interactive) + (backward-kill-sexp) + (condition-case nil + (prin1 (eval (read (current-kill 0))) + (current-buffer)) + (error (message "Invalid expression") + (insert (current-kill 0))))) + + (global-set-key (kbd "C-)") 'eval-and-replace) + #+END_SRC +** Smarter navigation to the beginning of a line + Taken from [[http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/][Emacs Redux]] + #+name: other + #+BEGIN_SRC emacs-lisp + (defun smarter-move-beginning-of-line (arg) + "Move point back to indentation of beginning of line. + + Move point to the first non-whitespace character on this line. + If point is already there, move to the beginning of the line. + Effectively toggle between the first non-whitespace character and + the beginning of the line. + + If ARG is not nil or 1, move forward ARG - 1 lines first. If + point reaches the beginning or end of the buffer, stop there." + (interactive "^p") + (setq arg (or arg 1)) + + ;; Move lines first + (when (/= arg 1) + (let ((line-move-visual nil)) + (forward-line (1- arg)))) + + (let ((orig-point (point))) + (back-to-indentation) + (when (= orig-point (point)) + (move-beginning-of-line 1)))) + + ;; remap C-a to `smarter-move-beginning-of-line' + (global-set-key [remap move-beginning-of-line] + 'smarter-move-beginning-of-line) + #+END_SRC +** Edit file with sudo + Taken from [[http://www.emacswiki.org/TrampMode#toc32][EmacsWiki]] + #+name: other + #+BEGIN_SRC emacs-lisp + (require 'dired) + (defun sudo-edit-current-file () + (interactive) + (let ((my-file-name) ; fill this with the file to open + (position)) ; if the file is already open save position + (if (equal major-mode 'dired-mode) ; test if we are in dired-mode + (progn + (setq my-file-name (dired-get-file-for-visit)) + (find-alternate-file (prepare-tramp-sudo-string my-file-name))) + (setq my-file-name (buffer-file-name); hopefully anything else is an already opened file + position (point)) + (find-alternate-file (prepare-tramp-sudo-string my-file-name)) + (goto-char position)))) + + + (defun prepare-tramp-sudo-string (tempfile) + (if (file-remote-p tempfile) + (let ((vec (tramp-dissect-file-name tempfile))) + + (tramp-make-tramp-file-name + "sudo" + (tramp-file-name-user nil) + (tramp-file-name-host vec) + (tramp-file-name-localname vec) + (format "ssh:%s@%s|" + (tramp-file-name-user vec) + (tramp-file-name-host vec)))) + (concat "/sudo:root@localhost:" tempfile))) + + (define-key dired-mode-map [s-return] 'sudo-edit-current-file) + #+END_SRC +* Custom settings + Store options set via =customize-*= in a separate file (Emacs stores + them in =init.el= by default). + + #+name: custom-settings + #+BEGIN_SRC emacs-lisp + (setq custom-file "~/.emacs.d/custom.el") + (if (file-exists-p custom-file) + (load custom-file)) + #+END_SRC +* Auto-loading elisp files + Any elisp files dropped into =~/.emacs.local.d/= will be + automatically loaded. + + #+name: auto-load + #+BEGIN_SRC emacs-lisp + (defun my/load-elisp-directory (path) + (let ((file-pattern "\\.elc?$")) + (when (file-directory-p path) + (mapcar (lambda (lisp-file) + (load-file lisp-file)) + (directory-files (expand-file-name path) t file-pattern))))) + + (my/load-elisp-directory "~/.emacs.d/init.d") + (my/load-elisp-directory "~/.emacs.local.d") + #+END_SRC +* Configuration file layout + + Here I define the emacs.el file that gets generated by the code in + this org file. + + #+BEGIN_SRC emacs-lisp :tangle yes :noweb no-export :exports code + ;;;; Do not modify this file by hand. It was automatically generated + ;;;; from `emacs.org` in the same directory. See that file for more + ;;;; information. + ;;;; + + <> + <> + <> + <> + <> + <> + <> + <> + #+END_SRC diff --git a/.emacs.d/init.d/emacsredux.el b/.emacs.d/init.d/emacsredux.el deleted file mode 100644 index 69a5ebc..0000000 --- a/.emacs.d/init.d/emacsredux.el +++ /dev/null @@ -1,32 +0,0 @@ -;; emacsredux.com -(defun rename-file-and-buffer () - "Rename the current buffer and file it is visiting." - (interactive) - (let ((filename (buffer-file-name))) - (if (not (and filename (file-exists-p filename))) - (message "Buffer is not visiting a file!") - (let ((new-name (read-file-name "New name: " filename))) - (cond - ((vc-backend filename) (vc-rename-file filename new-name)) - (t - (rename-file filename new-name t) - (rename-buffer new-name) - (set-visited-file-name new-name) - (set-buffer-modified-p nil))))))) - -(defadvice ido-find-file (after find-file-sudo activate) - "Find file as root if necessary." - (unless (and buffer-file-name - (file-writable-p buffer-file-name)) - (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))) - -(defun eval-and-replace () - "Replace the preceding sexp with its value." - (interactive) - (backward-kill-sexp) - (condition-case nil - (prin1 (eval (read (current-kill 0))) - (current-buffer)) - (error (message "Invalid expression") - (insert (current-kill 0))))) -(global-set-key (kbd "C-)") 'eval-and-replace) diff --git a/.emacs.d/init.d/erlang.el b/.emacs.d/init.d/erlang.el deleted file mode 100644 index 7eac2a4..0000000 --- a/.emacs.d/init.d/erlang.el +++ /dev/null @@ -1,18 +0,0 @@ -;; Erlang configuration -(add-to-list - 'load-path - (car (file-expand-wildcards "/usr/lib/erlang/lib/tools-*/emacs"))) -(setq erlang-root-dir "/usr/lib/erlang") -(setq exec-path (cons "/usr/lib/erlang/bin" exec-path)) -(require 'erlang-start) -(add-hook 'erlang-mode-hook - (lambda () - ;; when starting an Erlang shell in Emacs, the node name - ;; by default should be "emacs" - (setq inferior-erlang-machine-options '("-sname" "emacs")))) - -;; Lisp-Flavored Erlang -(add-to-list - 'load-path - (car (file-expand-wildcards "/usr/lib/erlang/lib/lfe-*/emacs"))) -(require 'lfe-start 'nil 'noerror) diff --git a/.emacs.d/init.d/flycheck.el b/.emacs.d/init.d/flycheck.el deleted file mode 100644 index c9c8a91..0000000 --- a/.emacs.d/init.d/flycheck.el +++ /dev/null @@ -1,2 +0,0 @@ -(add-hook 'after-init-hook #'global-flycheck-mode) - diff --git a/.emacs.d/init.d/git-gutter.el b/.emacs.d/init.d/git-gutter.el deleted file mode 100644 index f80ffd0..0000000 --- a/.emacs.d/init.d/git-gutter.el +++ /dev/null @@ -1,11 +0,0 @@ -;; Git Gutter -(global-git-gutter-mode t) - -(defadvice ediff-make-temp-file (before make-temp-file-suspend-ll - activate compile preactivate) - "Disable git-gutter when running ediff" - (global-git-gutter-mode 0)) - -(add-hook 'ediff-cleanup-hook - '(lambda () - (global-git-gutter-mode t))) diff --git a/.emacs.d/init.d/key-bindings.el b/.emacs.d/init.d/key-bindings.el deleted file mode 100644 index e69de29..0000000 diff --git a/.emacs.d/init.d/lisp.el b/.emacs.d/init.d/lisp.el deleted file mode 100644 index 22cf146..0000000 --- a/.emacs.d/init.d/lisp.el +++ /dev/null @@ -1,23 +0,0 @@ -;; SLIME -(if (file-exists-p "~/quicklisp/slime-helper.el") - (load (expand-file-name "~/quicklisp/slime-helper.el"))) - -(setq inferior-lisp-program "clisp") - -(mapcar (lambda (mode-hook) - (eval-after-load "paredit" `(add-hook ',mode-hook #'enable-paredit-mode)) - (eval-after-load "rainbow-delimiters" `(add-hook ',mode-hook #'rainbow-delimiters-mode)) - (eval-after-load "rainbow-identifiers" `(add-hook ',mode-hook #'rainbow-identifiers-mode)) - (add-hook mode-hook (lambda () - (show-paren-mode) - (electric-indent-mode 1) - (paredit-mode 1) - (rainbow-delimiters-mode 1) - (rainbow-identifiers-mode 1))) - ) - '(lisp-mode-hook - emacs-lisp-mode-hook - scheme-mode-hook - lfe-mode-hook - clojure-mode-hook)) - diff --git a/.emacs.d/init.d/magit-fullscreen.el b/.emacs.d/init.d/magit-fullscreen.el deleted file mode 100644 index 6e49286..0000000 --- a/.emacs.d/init.d/magit-fullscreen.el +++ /dev/null @@ -1,12 +0,0 @@ -;; Magit -(defun magit-fullscreen () - (defadvice magit-status (around magit-fullscreen activate) - (window-configuration-to-register :magit-fullscreen) - ad-do-it - (delete-other-windows)) - - (defadvice magit-quit-window (around magit-restore-screen activate) - ad-do-it - (jump-to-register :magit-fullscreen))) - -(eval-after-load 'magit '(magit-fullscreen)) diff --git a/.emacs.d/init.d/markdown.el b/.emacs.d/init.d/markdown.el deleted file mode 100644 index 87196c5..0000000 --- a/.emacs.d/init.d/markdown.el +++ /dev/null @@ -1,2 +0,0 @@ -(setq auto-mode-alist - (cons '("\\.md" . markdown-mode) auto-mode-alist)) diff --git a/.emacs.d/init.d/php.el b/.emacs.d/init.d/php.el deleted file mode 100644 index 2ab9d09..0000000 --- a/.emacs.d/init.d/php.el +++ /dev/null @@ -1,12 +0,0 @@ -;; PHP Mode -(add-to-list 'auto-mode-alist '("\\.php$" . php-mode)) -(add-to-list 'auto-mode-alist '("\\.inc$" . php-mode)) - -(defun my-php-mode-hook () - "Customize PHP indentation" - - (c-set-offset 'arglist-cont-nonempty 'c-lineup-arglist) - (c-set-offset 'substatement-open 0) - (c-set-offset 'case-label '+)) - -(add-hook 'php-mode-hook 'my-php-mode-hook) diff --git a/.emacs.d/init.d/powerline.el b/.emacs.d/init.d/powerline.el deleted file mode 100644 index 8ea825a..0000000 --- a/.emacs.d/init.d/powerline.el +++ /dev/null @@ -1 +0,0 @@ -(powerline-default-theme) diff --git a/.emacs.d/init.d/projectile.el b/.emacs.d/init.d/projectile.el deleted file mode 100644 index 58d2d77..0000000 --- a/.emacs.d/init.d/projectile.el +++ /dev/null @@ -1 +0,0 @@ -(projectile-global-mode) diff --git a/.emacs.d/init.d/smarter-move-beginning-of-line.el b/.emacs.d/init.d/smarter-move-beginning-of-line.el deleted file mode 100644 index dc379ae..0000000 --- a/.emacs.d/init.d/smarter-move-beginning-of-line.el +++ /dev/null @@ -1,26 +0,0 @@ -(defun smarter-move-beginning-of-line (arg) - "Move point back to indentation of beginning of line. - -Move point to the first non-whitespace character on this line. -If point is already there, move to the beginning of the line. -Effectively toggle between the first non-whitespace character and -the beginning of the line. - -If ARG is not nil or 1, move forward ARG - 1 lines first. If -point reaches the beginning or end of the buffer, stop there." - (interactive "^p") - (setq arg (or arg 1)) - - ;; Move lines first - (when (/= arg 1) - (let ((line-move-visual nil)) - (forward-line (1- arg)))) - - (let ((orig-point (point))) - (back-to-indentation) - (when (= orig-point (point)) - (move-beginning-of-line 1)))) - -;; remap C-a to `smarter-move-beginning-of-line' -(global-set-key [remap move-beginning-of-line] - 'smarter-move-beginning-of-line) diff --git a/.emacs.d/init.d/smex.el b/.emacs.d/init.d/smex.el deleted file mode 100644 index c5abb2a..0000000 --- a/.emacs.d/init.d/smex.el +++ /dev/null @@ -1,3 +0,0 @@ -;; Smex -(global-set-key (kbd "M-x") 'smex) -(global-set-key (kbd "M-X") 'smex-major-mode-commands) diff --git a/.emacs.d/init.d/tramp-remote-sudo.el b/.emacs.d/init.d/tramp-remote-sudo.el deleted file mode 100644 index 6c88700..0000000 --- a/.emacs.d/init.d/tramp-remote-sudo.el +++ /dev/null @@ -1 +0,0 @@ -(set-default 'tramp-default-proxies-alist (quote ((".*" "\\`root\\'" "/ssh:%h:")))) diff --git a/.emacs.d/init.d/web-mode.el b/.emacs.d/init.d/web-mode.el deleted file mode 100644 index d7a4513..0000000 --- a/.emacs.d/init.d/web-mode.el +++ /dev/null @@ -1,4 +0,0 @@ -(add-hook 'web-mode-hook (lambda () - (setq web-mode-markup-indent-offset 4) - (setq web-mode-css-indent-offset 4) - (setq web-mode-code-indent-offset 4))) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 7871766..6b1cd7b 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,75 +1,5 @@ -(add-to-list 'load-path "~/.emacs.d/elisp") - -(require 'package) -(add-to-list 'package-archives - '("elpa" . "http://elpa.gnu.org/packages/")) - -;; Add the user-contributed repository -(add-to-list 'package-archives - '("marmalade" . "http://marmalade-repo.org/packages/")) - -;; Milkypostman’s Experimental Lisp Package Repository -(add-to-list 'package-archives - '("melpa" . "http://melpa.milkbox.net/packages/") t) - -(package-initialize) - (require 'cask "~/.cask/cask.el") (cask-initialize) -;; Emacs -(global-set-key (kbd "C-,") 'kill-whole-line) - -;; ido-mode -(ido-mode) -(setq ido-enable-flex-matching t) - -;; Autocomplete -(require 'auto-complete-config) -(ac-config-default) - -;; Expand Region -(global-set-key (kbd "C-=") 'er/expand-region) - -(defun load-elisp-directory (path) - (let ((file-pattern "\\.elc?$")) - (when (file-directory-p path) - (mapcar (lambda (lisp-file) - (load-file lisp-file)) - (directory-files (expand-file-name path) t file-pattern))))) - -(load-elisp-directory "~/.emacs.d/init.d") -(load-elisp-directory "~/.emacs.local.d") - -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(blank-chars (quote (tabs trailing space-before-tab))) - '(blank-global-modes t) - '(browse-url-browser-function (quote browse-url-generic)) - '(browse-url-generic-program "google-chrome") - '(c-basic-offset 4) - '(c-default-style "bsd") - '(eol-mnemonic-dos "(DOS)") - '(eol-mnemonic-mac "(Mac)") - '(haskell-mode-hook (quote (turn-on-haskell-indentation)) t) - '(indent-tabs-mode nil) - '(inferior-lisp-program "sbcl") - '(inhibit-startup-screen t)) -(put 'narrow-to-region 'disabled nil) - -(when (display-graphic-p) - ;; Theme - (load-theme 'twilight t) - - ;; Font customizations - (custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(default ((t (:inherit nil :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 80 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))) - '(font-lock-function-name-face ((t (:foreground "LightSkyBlue" :weight bold)))) - '(font-lock-type-face ((t (:foreground "PaleGreen" :weight bold)))))) +(require 'org) +(org-babel-load-file "~/.emacs.d/emacs.org")