Updated emacs-d and added Remtrail command to vimrc

This commit is contained in:
hellerve
2015-06-15 16:10:45 +02:00
parent d6da2b169d
commit 23636108a1
64 changed files with 3571 additions and 21 deletions

View File

@@ -0,0 +1,198 @@
;;; -*- lexical-binding: t -*-
;;; ohai-appearance.el --- Fashion and aesthetics.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
(require 'ohai-personal-taste)
(require 'term)
;; Get rid of the training wheels, if you're ready for it.
(when (not ohai-personal-taste/training-wheels)
(dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
(when (fboundp mode) (funcall mode -1))))
;; Configure the light colour scheme.
(defun ohai-appearance/light ()
(interactive)
(load-theme 'leuven)
(set-face-attribute 'mode-line nil
:foreground "#cccccc"
:background "#000000"
:box nil
:weight 'bold)
(set-face-attribute 'mode-line-buffer-id nil
:foreground "white"
:weight 'bold)
(set-face-foreground 'which-func "#3cb64a")
(set-face-attribute 'linum nil :height 0.7)
(set-face-foreground 'term-color-black "#ffffff")
(set-face-foreground 'term-color-red "#f5666d")
(set-face-foreground 'term-color-green "#3cb64a")
(set-face-foreground 'term-color-yellow "#ce5c00")
(set-face-foreground 'term-color-blue "#00578e")
(set-face-foreground 'term-color-magenta "#d020f0")
(set-face-foreground 'term-color-cyan "#6799cc")
(set-face-foreground 'term-color-white "#000000")
(run-hooks 'ohai-appearance/hook)
(run-hooks 'ohai-appearance/light-hook))
;; Configure the dark colour scheme.
(defun ohai-appearance/dark ()
(interactive)
(load-theme 'wombat)
(set-face-background 'region "#374186")
(set-face-background 'fringe "#191919")
(set-face-attribute 'linum nil :background nil :height 0.7)
(set-face-foreground 'which-func "#7f9f7f")
(set-face-foreground 'term-color-black "#3f3f3f")
(set-face-foreground 'term-color-red "#cc9393")
(set-face-foreground 'term-color-green "#7f9f7f")
(set-face-foreground 'term-color-yellow "#f0dfaf")
(set-face-foreground 'term-color-blue "#8cd0d3")
(set-face-foreground 'term-color-magenta "#dc8cc3")
(set-face-foreground 'term-color-cyan "#93e0e3")
(set-face-foreground 'term-color-white "#dcdccc")
(run-hooks 'ohai-appearance/hook)
(run-hooks 'ohai-appearance/dark-hook))
;; Setup hooks to re-run after all modules have loaded, allowing
;; other modules to tweak the theme without having to wait
;; until they're loaded to switch to it.
(add-hook
'ohai/modules-loaded-hook
(lambda ()
(run-hooks 'ohai-appearance/hook)
(cond
((equal ohai-personal-taste/style 'dark)
(run-hooks 'ohai-appearance/dark-hook))
((equal ohai-personal-taste/style 'light)
(run-hooks 'ohai-appearance/light-hook)))))
;; Maximise the Emacs frame if that's how you like it.
(if (equal ohai-personal-taste/window-state 'maximised)
(set-frame-parameter nil 'fullscreen 'maximized))
;; Don't defer screen updates when performing operations.
(setq redisplay-dont-pause t)
;; When not in a terminal, configure a few window system specific things.
(when window-system
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(tooltip-mode -1)
(mouse-wheel-mode t)
(blink-cursor-mode -1))
;; Show line numbers in buffers.
(global-linum-mode t)
(setq linum-format (if (not window-system) "%4d " "%4d"))
;; Show column numbers in modeline.
(setq column-number-mode t)
;; Show current function in modeline.
(which-function-mode)
;; Ensure linum-mode is disabled in certain major modes.
(setq linum-disabled-modes
'(term-mode slime-repl-mode magit-status-mode help-mode nrepl-mode
mu4e-main-mode mu4e-headers-mode mu4e-view-mode
mu4e-compose-mode))
(defun linum-on ()
(unless (or (minibufferp) (member major-mode linum-disabled-modes))
(linum-mode 1)))
;; Highlight matching braces.
(show-paren-mode 1)
;; Engage Nyan Cat!
(package-require 'nyan-mode)
(nyan-mode 1)
(setq nyan-bar-length 16
nyan-wavy-trail t)
;; Unclutter the modeline
(package-require 'diminish)
(eval-after-load "yasnippet" '(diminish 'yas-minor-mode))
(eval-after-load "ethan-wspace" '(diminish 'ethan-wspace-mode))
(eval-after-load "eldoc" '(diminish 'eldoc-mode))
(eval-after-load "rainbow-mode" '(diminish 'rainbow-mode))
(eval-after-load "paredit" '(diminish 'paredit-mode))
(eval-after-load "autopair" '(diminish 'autopair-mode))
(eval-after-load "abbrev" '(diminish 'abbrev-mode))
(eval-after-load "company" '(diminish 'company-mode))
(eval-after-load "js2-highlight-vars" '(diminish 'js2-highlight-vars-mode))
(eval-after-load "projectile" '(diminish 'projectile-mode))
(eval-after-load "mmm-mode" '(diminish 'mmm-mode))
(eval-after-load "skewer-html" '(diminish 'skewer-html-mode))
(eval-after-load "skewer-mode" '(diminish 'skewer-mode))
(eval-after-load "auto-indent-mode" '(diminish 'auto-indent-minor-mode))
(eval-after-load "highlight-parentheses" '(diminish 'highlight-parentheses-mode))
;; (eval-after-load "subword" '(diminish 'subword-mode))
(eval-after-load "anzu" '(diminish 'anzu-mode))
(eval-after-load "cider" '(diminish 'cider-mode))
(eval-after-load "smartparens" '(diminish 'smartparens-mode))
(eval-after-load "git-gutter" '(diminish 'git-gutter-mode))
(eval-after-load "magit" '(diminish 'magit-auto-revert-mode))
(eval-after-load "js2-mode"
'(defadvice js2-mode (after js2-rename-modeline activate)
(setq mode-name "JS+")))
(eval-after-load "clojure-mode"
'(defadvice clojure-mode (after clj-rename-modeline activate)
(setq mode-name "Clj")))
(eval-after-load "typescript"
'(defadvice typescript-mode (after typescript-rename-modeline activate)
(setq mode-name "TS")))
(eval-after-load "nxhtml-mode"
'(defadvice nxhtml-mode (after nxhtml-rename-modeline activate)
(setq mode-name "HTML")))
(eval-after-load "js"
'(defadvice js-mode (after js-rename-modeline activate)
(setq mode-name "JS")))
(defadvice emacs-lisp-mode (after elisp-rename-modeline activate)
(setq mode-name "ELisp"))
;; Display incremental search stats in modeline.
(package-require 'anzu)
(global-anzu-mode 1)
;; Install the colour scheme according to personal taste.
(defun ohai-appearance/apply-style ()
(interactive)
(cond
((equal ohai-personal-taste/style 'dark)
(ohai-appearance/dark))
((equal ohai-personal-taste/style 'light)
(ohai-appearance/light))))
(ohai-appearance/apply-style)
(provide 'ohai-appearance)
;;; ohai-appearance.el ends here

View File

@@ -0,0 +1,97 @@
;;; -*- lexical-binding: t -*-
;;; ohai-clojure.el --- If you like your parentheses Java flavoured.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(package-require 'clojure-mode)
;; We'll be using Monroe, a simple nREPL client. To use it, you'll need
;; to start an nREPL somewhere (running `lein repl' in your project should
;; do the trick) and run `M-x monroe' to connect to it and open a REPL
;; buffer.
(package-require 'monroe)
;; We'll also be using clj-refactor for refactoring support. The features
;; which require CIDER won't work with Monroe.
(package-require 'clj-refactor)
;; We might need Paredit too if that's how you like it.
(package-require 'paredit)
;; Setup
(add-hook
'clojure-mode-hook
(lambda ()
(when ohai-personal-taste/paredit (paredit-mode))
(clj-refactor-mode 1)
(require 'monroe)
(clojure-enable-monroe)))
(with-eval-after-load "clojure-mode"
;; Rebind C-x C-e to eval through nREPL in clojure-mode buffers.
(define-key clojure-mode-map (kbd "C-x C-e")
'monroe-eval-expression-at-point)
;; Define the keybinding prefix for clj-refactor commands.
;; From there, see https://github.com/clojure-emacs/clj-refactor.el#usage
(cljr-add-keybindings-with-prefix "C-c C-m"))
;; Monroe doesn't offer any completion support. Let's build on it to
;; add a company-mode backend which queries the connected nREPL for
;; completions.
(with-eval-after-load "clojure-mode"
(with-eval-after-load "company"
(defun monroe-eval-string (s callback)
(monroe-send-eval-string
s
(lambda (response)
(monroe-dbind-response
response (id ns value err out ex root-ex status)
(when ns (setq monroe-buffer-ns ns))
(when value (funcall callback nil value))
(when status
(when (member "eval-error" status) (funcall callback ex nil))
(when (member "interrupted" status) (funcall callback status nil))
(when (member "need-input" status) (monroe-handle-input))
(when (member "done" status) (remhash id monroe-requests)))))))
(defun monroe-get-completions (word callback)
(interactive)
(monroe-eval-string
(format "(complete.core/completions \"%s\")" word)
(lambda (err s)
(when (not err) (funcall callback (read-from-whole-string s))))))
(defun company-monroe (command &optional arg &rest ignored)
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-monroe))
(prefix (and (eq major-mode 'clojure-mode)
(get-buffer "*monroe-connection*")
(company-grab-symbol)))
(candidates
(cons :async
(lambda (callback)
(monroe-get-completions arg callback))))))
(add-to-list 'company-backends 'company-monroe)))
(provide 'ohai-clojure)
;;; ohai-clojure.el ends here

View File

@@ -0,0 +1,78 @@
;;; -*- lexical-binding: t -*-
;;; ohai-codestyle.el --- This is where you apply your OCD.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Tab indentation is a disease; a cancer of this planet.
;; Turn it off and let's never talk about this default again.
(set-default 'indent-tabs-mode nil)
;; The fact that we have to do this is also quite embarrassing.
(setq sentence-end-double-space nil)
;; Always indent after a newline.
(define-key global-map (kbd "RET") 'newline-and-indent)
;; Strict whitespace with ethan-wspace: highlight bad habits,
;; and automatically clean up your code when saving.
;; Use C-c c to instantly clean up your file.
;; Read more about ethan-wspace: https://github.com/glasserc/ethan-wspace
(package-require 'ethan-wspace)
(setq mode-require-final-newline nil)
(setq require-final-newline nil)
(global-ethan-wspace-mode 1)
(global-set-key (kbd "C-c c") 'ethan-wspace-clean-all)
;; Set default indentation for various languages (add your own!)
(setq-default tab-width 4)
;; Javascript
(setq-default js2-basic-offset 2)
;; JSON
(setq-default js-indent-level 2)
;; Coffeescript
(setq coffee-tab-width 2)
;; Typescript
(setq typescript-indent-level 2
typescript-expr-indent-offset 2)
;; Python
(setq-default py-indent-offset 2)
;; XML
(setq-default nxml-child-indent 2)
;; C
(setq-default c-basic-offset 2)
;; HTML etc with web-mode
(setq-default web-mode-markup-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2
web-mode-style-padding 2
web-mode-script-padding 2)
;; Set the default formatting styles for various C based modes.
;; Particularly, change the default style from GNU to Java.
;; rms, I love you, but your formatting style makes my eyes bleed.
(setq c-default-style
'((awk-mode . "awk")
(other . "java")))
(provide 'ohai-codestyle)

View File

@@ -0,0 +1,69 @@
;;; -*- lexical-binding: t -*-
;;; ohai-complete.el --- All cool IDEs have IntelliSense.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
(require 'ohai-appearance)
(package-require 'company)
;; Use C-\ to activate the Company autocompleter.
(require 'company)
(global-company-mode)
(global-set-key (kbd "C-\\") 'company-complete)
(setq company-global-modes '(not term-mode))
(setq company-minimum-prefix-length 2
company-selection-wrap-around t
company-show-numbers t
company-tooltip-align-annotations t
company-require-match nil
company-dabbrev-downcase nil
company-dabbrev-ignore-case nil)
;; Sort completion candidates that already occur in the current
;; buffer at the top of the candidate list.
(setq company-transformers '(company-sort-by-occurrence))
;; Show documentation where available for selected completion
;; after a short delay.
(package-require 'company-quickhelp)
(setq company-quickhelp-delay 1)
(company-quickhelp-mode 1)
;; Company's default colours look OK with the light scheme,
;; but hideous with the dark one, so let's pick something nicer.
(add-hook
'ohai-appearance/dark-hook
(lambda ()
(set-face-foreground 'company-tooltip "#000")
(set-face-background 'company-tooltip "#ddd")
(set-face-background 'company-scrollbar-bg "#fff")
(set-face-background 'company-scrollbar-fg "#999")
(set-face-background 'company-tooltip-selection "#aaa")
(set-face-foreground 'company-tooltip-common "#9a0000")
(set-face-foreground 'company-tooltip-common-selection "#9a0000")
(set-face-foreground 'company-tooltip-annotation "#00008e")))
(provide 'ohai-complete)

View File

@@ -0,0 +1,73 @@
;;; -*- lexical-binding: t -*-
;;; ohai-dired.el --- Directory manipulation like an Emacs Master.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;; dired+ is an enhanced version of the built-in Emacs directory editor.
;; Learn about how it extends Dired: http://www.emacswiki.org/emacs/DiredPlus
(setq diredp-hide-details-initially-flag nil)
(package-require 'dired+)
(require 'dired+)
(set-face-foreground 'diredp-file-name nil)
;; Keep dired buffers updated when the file system changes.
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose nil)
;; A function for deleting the file being edited.
;; This one is a bit dangerous, even with the yes/no question, so
;; it's not bound to any key by default.
;; Run it using M-x delete-current-buffer-file.
(defun delete-current-buffer-file ()
"Removes file connected to current buffer and kills buffer."
(interactive)
(let ((filename (buffer-file-name))
(buffer (current-buffer))
(name (buffer-name)))
(if (not (and filename (file-exists-p filename)))
(ido-kill-buffer)
(when (yes-or-no-p "Are you sure you want to remove this file? ")
(delete-file filename)
(kill-buffer buffer)
(message "File '%s' successfully removed" filename)))))
;; And a function for renaming the file being edited, bound to C-x C-r.
(defun rename-current-buffer-file ()
"Renames current buffer and file it is visiting."
(interactive)
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name (read-file-name "New name: " filename)))
(if (get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name)
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(message "File '%s' successfully renamed to '%s'"
name (file-name-nondirectory new-name)))))))
(global-set-key (kbd "C-x C-r") 'rename-current-buffer-file)
(provide 'ohai-dired)
;;; ohai-dired.el ends here

View File

@@ -0,0 +1,137 @@
;;; -*- lexical-binding: t -*-
;;; ohai-editing.el --- Configure your editing style.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;; Multiple cursors!
;; Use <insert> to place a cursor on the next match for the current selection.
;; Use S-<insert> to place one on the previous match.
;; Use C-' to use extended mark mode, giving you more control.
;; Use C-" to place cursors on all matches.
;; Select a region and C-M-' to place cursors on each line of the selection.
;; Bonus: <insert> key no longer activates overwrite mode.
;; What is that thing for anyway?
(package-require 'multiple-cursors)
(global-set-key (kbd "<insert>") 'mc/mark-next-like-this)
(global-set-key (kbd "S-<insert>") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-'") 'mc/mark-more-like-this-extended)
(global-set-key (kbd "C-\"") 'mc/mark-all-like-this-dwim)
(global-set-key (kbd "C-M-'") 'mc/edit-lines)
;; Use C-= to select the innermost logical unit your cursor is on.
;; Keep hitting C-= to expand it to the next logical unit.
;; Protip: this goes really well with multiple cursors.
(package-require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)
;; Remap join-line to M-j where it's easier to get to.
;; join-line will join the line you're on with the line above it
;; in a reasonable manner for the type of file you're editing.
(global-set-key (kbd "M-j") 'join-line)
;; Hit C-c <tab> to auto-indent the entire buffer you're in.
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(global-set-key (kbd "C-c <tab>") 'indent-buffer)
;; Automatically insert matching braces and do other clever
;; things pertaining to braces and such.
(electric-pair-mode 1)
;; Duplicate start of line or region with C-M-<end>.
;; From http://www.emacswiki.org/emacs/DuplicateStartOfLineOrRegion
(defun duplicate-start-of-line-or-region ()
(interactive)
(if mark-active
(duplicate-region)
(duplicate-start-of-line)))
(defun duplicate-start-of-line ()
(if (bolp)
(progn
(end-of-line)
(duplicate-start-of-line)
(beginning-of-line))
(let ((text (buffer-substring (point)
(beginning-of-thing 'line))))
(forward-line)
(push-mark)
(insert text)
(open-line 1))))
(defun duplicate-region ()
(let* ((end (region-end))
(text (buffer-substring (region-beginning) end)))
(goto-char end)
(insert text)
(push-mark end)
(setq deactivate-mark nil)
(exchange-point-and-mark)))
(global-set-key (kbd "C-M-<end>") 'duplicate-start-of-line-or-region)
;; Hack for setting a fixed wrap column in visual-line-mode.
(defun set-visual-wrap-column (new-wrap-column &optional buffer)
"Force visual line wrap at NEW-WRAP-COLUMN in BUFFER (defaults
to current buffer) by setting the right-hand margin on every
window that displays BUFFER. A value of NIL or 0 for
NEW-WRAP-COLUMN disables this behavior."
(interactive (list (read-number "New visual wrap column, 0 to disable: " (or visual-wrap-column fill-column 0))))
(if (and (numberp new-wrap-column)
(zerop new-wrap-column))
(setq new-wrap-column nil))
(with-current-buffer (or buffer (current-buffer))
(visual-line-mode t)
(set (make-local-variable 'visual-wrap-column) new-wrap-column)
(add-hook 'window-configuration-change-hook 'update-visual-wrap-column nil t)
(let ((windows (get-buffer-window-list)))
(while windows
(when (window-live-p (car windows))
(with-selected-window (car windows)
(update-visual-wrap-column)))
(setq windows (cdr windows))))))
(defun update-visual-wrap-column ()
(if (not visual-wrap-column)
(set-window-margins nil nil)
(let* ((current-margins (window-margins))
(right-margin (or (cdr current-margins) 0))
(current-width (window-width))
(current-available (+ current-width right-margin)))
(if (<= current-available visual-wrap-column)
(set-window-margins nil (car current-margins))
(set-window-margins nil (car current-margins)
(- current-available visual-wrap-column))))))
;; A function for easily editing a file as root through TRAMP.
(defun sudo-edit (&optional arg)
(interactive "p")
(if (or arg (not buffer-file-name))
(find-file (concat "/sudo:root@localhost:"
(if (fboundp 'helm-read-file-name)
(helm-read-file-name "File: ")
(ido-read-file-name "File: "))))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
;; A key for intelligently shrinking whitespace.
;; See https://github.com/jcpetkovich/shrink-whitespace.el for details.
(package-require 'shrink-whitespace)
(global-set-key (kbd "C-c DEL") 'shrink-whitespace)
(provide 'ohai-editing)

View File

@@ -0,0 +1,59 @@
;;; -*- lexical-binding: t -*-
;;; ohai-elisp.el --- Making your lisp sound more pleasant.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
(require 'ohai-personal-taste)
;; If you're ready for Paredit, let's do Paredit!
;; Learn Paredit: http://pub.gajendra.net/src/paredit-refcard.pdf
(when ohai-personal-taste/paredit
(package-require 'paredit)
(add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode))
;; Setup C-c v to eval whole buffer in all lisps.
(define-key lisp-mode-shared-map (kbd "C-c v") 'eval-buffer)
;; Highlight the sexp under the cursor.
(package-require 'highlight-parentheses)
(add-hook 'emacs-lisp-mode-hook 'highlight-parentheses-mode)
;; When saving an elisp file, remove its compiled version if
;; there is one, as you'll want to recompile it.
(defun remove-elc-on-save ()
"If you're saving an elisp file, likely the .elc is no longer valid."
(make-local-variable 'after-save-hook)
(add-hook 'after-save-hook
(lambda ()
(if (file-exists-p (concat buffer-file-name "c"))
(delete-file (concat buffer-file-name "c"))))))
(add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
;; Enable eldoc mode, which provides context based documentation
;; in the minibuffer.
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
;; Use M-. to jump to the definition of the symbol under the cursor.
(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
(provide 'ohai-elisp)

View File

@@ -0,0 +1,66 @@
;;; -*- lexical-binding: t -*-
;;; ohai-elixir.el --- Elixir language support.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Set up the basic Elixir mode.
(package-require 'elixir-mode)
;; Alchemist offers integration with the Mix tool.
(package-require 'alchemist)
(with-eval-after-load "elixir-mode"
(add-hook 'elixir-mode-hook 'alchemist-mode))
;; Bind some Alchemist commands to more commonly used keys.
(with-eval-after-load "alchemist"
(define-key alchemist-mode-map
(kbd "C-c C-l")
(lambda () (interactive)
(save-buffer)
(alchemist-iex-compile-this-buffer)))
(define-key alchemist-mode-map
(kbd "C-x C-e") 'alchemist-iex-send-current-line))
;; A Flycheck checker that uses Mix, so it finds project deps.
;; From https://github.com/ananthakumaran/dotfiles/blob/master/.emacs.d/init-elixir.el#L25-L42
(with-eval-after-load "flycheck"
(flycheck-define-checker elixir-mix
"An Elixir syntax checker using the Elixir interpreter.
See URL `http://elixir-lang.org/'."
:command ("mix"
"compile"
source)
:error-patterns
((error line-start "** (" (zero-or-more not-newline) ") "
(zero-or-more not-newline) ":" line ": " (message) line-end)
(warning line-start
(one-or-more (not (syntax whitespace))) ":"
line ": "
(message)
line-end))
:modes elixir-mode)
(add-to-list 'flycheck-checkers 'elixir-mix))
(provide 'ohai-elixir)
;;; ohai-elixir.el ends here

View File

@@ -0,0 +1,82 @@
;;; -*- lexical-binding: t -*-
;;; ohai-erlang.el --- Things for working with erlang.
;; Copyright (C) 2015 Bodil Stokke
;; Curated and improved by Bernard Notarianni
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Let's use the regular erlang-mode
(package-require 'erlang)
(defun stripwhite (str)
"Remove any whitespace from STR."
(let ((s (if (symbolp str) (symbol-name str) str)))
(replace-regexp-in-string "[ \t\n]*" "" s)))
(defun erlang-move-to-export-insertion ()
(interactive)
(goto-char (point-max))
(if (search-backward-regexp "^-export" 0 t)
(end-of-line)
(search-backward-regexp "^-" 0 t)
(end-of-line)))
(defun erlang-export (fun-arity)
(interactive
(list (read-no-blanks-input "function/arity: " (erlang-current-function))))
(save-excursion
(erlang-move-to-export-insertion)
(newline)
(insert (format "-export ([%s])." fun-arity))))
;; Find the name of the function under the cursor.
(defun erlang-current-function ()
(save-excursion
(if (not (equal (point) (point-max))) (forward-char))
(erlang-beginning-of-function)
(let ((beg (point))
(fun-name)
(fun-arity)
(result '()))
(search-forward "(")
(backward-char)
(setq fun-name (stripwhite (buffer-substring beg (point))))
(if (char-equal (char-after) ?\))
(setq fun-arity 0)
(forward-char)
(setq fun-arity 0)
(while (not (char-equal (char-after) ?\)))
(erlang-forward-arg)
(setq fun-arity (+ fun-arity 1))))
(format "%s/%d" fun-name fun-arity))))
(defun erlang-forward-arg ()
(forward-sexp))
;; Setup C-c e to add an export clause for the function under cursor.
(add-hook 'erlang-mode-hook (lambda () (local-set-key "\C-ce" 'erlang-export)))
;; Avoid Warning about final newline with Erlang mode
(add-hook 'erlang-mode-hook
(lambda ()
(setq require-final-newline nil)
(setq mode-require-final-newline nil)))
(provide 'ohai-erlang)

View File

@@ -0,0 +1,81 @@
;;; -*- lexical-binding: t -*-
;;; ohai-flycheck.el --- Spot all the errors.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Install Flycheck.
(package-require 'flycheck)
;; Start it automatically for all modes except ELisp mode,
;; where the linter is just designed to make you mad.
(add-hook 'find-file-hook
(lambda ()
(when (not (equal 'emacs-lisp-mode major-mode))
(flycheck-mode))))
;; Jump between current errors with M-n and M-p.
(global-set-key (kbd "M-n") 'next-error)
(global-set-key (kbd "M-p") 'previous-error)
;; Turn the modeline red when Flycheck has errors.
(package-require 'flycheck-color-mode-line)
;; Configure the theme.
(with-eval-after-load "flycheck"
(setq flycheck-highlighting-mode 'symbols)
(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
(add-hook
'ohai-appearance/dark-hook
(lambda ()
(with-eval-after-load "flycheck"
(set-face-background 'flycheck-error "#660000")
(set-face-foreground 'flycheck-error nil)
(set-face-background 'flycheck-warning "#331800")
(set-face-foreground 'flycheck-warning nil)
(require 'flycheck-color-mode-line)
(set-face-background 'flycheck-color-mode-line-error-face "#440000")
(set-face-background 'flycheck-color-mode-line-warning-face "#553300")
(set-face-background 'flycheck-color-mode-line-info-face nil)
(set-face-foreground 'flycheck-color-mode-line-error-face "#ffffff")
(set-face-foreground 'flycheck-color-mode-line-warning-face "#ffffff")
(set-face-foreground 'flycheck-color-mode-line-info-face nil))))
(add-hook
'ohai-appearance/light-hook
(lambda ()
(with-eval-after-load "flycheck"
(set-face-background 'flycheck-error "#ff8888")
(set-face-foreground 'flycheck-error nil)
(set-face-background 'flycheck-warning "#ffcc88")
(set-face-foreground 'flycheck-warning nil)
(require 'flycheck-color-mode-line)
(set-face-background 'flycheck-color-mode-line-error-face "#ff0000")
(set-face-foreground 'flycheck-color-mode-line-error-face "#ffffff")
(set-face-background 'flycheck-color-mode-line-warning-face "#886600")
(set-face-foreground 'flycheck-color-mode-line-warning-face "#ffffff")
(set-face-background 'flycheck-color-mode-line-info-face nil)
(set-face-foreground 'flycheck-color-mode-line-info-face nil))))
(provide 'ohai-flycheck)

View File

@@ -0,0 +1,47 @@
;;; -*- lexical-binding: t -*-
;;; ohai-fonts.el --- On-the-fly font size adjustment.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-lib)
(defun ohai-fonts/spec-to-list (spec)
(s-split "-" spec))
(defun ohai-fonts/list-to-spec (spec)
(s-join "-" spec))
(defun ohai-fonts/update-font-spec-size (spec increment)
(ohai-fonts/list-to-spec
(-update-at 7 (lambda (i) (number-to-string
(+ (string-to-number i) increment)))
(ohai-fonts/spec-to-list spec))))
(defun ohai-fonts/update-font-size (increment)
(set-frame-font
(ohai-fonts/update-font-spec-size (frame-parameter nil 'font) increment)))
(global-set-key (kbd "C-M--") (lambda () (interactive)
(ohai-fonts/update-font-size -1)))
(global-set-key (kbd "C-M-=") (lambda () (interactive)
(ohai-fonts/update-font-size 1)))
(provide 'ohai-fonts)
;;; ohai-fonts.el ends here

View File

@@ -0,0 +1,55 @@
;;; -*- lexical-binding: t -*-
;;; ohai-general.el --- Setting up the basics.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;; Make sure we always use UTF-8.
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(load-library "iso-transl")
;; Always ask for y/n keypress instead of typing out 'yes' or 'no'
(defalias 'yes-or-no-p 'y-or-n-p)
;; Emacs writes backup files to `filename~` by default. This is messy,
;; so let's tell it to write them to `~/.emacs.d/bak` instead.
;; If you have an accident, check this directory - you might get lucky.
(setq backup-directory-alist
`(("." . ,(expand-file-name (concat dotfiles-dir "bak")))))
;; Automatically save buffers before launching M-x compile and friends,
;; instead of asking you if you want to save.
(setq compilation-ask-about-save nil)
;; Make the selection work like most people expect.
(delete-selection-mode t)
(transient-mark-mode t)
;; Automatically update unmodified buffers whose files have changed.
(global-auto-revert-mode 1)
;; If available, use `xdg-open' to open URLs.
(when (ohai/is-exec "xdg-open")
(setq-default
browse-url-browser-function (quote browse-url-generic)
browse-url-generic-program "xdg-open"))
(provide 'ohai-general)

View File

@@ -0,0 +1,41 @@
;;; -*- lexical-binding: t -*-
;;; ohai-git.el --- Things for working with Git.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Invoke Magit by typing C-x g, and you can thank me later.
;; See http://magit.github.io/ for instructions.
(package-require 'magit)
(global-set-key (kbd "C-x g") 'magit-status)
;; Use M-x gist-buffer or M-x gist-region to create a gist
;; directly from the current buffer or selection.
(package-require 'gist)
;; Mark uncommitted changes in the fringe.
(package-require 'git-gutter-fringe)
(require 'git-gutter-fringe)
(global-git-gutter-mode t)
(provide 'ohai-git)

View File

@@ -0,0 +1,80 @@
;;; -*- lexical-binding: t -*-
;;; ohai-haskell.el --- FIRE ALL MONAD TRANSFORMERS
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(package-require 'haskell-mode)
;; Setup haskell-mode hooks
(with-eval-after-load "haskell-mode"
(custom-set-variables
'(haskell-mode-hook
'(turn-on-haskell-indentation
turn-on-haskell-doc))))
;; Setup haskell-interactive-mode keybindings. Get started by using C-c C-z from
;; a buffer visiting a file in your Haskell project.
(with-eval-after-load "haskell-mode"
;; Switch to the current REPL buffer, starting a session if needed.
(define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch)
;; Switch between REPL sessions.
(define-key haskell-mode-map (kbd "C-c b") 'haskell-session-change)
;; Load the current buffer into the REPL.
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-file)
;; Infer the type of the thing at point.
(define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
;; Display info (in the REPL) about the thing at point.
(define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
;; Insert the inferred type of the function at point into the code.
(define-key haskell-mode-map (kbd "C-c C-s") (lambda () (interactive) (haskell-process-do-type t)))
;; Run `cabal test' in a compile buffer.
(define-key haskell-mode-map (kbd "C-c C-,") 'ohai-haskell/run-test-suite))
;; Change some ASCII art syntax into their corresponding Unicode characters.
;; Rebind the same Unicode characters to insert their ASCII art versions
;; if entered from the keyboard.
;; This is very much a matter of taste, feel free to disable it. Or better yet,
;; if you're into that sort of thing, see https://wiki.haskell.org/Unicode-symbols
;; for native Unicode support.
(with-eval-after-load "haskell-mode"
(ohai/font-lock-replace-symbol 'haskell-mode "\\(->\\)" "")
(ohai/font-lock-replace-symbol 'haskell-mode "\\(<-\\)" "")
(ohai/font-lock-replace-symbol 'haskell-mode "\\(=>\\)" "")
(define-key haskell-mode-map (kbd "") (lambda () (interactive) (insert "->")))
(define-key haskell-mode-map (kbd "") (lambda () (interactive) (insert "<-")))
(define-key haskell-mode-map (kbd "") (lambda () (interactive) (insert "=>"))))
;; A function for launching a compile buffer with `cabal test'.
(defun ohai-haskell/run-test-suite ()
(interactive)
(require 'compile)
(projectile-with-default-dir (projectile-project-root)
(compile "cabal test")))
;; Flycheck addons
(package-require 'flycheck-haskell)
(with-eval-after-load "flycheck"
(with-eval-after-load "haskell"
(add-hook 'flycheck-mode-hook #'flycheck-haskell-setup)))
(provide 'ohai-haskell)
;;; ohai-haskell.el ends here

View File

@@ -0,0 +1,54 @@
;;; -*- lexical-binding: t -*-
;;; ohai-helm.el --- The Grand Emacs Incremental Narrowing Thingy.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(package-require 'helm)
(require 'helm-config)
(require 'helm)
(helm-mode 1)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x C-g") 'helm-do-grep)
(global-set-key (kbd "C-x b") 'helm-buffers-list)
(global-set-key (kbd "C-x c g") 'helm-google-suggest)
(with-eval-after-load "ohai-project"
(package-require 'helm-projectile)
(global-set-key (kbd "C-c C-f") 'helm-projectile-find-file-dwim))
(helm-autoresize-mode 1)
(setq-default helm-display-header-line nil
helm-autoresize-min-height 10
helm-autoresize-max-height 35
helm-split-window-in-side-p t
helm-M-x-fuzzy-match t
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-apropos-fuzzy-match t)
(set-face-attribute 'helm-source-header nil :height 0.75)
(provide 'ohai-helm)
;;; ohai-helm.el ends here

View File

@@ -0,0 +1,40 @@
;;; -*- lexical-binding: t -*-
;;; ohai-help.el --- It's dangerous to go alone! Take this.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
(package-require 'guide-key)
(setq-default guide-key/guide-key-sequence t
guide-key/recursive-key-sequence-flag t
guide-key/idle-delay 2
guide-key/popup-window-position 'bottom
guide-key/text-scale-amount -2)
(guide-key-mode 1)
;; Get an instant cheat sheet for your current major mode
;; with C-h C-m.
(package-require 'discover-my-major)
(global-set-key (kbd "C-h C-m") 'discover-my-major)
(provide 'ohai-help)

View File

@@ -0,0 +1,58 @@
;;; -*- lexical-binding: t -*-
;;; ohai-html.el --- Dealing with the W3C.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
(require 'ohai-editing)
;; web-mode is a special mode for HTML which copes with embedded JS/CSS,
;; JSX, various templating systems, etc.
;; Learn about web-mode: http://web-mode.org/
(package-require 'web-mode)
;; We'd like to use web-mode for HTML, instead of the default html-mode.
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
;; Let's add some extensions from the web-mode docs too.
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
;; Highlight the element under the cursor.
(setq-default web-mode-enable-current-element-highlight t)
;; Key for renaming tags
(with-eval-after-load "web-mode"
(define-key web-mode-map (kbd "C-c C-r") 'mc/mark-sgml-tag-pair))
;; Colourise colour names in certain modes.
(package-require 'rainbow-mode)
(dolist (mode '(css-mode less-css-mode html-mode web-mode))
(add-hook (intern (concat (symbol-name mode) "-hook"))
(lambda () (rainbow-mode))))
(provide 'ohai-html)

View File

@@ -0,0 +1,118 @@
;;; -*- lexical-binding: t -*-
;;; ohai-ido.el --- Make minibuffer selection tolerable.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;; Enable ido-mode.
(ido-mode t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
ido-use-url-at-point t
ido-max-prospects 10
ido-use-virtual-buffers t)
;; Make sure ido is really everywhere.
(package-require 'ido-ubiquitous)
(ido-ubiquitous-mode)
;; Use smex to provide ido-like interface for M-x
(package-require 'smex)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; This is the old M-x.
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
;; Vertical ido.
(package-require 'ido-vertical-mode)
(ido-vertical-mode)
;; Improved fuzzy matching.
(package-require 'flx-ido)
(flx-ido-mode 1)
(setq ido-enable-flex-matching t
ido-use-faces nil
gc-cons-threshold 20000000)
;; Bind C-t to use ido to jump to a symbol in the current buffer.
(require 'imenu)
(defun ido-imenu ()
"Update the imenu index and then use ido to select a symbol to navigate to.
Symbols matching the text at point are put first in the completion list."
(interactive)
(imenu--make-index-alist)
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
(let ((name nil) (position nil))
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(addsymbols symbol))
((listp symbol)
(setq name (car symbol))
(setq position (cdr symbol)))
((stringp symbol)
(setq name symbol)
(setq position (get-text-property 1 'org-imenu-marker symbol))))
(unless (or (null position) (null name))
(add-to-list 'symbol-names name)
(add-to-list 'name-and-pos (cons name position))))))))
(addsymbols imenu--index-alist))
;; If there are matching symbols at point, put them at the beginning of `symbol-names'.
(let ((symbol-at-point (thing-at-point 'symbol)))
(when symbol-at-point
(let* ((regexp (concat (regexp-quote symbol-at-point) "$"))
(matching-symbols (delq nil (mapcar (lambda (symbol)
(if (string-match regexp symbol) symbol))
symbol-names))))
(when matching-symbols
(sort matching-symbols (lambda (a b) (> (length a) (length b))))
(mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names))))
matching-symbols)))))
(let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
(position (cdr (assoc selected-symbol name-and-pos))))
(goto-char position))))
(set-default 'imenu-auto-rescan t)
(global-set-key (kbd "C-t") 'ido-imenu)
;; Bind `~` to go to homedir when in ido-find-file.
;; From http://whattheemacsd.com/setup-ido.el-02.html
(add-hook 'ido-setup-hook
(lambda ()
;; Go straight home
(define-key ido-file-completion-map
(kbd "~")
(lambda ()
(interactive)
(if (looking-back "/")
(insert "~/")
(call-interactively 'self-insert-command))))))
(provide 'ohai-ido)

View File

@@ -0,0 +1,77 @@
;;; -*- lexical-binding: t -*-
;;; ohai-javascript.el --- Everybody's favourite personal hell.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
(require 'ohai-lib)
;; If npm is installed, add its local prefix to the executable
;; search path, which helps Emacs find linters etc.
;; This isn't Windows compatible, but then neither is npm, really.
(-when-let (npm-prefix (ohai/exec-if-exec "npm" "config get prefix"))
(setenv "PATH" (concat npm-prefix "/bin:" (getenv "PATH"))))
;; Install js2-mode, which improves on Emacs's default JS mode
;; tremendously.
(package-require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.es6\\'" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.ejs\\'" . js2-mode))
;; But for JSON files, it's better to stick with plain old js-mode.
(add-to-list 'auto-mode-alist '("\\.json$" . js-mode))
;; Configure js2-mode good.
(setq-default
js2-mode-indent-ignore-first-tab t
js2-strict-inconsistent-return-warning nil
js2-global-externs
'("module" "require" "__dirname" "process" "console" "JSON" "$" "_"))
;; js2-show-parse-errors nil
;; js2-strict-var-hides-function-arg-warning nil
;; js2-strict-missing-semi-warning nil
;; js2-strict-trailing-comma-warning nil
;; js2-strict-cond-assign-warning nil
;; js2-strict-var-redeclaration-warning nil
;; Use Tern for smarter JS.
(package-require 'tern)
(add-hook 'js2-mode-hook (lambda () (tern-mode t)))
;; Locate the Tern binary by querying the system search path, which
;; should now include the local npm prefix.
(setq tern-command (list (or (ohai/resolve-exec "tern") "tern")))
;; Setup Tern as an autocomplete source.
(with-eval-after-load "company"
(package-require 'company-tern)
(require 'company-tern)
(add-to-list 'company-backends 'company-tern))
;; Leverage js2-mode to get some refactoring support through js2-refactor.
(package-require 'js2-refactor)
(add-hook 'js2-mode-hook
(lambda ()
(js2r-add-keybindings-with-prefix "C-c C-m")))
(provide 'ohai-javascript)

View File

@@ -0,0 +1,32 @@
;;; -*- lexical-binding: t -*-
;;; ohai-markdown.el --- That text format that's everywhere org-mode should be.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Install Markdown support.
(package-require 'markdown-mode)
(add-to-list 'auto-mode-alist '("\\.markdown$" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
(provide 'ohai-markdown)

View File

@@ -0,0 +1,71 @@
;;; -*- lexical-binding: t -*-
;;; ohai-navigation.el --- Moving around.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;; Make PgUp/Dn move the point.
(setq scroll-error-top-bottom t)
;; Avy is a quick way to jump around your buffers.
;; https://github.com/abo-abo/avy
(package-require 'avy)
(global-set-key (kbd "C-;") 'avy-goto-word-1)
(global-set-key (kbd "C-:") 'avy-goto-char)
(with-eval-after-load "isearch"
(define-key isearch-mode-map (kbd "C-;") 'avy-isearch))
;; Smart home key.
(defun smart-beginning-of-line ()
"Move point to first non-whitespace character or beginning-of-line."
(interactive "^")
(let ((oldpos (point)))
(back-to-indentation)
(and (= oldpos (point))
(beginning-of-line))))
(global-set-key (kbd "<home>") 'smart-beginning-of-line)
(global-set-key (kbd "C-a") 'smart-beginning-of-line)
;; Consider CamelCase chunks as words when navigating.
(global-subword-mode 1)
;; Swap buffers in open windows with C-x C-o.
(package-require 'swap-buffers)
(global-set-key (kbd "C-x C-o") 'swap-buffers)
;; Enhance C-x o when more than two windows are open.
(package-require 'ace-window)
(global-set-key (kbd "C-x o") 'ace-window)
;; Use C-x M-p to kill the buffer in the other window, revealing
;; the next buffer in the stack.
(global-set-key
(kbd "C-x M-p")
(lambda () (interactive)
(save-excursion
(other-window 1)
(quit-window))))
;; Display incremental search stats in the modeline.
(package-require 'anzu)
(global-anzu-mode 1)
(provide 'ohai-navigation)

View File

@@ -0,0 +1,46 @@
;;; -*- lexical-binding: t -*-
;;; ohai-orgmode.el --- Your personal everything manager.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Stop org-mode from highjacking shift-cursor keys.
(setq org-replace-disputed-keys t)
;; Always use visual-line-mode in org-mode, and wrap it at column 80.
(add-hook
'org-mode-hook
(lambda ()
(visual-line-mode 1)
(set-visual-wrap-column 80)))
;; Fancy bullet rendering.
(package-require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
;; Insert links from clipboard.
(package-require 'org-cliplink)
(with-eval-after-load "org"
(define-key org-mode-map (kbd "C-c M-l") 'org-cliplink))
(provide 'ohai-orgmode)

View File

@@ -0,0 +1,35 @@
;;; -*- lexical-binding: t -*-
;;; ohai-project.el --- Your personal everything manager.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Install Projectile and activate it for all things.
;; Learn about Projectile: http://batsov.com/projectile/
(package-require 'projectile)
(projectile-global-mode)
;; Use C-c C-f to find a file anywhere in the current project.
(global-set-key (kbd "C-c C-f") 'projectile-find-file)
(provide 'ohai-project)

View File

@@ -0,0 +1,76 @@
;;; -*- lexical-binding: t -*-
;;; ohai-purescript.el --- Settings for editing PureScript.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-lib)
(require 'ohai-project)
(require 'ohai-javascript)
;; Install purescript-mode.
(package-require 'purescript-mode)
(require 'purescript-mode)
(add-to-list 'auto-mode-alist '("\\.purs$" . purescript-mode))
(add-hook 'purescript-mode-hook 'turn-on-purescript-indentation)
;; Change some ASCII art syntax into their corresponding Unicode characters.
;; Rebind the same Unicode characters to insert their ASCII art versions
;; if entered from the keyboard.
(with-eval-after-load "purescript-mode"
(ohai/font-lock-replace-symbol 'purescript-mode "\\(->\\)" "")
(ohai/font-lock-replace-symbol 'purescript-mode "\\(<-\\)" "")
(ohai/font-lock-replace-symbol 'purescript-mode "\\(=>\\)" "")
(define-key purescript-mode-map (kbd "") (lambda () (interactive) (insert "->")))
(define-key purescript-mode-map (kbd "") (lambda () (interactive) (insert "<-")))
(define-key purescript-mode-map (kbd "") (lambda () (interactive) (insert "=>"))))
;; Define a Flycheck checker for running the PureScript compiler through Pulp.
(with-eval-after-load "flycheck"
(flycheck-define-checker
pulp
"Use Pulp to flycheck PureScript code."
:command ("pulp" "--monochrome" "build")
:error-patterns
((error line-start
(or (and "Error at " (file-name) " line " line ", column " column ":"
(zero-or-more " "))
(and "\"" (file-name) "\" (line " line ", column " column "):"))
(message (one-or-more (not (in "*"))))
line-end))
:modes purescript-mode)
(add-to-list 'flycheck-checkers 'pulp))
;; A function for generating a likely module name from the current file path.
;; We use this in the `ps.module' snippet.
(defun purescript-module-name-from-current-buffer-file ()
(let ((path (f-split (f-relative
(f-base (buffer-file-name))
(f-join (projectile-project-root) "src"))))
(testpath (f-split (f-relative
(f-base (buffer-file-name))
(f-join (projectile-project-root) "test")))))
(if (string= ".." (car path))
(if (string= ".." (car testpath)) "Main" (s-join "." (cons "Test" testpath)))
(s-join "." path))))
(provide 'ohai-purescript)
;;; ohai-purescript.el ends here

View File

@@ -0,0 +1,38 @@
;;; -*- lexical-binding: t -*-
;;; ohai-snippets.el --- Where there is boilerplate, there must be snippets.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; The s.el package contains a lot of functions useful in snippets.
(package-require 's)
(require 's)
;; Install yasnippet and make it available globally.
;; Read about it here: http://capitaomorte.github.io/yasnippet/
(package-require 'yasnippet)
(require 'yasnippet)
(yas-global-mode 1)
(provide 'ohai-snippets)
;;; ohai-snippets.el ends here

View File

@@ -0,0 +1,152 @@
;;; -*- lexical-binding: t -*-
;;; ohai-splash.el --- Customise the scratch buffer.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
(require 'ohai-personal-taste)
(setq ohai-splash/sources
(cond
((equal ohai-personal-taste/splash 'emergency-puppy)
'(ohai-splash/emergency-puppy))
((equal ohai-personal-taste/splash 'daily-otter)
'(ohai-splash/daily-otter))))
(package-require 'dash)
(package-require 's)
(package-require 'web)
(require 'dash)
(require 's)
(require 'web)
(defun ohai-splash/load-and-map (url map-fn cb)
(web-http-get
(lambda (con header data)
(funcall cb (funcall map-fn data header)))
:url url))
(defun ohai-splash/load-and-match (url regex format-str cb)
(ohai-splash/load-and-map
url
(lambda (data header)
(-when-let (m (s-match regex data))
(s-format format-str 'elt m)))
cb))
(defun ohai-splash/pick-first (fetchers cb)
(-if-let (fetcher (car fetchers))
(if (stringp fetcher) (funcall cb fetcher)
(funcall fetcher
(lambda (url)
(if url (funcall cb url)
(ohai-splash/pick-first (cdr fetchers) cb)))))
(funcall cb nil)))
(defun ohai-splash/load-image (url cb)
(web-http-get
(lambda (con header data)
(funcall cb (create-image (string-to-unibyte data) nil t)))
:url url))
(defun ohai-splash/dilbert (cb)
(ohai-splash/load-and-match "http://dilbert.com/"
"/dyn/str_strip/[0-9/]+\.strip\\(\.sunday\\)?\.gif"
"http://dilbert.com$0" cb))
(defun ohai-splash/imgur (search-term)
(lambda (cb)
(ohai-splash/load-and-match
(s-concat "http://imgur.com/search/score/day?q_size_px=med&q_size_mpx=med&q="
(url-hexify-string search-term))
"<div id=\"\\([0-9a-zA-Z]+\\)\" class=\"post\""
"http://i.imgur.com/$1.jpg" cb)))
(defun ohai-splash/placepuppy (cb)
(cb "http://placepuppy.it/600/400"))
(defun ohai-splash/emergency-puppy (cb)
(ohai-splash/load-and-match
"https://twitter.com/EmergencyPuppy/media"
"<img class=\"TwitterPhoto-mediaSource\"\n* *src=\"\\([^\"]*\\):large\""
"$1" cb))
(defun ohai-splash/daily-otter (cb)
(ohai-splash/load-and-match
"http://dailyotter.org/"
"<img class=\"aligncenter wp-image-.*src=\"\\([^\"]*\\)\""
"$1" cb))
(defun ohai-splash/run (sources cb)
(ohai-splash/pick-first
(or sources ohai-splash/sources)
(lambda (url)
(ohai-splash/load-image url cb))))
(defun ohai-splash/inject-help-text ()
(with-current-buffer (get-buffer "*scratch*")
(end-of-buffer)
(delete-region 1 (point))
(insert ";; Blessed art thou, who hath come to the One True Editor.
;; If you are currently experiencing panic and need to get out, you can exit
;; by typing C-x C-c. That is, press Control+X, then Control+C.
;; If you are new to GNU Emacs, you should start the interactive tutorial by
;; typing C-h t. That is, Control+H, then the letter T.
;; This is your scratch buffer. You can enter temporary notes here, or you
;; can write Emacs Lisp commands and evaluate them (C-x C-e) from this buffer.
;; To get straight to work, press C-x C-f to open or create a file.
")))
(defun ohai-splash/inject-spinner ()
(with-current-buffer (get-buffer "*scratch*")
(insert "Downloading internets... ")))
(defun ohai-splash/inject-picture (img)
(with-current-buffer (get-buffer "*scratch*")
(end-of-buffer)
(move-beginning-of-line nil)
(kill-line)
(insert-image img "ohai")
(move-beginning-of-line nil)
(mark-word)
(delete-other-windows)))
(defun ohai-splash/go ()
(ohai-splash/inject-help-text)
(when (and (online?) ohai-splash/sources)
(ohai-splash/inject-spinner)
(ohai-splash/run nil (lambda (img) (ohai-splash/inject-picture img))))
t)
(when window-system
(setq initial-buffer-choice 'ohai-splash/go))
;; A hack here to force the splash screen after the first run wizard's
;; module selection, as `initial-buffer-choice' will already have run.
(when (boundp 'ohai/wizard-did-run)
(ohai-splash/go))
(provide 'ohai-splash)

View File

@@ -0,0 +1,28 @@
;;; -*- lexical-binding: t -*-
;;; ohai-swiper.el --- Improved incremental search.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(package-require 'swiper)
(global-set-key (kbd "C-s") 'swiper)
(provide 'ohai-swiper)
;;; ohai-swiper.el ends here