Merge pull request #5 from jimeh/rewrite

Complete rewrite of config using a Emacs Prelude like structure
This commit is contained in:
2015-10-04 09:54:05 +01:00
120 changed files with 3995 additions and 13715 deletions

1
.gitignore vendored
View File

@@ -17,6 +17,7 @@ project-explorer-cache/*
recentf
saved-places
smex-items
savefile/*
# Bittorrent Sync related
.AppleDouble

6
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "el-get/el-get"]
path = el-get/el-get
url = https://github.com/dimitri/el-get.git
[submodule "vendor/tomorrow-night-paradise-theme"]
path = vendor/tomorrow-night-paradise-theme
url = https://github.com/jimeh/tomorrow-night-paradise-theme.el.git

View File

@@ -1,85 +1,41 @@
# My .emacs.d Config Folder
# jimeh's .emacs.d (a.k.a. Emacs Siren)
This is my personal Emacs configuration. Having been primarily a TextMate user
previously, my setup might also work nicely for other TM users who are curious
about Emacs.
That said, this is not some form of an Emacs starter kit, it's simply my
personal config with any quirks, oddities, bugs, and man-eating errors I live
with on a daily basis.
This is my personal Emacs config, currently nicknamed Emacs Siren, and heavily
inspired by [Emacs Prelude](https://github.com/bbatsov/prelude).
However, this is not some form of an Emacs starter kit, it's simply my personal
config with any quirks, oddities, bugs, and man-eating errors I live with on a
daily basis.
## Requirements
My config uses Emacs 24's new package system, and also the awesome [el-get][]
package manager. The latest stable version of Emacs is currently 23, so you'll
need to get ahold of a nightly build.
[el-get]: https://github.com/dimitri/el-get
### Mac OS X
Personally I compile my own build of Emacs for Mac OS X using a custom build
script I wrote: [build-emacs-for-osx][]
[build-emacs-for-osx]: https://github.com/jimeh/build-emacs-for-osx
Or if you prefer to not compile it yourself, and you can live without
full-screen and the sRGB patch, you can download the latest nightly from:
[emacsformacosx.com][].
[emacsformacosx.com]: http://emacsformacosx.com/builds
### Linux, Windows
I'm afraid you'll have to figure out how to get Emacs 24 yourself. Like I
said, this is not a starter kit.
- Emacs 24.5 or later. Earlier versions might work, but I haven't tested them.
## Installation
Simply clone my config repo to `~/.emacs.d` update git submodules, and launch
Emacs:
1. Clone the repo to `~/.emacs.d`, and update git submodules:
git clone git://github.com/jimeh/.emacs.d.git ~/.emacs.d
cd ~/.emacs.d
git submodule init
git submodule update
git clone git://github.com/jimeh/.emacs.d.git ~/.emacs.d
cd ~/.emacs.d
git submodule init
git submodule update
Once you launch Emacs, it'll load in the config and the list of packages to
use, automatically installing any packages which are not installed. This means
your first launch can take as long as 5-10 minutes, and also display some
ruby-related errors. On subsequent launches it's fast and error free.
2. Launch Emacs and wait a few minutes while it installs all packages.
3. Enjoy ^_^
*Remember how I said you'll have to live with the bugs too if you wanna use my
config? ;)*
## Why not use Emacs Prelude?
Prelude is nice and all, but I don't need everything it does. I need a config
that does what I need without having to potentially counter and/or work against
some config framework. Hence I prefer rolling my own.
## Notes
The way Prelude structures it's files and code however is very great, and
something I took to heart when I started working on a rewrite of my config, and
hence Emacs Siren was born.
* Feel free to fork and tweak :)
* Theme-wise I use a slightly tweaked version of [Joe Bergantine][]'s [Birds of
Paradise][] theme, which I've made available [here][my-theme]. The original
Emacs port was created by Paul M. Rodriguez, and I can't remember or find
where I got it from originally, so I posted it to [this][ori-theme] Gist.
* I've customized keyboard shortcuts a decent bit, which you can overview in
[keybindings.el][].
* Flyspell is set to use `aspell` instead of the default `ispell` command.
* Most language specific tweaks are in the respective files in the
[languages][] folder.
* There's a lot of stuff in here, dig through the config files manually :)
## Why call my config Emacs-Siren?
[Joe Bergantine]: http://joebergantine.com/
[Birds of Paradise]: http://joebergantine.com/werkstatt/birds-of-paradise
[my-theme]: https://github.com/jimeh/birds-of-paradise-plus-theme.el
[ori-theme]: https://gist.github.com/1130343
[keybindings.el]: https://github.com/jimeh/.emacs.d/blob/master/keybindings.el
[languages]: https://github.com/jimeh/.emacs.d/tree/master/languages
I had been playing a lot of The Witcher 3: Wild Hunt, and decided to pick a name
based on a enemy type from the game. "Siren" was short and kinda cool sounding.
## Todo ##
* Improve ReadMe.
* Come up with more todos.
![Siren](http://i.imgur.com/7PtsVDG.jpg)

View File

@@ -1,168 +0,0 @@
;; Disable splash page
(setq inhibit-startup-message t)
;; Set default font
(if gui-window-system
;;; Large
;; (set-face-attribute 'default nil :family "Monaco" :height 110)
;; (set-face-attribute 'default nil :family "Menlo" :height 110)
;;; Small
(set-face-attribute 'default nil :family "Monaco" :height 100)
;; (set-face-attribute 'default nil :family "Menlo" :height 100)
;; (set-face-attribute 'default nil :family "Inconsolata" :height 120)
)
;; Load Theme
(if gui-window-system (require 'twilight-anti-bright-theme)
(require 'tomorrow-night-paradise-theme))
;; Disable menu-bar
(menu-bar-mode 0)
;; Disable toolbar
(tool-bar-mode -1)
;; Disable Scrollbar
(if gui-window-system (set-scroll-bar-mode 'nil))
;; Show matching parentheses
(show-paren-mode t)
;; Show column number globally
(column-number-mode t)
;; Highlight current line globally
(global-hl-line-mode t)
;; Don't use OSX Native fullscreen mode
(setq ns-use-native-fullscreen nil)
;; Customize line numbers - In gui mode the fringe is the spacer between line
;; numbers and code, while in console mode we add an extra space for it.
(if gui-window-system (setq linum+-dynamic-format " %%%dd")
(setq linum+-dynamic-format " %%%dd "))
;; Linum+ resets linum-format to "smart" when it's loaded, hence we have to
;; use a eval-after-load hook to set it to "dynamic".
(eval-after-load "linum+" '(progn (setq linum-format 'dynamic)))
;; Enable git-gutter-fringe mode.
(if gui-window-system
(when (require 'git-gutter-fringe nil 'noerror)
(global-git-gutter-mode)))
;; Display up to 20 results in when using grizzl completion.
(when (require 'grizzl nil 'noerror)
(setq *grizzl-read-max-results* 20))
;; Use ido completion in projectile.
(setq projectile-completion-system 'ido)
;; Display ido results vertically, rather than horizontally.
(when (require 'ido-vertical-mode nil 'noerror)
(ido-vertical-mode 1))
;; meaningful names for buffers with the same name
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
(setq uniquify-separator "/")
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
;; Display whitespace characters globally
(global-whitespace-mode t)
;; Customize Whitespace Characters
;; - Newline: \u00AC = ¬
;; - Tab: \u2192 = →
;; \u00BB = »
;; \u25B6 = ▶
(setq whitespace-display-mappings
(quote ((newline-mark ?\n [?\u00AC ?\n] [?$ ?\n])
(tab-mark ?\t [?\u2192 ?\t] [?\u00BB ?\t] [?\\ ?\t]))))
(setq whitespace-style
(quote (face tabs trailing space-before-tab newline
indentation space-after-tab tab-mark newline-mark
empty)))
;; Cursor
(blink-cursor-mode t)
(setq initial-frame-alist
(cons '(cursor-type . bar) (copy-alist initial-frame-alist)))
(setq default-frame-alist
(cons '(cursor-type . bar) (copy-alist default-frame-alist)))
;; Transparency (via helpers.el)
(setq transparency-level 99)
(transparency-set-value transparency-level)
(add-hook 'after-make-frame-functions
(lambda (selected-frame)
(set-frame-parameter selected-frame 'alpha transparency-level)))
(when (require 'diminish nil 'noerror)
(diminish 'visual-line-mode)
(eval-after-load "undo-tree" '(diminish 'undo-tree-mode))
(eval-after-load "auto-complete" '(diminish 'auto-complete-mode))
(eval-after-load "yasnippet" '(diminish 'yas-minor-mode))
(eval-after-load "smartparens" '(diminish 'smartparens-mode))
(eval-after-load "hs-minor-mode" '(diminish 'hs-minor-mode))
(eval-after-load "git-gutter-mode" '(diminish 'git-gutter-mode))
(eval-after-load "whitespace-mode" '(diminish 'whitespace-mode))
(eval-after-load "textmate-mode" '(diminish 'textmate-mode)))
;; Relative line numbers -- from: http://stackoverflow.com/a/6928112/42146
;; (defvar my-linum-format-string "%3d ")
;; ;; (add-hook 'linum-before-numbering-hook 'my-linum-get-format-string)
;; (defun my-linum-get-format-string ()
;; (let* ((width (1+ (length (number-to-string
;; (count-lines (point-min) (point-max))))))
;; (format (concat "%" (number-to-string width) "d")))
;; (setq my-linum-format-string format)))
;; (defvar my-linum-current-line-number 0)
;; (setq linum-format 'my-linum-relative-line-numbers)
;; (defun my-linum-relative-line-numbers (line-number)
;; (let ((offset (abs(- line-number my-linum-current-line-number))))
;; (propertize (format my-linum-format-string offset) 'face 'linum)))
;; (defadvice linum-update (around my-linum-update)
;; (let ((my-linum-current-line-number (line-number-at-pos)))
;; ad-do-it))
;; (ad-activate 'linum-update)
;; Customize git-gutter-fringe glyphs.
(when (and gui-window-system (require 'fringe-helper nil 'noerror))
;; (setq-default left-fringe-width 20)
;; (setq-default right-fringe-width 20)
(fringe-helper-define 'git-gutter-fr:added nil
"........"
"........"
"........"
"...XX..."
"...XX..."
"........"
"........"
"........")
(fringe-helper-define 'git-gutter-fr:deleted nil
"........"
"........"
"........"
"...XX..."
"...XX..."
"........"
"........"
"........")
(fringe-helper-define 'git-gutter-fr:modified nil
"........"
"........"
"........"
"...XX..."
"...XX..."
"........"
"........"
"........")
)

View File

@@ -1,103 +0,0 @@
;; Default tab-width of 2 spaces
(setq-default tab-width 2)
;; Electric behavior
(electric-layout-mode t)
;; Always indent with spaces
(setq-default indent-tabs-mode nil)
;; Answer yes/no questions by typing y/n
(fset 'yes-or-no-p 'y-or-n-p)
;; Enable C-x C-l and C-x C-u for down/up-case conversions
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
;; Enable Projectile global mode.
(when (require 'projectile nil 'noerror)
(projectile-global-mode))
;; Popwin
(when (require 'popwin nil 'noerror)
(setq display-buffer-function 'popwin:display-buffer))
;; Recentf
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 100)
(setq recentf-exclude '("\\.git.*" "\\.hg.*" "\\.svn.*"))
;; Enable delete-selection-mode
(delete-selection-mode t)
;; Disable ECB's pre-scanning for empty directories, as it for some reason
;; kept trying scan files as if they were directories, causing constant error
;; messages in the mini-buffer.
(setq ecb-prescan-directories-for-emptyness nil)
;; Save places within files.
(require 'saveplace)
(setq save-place-file "~/.emacs.d/saved-places")
(setq-default save-place t)
;; Use textmate-mode
(when (require 'textmate nil 'noerror)
(textmate-mode))
;; Highlight matching parenthesis
(show-paren-mode 1)
;; Make sure all backup files only live in one place
(setq backup-directory-alist '(("." . "~/.saves")))
;; Make re-builder easier to use
(require 're-builder)
(setq reb-re-syntax 'string)
;; smoother scrolling (less "jumpy" than defaults)
(setq redisplay-dont-pause t
mouse-wheel-scroll-amount '(1 ((shift) . 10)) ;; one line at a time
mouse-wheel-follow-mouse 't ;; scroll window under mouse
scroll-margin 4
scroll-step 1
scroll-conservatively 10000)
;; Enable mouse support when running in a console
(unless window-system
(xterm-mouse-mode 1)
(global-set-key [mouse-4] 'scroll-down-line)
(global-set-key [mouse-5] 'scroll-up-line))
;; Auto-complete when indenting.
(defadvice indent-for-tab-command (around ac-before-indent activate)
"Call `auto-complete' if text was recently entered"
(if (ac-trigger-command-p last-command)
(auto-complete)
ad-do-it))
;; Scroll half a screen when using scroll-up and scroll-down functions.
(defadvice scroll-up (around half-window activate)
(setq next-screen-context-lines
(max 1 (/ (1- (window-height (selected-window))) 2)))
ad-do-it)
(defadvice scroll-down (around half-window activate)
(setq next-screen-context-lines
(max 1 (/ (1- (window-height (selected-window))) 2)))
ad-do-it)
;; Make Project Explorer open selected file in last used buffer
(setq pe/display-content-buffer-function
(lambda (buffer)
(let* (( last-buffer
(car (cl-remove 'project-explorer-mode
(buffer-list)
:key (apply-partially 'buffer-local-value
'major-mode))))
( window (get-buffer-window last-buffer)))
(if window
(set-window-buffer window buffer)
(pe/show-buffer buffer)))
))

45
core/siren-core.el Normal file
View File

@@ -0,0 +1,45 @@
;;
;; core stuff - again shamelessly ripped from Emacs Prelude
;;
(defun siren-smart-open-line-above ()
"Insert an empty line above the current line.
Position the cursor at it's beginning, according to the current mode."
(interactive)
(move-beginning-of-line nil)
(newline-and-indent)
(forward-line -1)
(indent-according-to-mode))
(defun siren-wrap-with (s)
"Create a wrapper function for smartparens using S."
`(lambda (&optional arg)
(interactive "P")
(sp-wrap-with-pair ,s)))
(defun siren-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))))
(provide 'siren-core)

23
core/siren-custom.el Normal file
View File

@@ -0,0 +1,23 @@
;;
;; siren custom
;;
(defcustom siren-yank-indent-threshold 1000
"Threshold (# chars) over which indentation does not automatically occur."
:type 'number
:group 'siren)
(defcustom siren-indent-sensitive-modes
'(conf-mode coffee-mode haml-mode python-mode slim-mode yaml-mode)
"Modes for which auto-indenting is suppressed."
:type 'list
:group 'siren)
(defcustom siren-yank-indent-modes '(LaTeX-mode TeX-mode)
"Modes in which to indent regions that are yanked (or yank-popped).
Only modes that don't derive from `prog-mode' should be listed here."
:type 'list
:group 'siren)
(provide 'siren-custom)

207
core/siren-editor.el Normal file
View File

@@ -0,0 +1,207 @@
;;
;; editor
;;
;; Set default font
(if window-system
(set-face-attribute 'default nil :family "Monaco" :height 100))
;; don't use tabs to indent
(setq-default indent-tabs-mode nil)
;; but maintain correct appearance
(setq-default tab-width 8)
;; Newline at end of file
(setq require-final-newline t)
;; Visual Line mode - wrap lines
(visual-line-mode t)
;; Show matching parentheses
(show-paren-mode t)
;; Highlight current line globally
(global-hl-line-mode t)
;; delete the selection with a keypress
(delete-selection-mode t)
;; Electric behavior
;; (electric-layout-mode t)
;; Cursor
(if window-system
(progn
(blink-cursor-mode t)
(setq initial-frame-alist
(cons '(cursor-type . bar) (copy-alist initial-frame-alist)))
(setq default-frame-alist
(cons '(cursor-type . bar) (copy-alist default-frame-alist))))
(blink-cursor-mode -1))
;; store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;; autosave the undo-tree history
(setq undo-tree-history-directory-alist
`((".*" . ,temporary-file-directory)))
(setq undo-tree-auto-save-history t)
;; smart tab behavior - indent or complete
(setq tab-always-indent 'complete)
;; revert buffers automatically when underlying files are changed externally
(global-auto-revert-mode t)
;; diminish keeps the modeline tidy
(require 'diminish)
(diminish 'visual-line-mode)
;; Enable mouse support when running in a console
(unless window-system
(xterm-mouse-mode 1)
(global-set-key [mouse-4] 'scroll-down-line)
(global-set-key [mouse-5] 'scroll-up-line))
;; saveplace remembers your location in a file when saving files
(require 'saveplace)
(setq save-place-file (expand-file-name "saveplace" siren-savefile-dir))
;; activate it for all buffers
(setq-default save-place t)
;; savehist keeps track of some history
(require 'savehist)
(setq savehist-additional-variables
;; search entries
'(search-ring regexp-search-ring)
;; save every minute
savehist-autosave-interval 60
;; keep the home clean
savehist-file (expand-file-name "savehist" siren-savefile-dir))
(savehist-mode +1)
;; Recentf
(require 'recentf)
(recentf-mode 1)
(setq recentf-save-file (expand-file-name "recentf" siren-savefile-dir)
recentf-max-saved-items 500
recentf-max-menu-items 100
;; disable recentf-cleanup on Emacs start, because it can cause
;; problems with remote files
recentf-auto-cleanup 'never
recentf-exclude '("\\.git.*" "\\.hg.*" "\\.svn.*"))
(defun siren-recentf-exclude-p (file)
"A predicate to decide whether to exclude FILE from recentf."
(let ((file-dir (file-truename (file-name-directory file))))
(-any-p (lambda (dir)
(string-prefix-p dir file-dir))
(mapcar 'file-truename (list siren-savefile-dir package-user-dir)))))
(add-to-list 'recentf-exclude 'siren-recentf-exclude-p)
(recentf-mode +1)
;; meaningful names for buffers with the same name
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets
uniquify-separator "/"
uniquify-after-kill-buffer-p t ; rename after killing uniquified
uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
;; Display whitespace characters globally
(global-whitespace-mode t)
(diminish 'whitespace-mode)
(diminish 'global-whitespace-mode)
(setq whitespace-line-column 80)
;; Customize Whitespace Characters
;; - Newline: \u00AC = ¬
;; - Tab: \u2192 = →
;; \u00BB = »
;; \u25B6 = ▶
(setq whitespace-display-mappings
(quote ((newline-mark ?\n [?\u00AC ?\n] [?$ ?\n])
(tab-mark ?\t [?\u2192 ?\t] [?\u00BB ?\t] [?\\ ?\t]))))
(setq whitespace-style
(quote (face tabs trailing space-before-tab newline
indentation space-after-tab tab-mark newline-mark
empty)))
;; flyspell setup
(require 'flyspell)
(diminish 'flyspell-mode)
(setq ispell-program-name "aspell" ; use aspell instead of ispell
ispell-extra-args '("--sug-mode=ultra"))
;; enabled change region case commands
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;; smarter kill-ring navigation
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
(global-set-key (kbd "s-y") 'browse-kill-ring)
;; automatically indenting yanked text if in programming-modes
(defun yank-advised-indent-function (beg end)
"Do indentation, as long as the region isn't too large."
(if (<= (- end beg) siren-yank-indent-threshold)
(indent-region beg end nil)))
(defmacro advise-commands (advice-name commands class &rest body)
"Apply advice named ADVICE-NAME to multiple COMMANDS.
The body of the advice is in BODY."
`(progn
,@(mapcar (lambda (command)
`(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate)
,@body))
commands)))
(advise-commands "indent" (yank yank-pop) after
"If current mode is one of `siren-yank-indent-modes',
indent yanked text (with prefix arg don't indent)."
(if (and (not (ad-get-arg 0))
(not (member major-mode siren-indent-sensitive-modes))
(or (derived-mode-p 'prog-mode)
(member major-mode siren-yank-indent-modes)))
(let ((transient-mark-mode nil))
(yank-advised-indent-function (region-beginning) (region-end)))))
;; make a shell script executable automatically on save
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
;; .zsh file is shell script too
(add-to-list 'auto-mode-alist '("\\.zsh\\'" . shell-script-mode))
;; saner regex syntax
(require 're-builder)
(setq reb-re-syntax 'string)
;; sensible undo
(global-undo-tree-mode)
(diminish 'undo-tree-mode)
;; diff-hl
(global-diff-hl-mode +1)
(add-hook 'dired-mode-hook 'diff-hl-dired-mode)
;; easy-kill
(global-set-key [remap kill-ring-save] 'easy-kill)
(global-set-key [remap mark-sexp] 'easy-mark)
;; diminish various modes
;; (diminish 'hs-minor-mode)
;; (diminish 'subword-mode)
(provide 'siren-editor)

22
core/siren-env.el Normal file
View File

@@ -0,0 +1,22 @@
;;
;; env
;;
;; Nix package manager
(push "~/.nix-profile/bin" exec-path)
;; Homebrew
(push "/usr/local/bin" exec-path)
;; rbenv
(setq exec-path (cons "~/.rbenv/bin" exec-path))
(setenv "PATH" (concat "~/.rbenv/bin:" (getenv "PATH")))
(setq exec-path (cons "~/.rbenv/shims" exec-path))
(setenv "PATH" (concat "~/.rbenv/shims:" (getenv "PATH")))
;; node.js
(setq exec-path (cons "~/.nvm/versions/node/v0.12.4/bin" exec-path))
(setenv "PATH" (concat "~/.nvm/versions/node/v0.12.4/bin:" (getenv "PATH")))
(provide 'siren-env)

12
core/siren-osx.el Normal file
View File

@@ -0,0 +1,12 @@
;;
;; osx
;;
;; It's all in the Meta
(setq ns-function-modifier 'hyper)
;; Don't use OSX Native fullscreen mode
(setq ns-use-native-fullscreen nil)
(provide 'siren-osx)

70
core/siren-packages.el Normal file
View File

@@ -0,0 +1,70 @@
;;
;; packages
;;
(require 'cl)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
;; set package-user-dir to be relative to config path
(setq package-user-dir (expand-file-name "elpa" siren-dir))
(package-initialize)
(defvar siren-packages
'(browse-kill-ring
dash
discover-my-major
diff-hl
diminish
easy-kill
epl
gist
git-timemachine
gitconfig-mode
gitignore-mode
; god-mode
grizzl
; operate-on-number
smart-mode-line
; smartrep
undo-tree
)
"A list of default packages to ensure are installed at launch.")
;;
;; Package helpers (borrowed from Emacs Prelude)
;;
(defun siren-packages-installed-p ()
"Check if all packages in `siren-packages' are installed."
(every #'package-installed-p siren-packages))
(defun siren-require-package (package)
"Install PACKAGE unless already installed."
(unless (memq package siren-packages)
(add-to-list 'siren-packages package))
(unless (package-installed-p package)
(package-install package)))
(defun siren-require-packages (packages)
"Ensure PACKAGES are installed.
Missing packages are installed automatically."
(mapc #'siren-require-package packages))
(defun siren-install-packages ()
"Install all packages listed in `siren-packages'."
(unless (siren-packages-installed-p)
;; check for new packages (package versions)
(message "%s" "Emacs is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
;; install the missing packages
(siren-require-packages siren-packages)))
;; Install Melpa packages
(siren-install-packages)
(provide 'siren-packages)

52
core/siren-ui.el Normal file
View File

@@ -0,0 +1,52 @@
;;
;; ui
;;
;; the toolbar is just a waste of valuable screen estate
;; in a tty tool-bar-mode does not properly auto-load, and is
;; already disabled anyway
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(menu-bar-mode -1)
;; disable startup screen
(setq inhibit-startup-screen t)
;; Disable Scrollbar
(if window-system (set-scroll-bar-mode 'nil))
;; nice scrolling
;; (setq scroll-margin 0
;; scroll-conservatively 100000
;; scroll-preserve-screen-position 1)
;; (setq redisplay-dont-pause t)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 10))) ;; one line at a time
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-margin 4)
(setq scroll-step 1)
(setq scroll-conservatively 10000)
;; mode line settings
(line-number-mode t)
(column-number-mode t)
(size-indication-mode t)
;; enable y/n answers
(fset 'yes-or-no-p 'y-or-n-p)
;; more useful frame title, that show either a file or a
;; buffer name (if the buffer isn't visiting a file)
(setq frame-title-format
'("Emacs - " (:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
(require 'smart-mode-line)
(setq sml/no-confirm-load-theme t)
;; delegate theming to the currently active theme
(setq sml/theme nil)
(add-hook 'after-init-hook #'sml/setup)
(provide 'siren-ui)

View File

@@ -1,163 +0,0 @@
(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.
'(ac-auto-show-menu 0.2)
'(ac-auto-start 3)
'(ac-delay 0.05)
'(ac-menu-height 15)
'(ack-arguments
(quote
("--ignore-dir=vendor/ruby" "--ignore-dir=vendor/bundle" "--ignore-dir=coverage" "--ignore-dir=docs" "--ignore-dir=doc" "--type-add=js=.js,.js.erb" "--type-add=ruby=.jbuilder,.rabl" "--type-add=html=.haml,.hamlc,.jade" "--type-add=css=.sass,.scss,.styl" "--type-set=coffee=.coffee" "--type-set=cucumber=.feature")))
'(ack-project-root-file-patterns
(quote
(".project\\'" ".xcodeproj\\'" ".sln\\'" "\\`Project.ede\\'" "\\`.git\\'" "\\`.bzr\\'" "\\`_darcs\\'" "\\`.hg\\'" "\\`Gemfile\\'" "\\`Rakefile\\'" "\\`Makefile\\'")))
'(ack-prompt-for-directory (quote unless-guessed))
'(aquamacs-additional-fontsets nil t)
'(aquamacs-customization-version-id 211 t)
'(aquamacs-tool-bar-user-customization nil t)
'(column-number-mode t)
'(display-time-24hr-format t)
'(display-time-day-and-date nil)
'(display-time-interval 10)
'(display-time-load-average-threshold 1.0)
'(display-time-mode t)
'(ecb-basic-buffer-sync (quote (Info-mode dired-mode magit-mode)))
'(ecb-create-layout-file "~/.emacs.d/ecb-user-layouts.el")
'(ecb-layout-name "left13")
'(ecb-options-version "2.40")
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
'(ecb-source-path
(quote
(("~/Projects" "Projects")
("~/.emacs.d" ".emacs.d")
("~/.dotfiles" ".dotfiles")
("~/Projects/fitzdares" "fitzdares")
("~/.go" ".go")
("~/src" "src")
("~/Sites" "Sites")
("~" "~")
("/" "/"))))
'(ecb-tip-of-the-day nil)
'(ecb-toggle-layout-sequence (quote ("left13" "left15")))
'(ecb-tree-indent 3)
'(ecb-tree-make-parent-node-sticky nil)
'(ecb-windows-width 0.24)
'(elscreen-display-tab t)
'(elscreen-tab-display-control t)
'(elscreen-tab-display-kill-screen nil)
'(eproject-completing-read-function (quote eproject--ido-completing-read))
'(evil-default-cursor (quote (t)))
'(exec-path-from-shell-variables (quote ("PATH" "MANPATH" "GOPATH")))
'(fci-handle-truncate-lines nil)
'(fci-rule-width 1)
'(feature-indent-initial-offset 0)
'(fill-column 78)
'(flycheck-completion-system (quote ido))
'(flycheck-idle-change-delay 1.0)
'(flycheck-indication-mode (quote right-fringe))
'(global-auto-revert-mode t)
'(global-undo-tree-mode t)
'(helm-ag-source-type (quote file-line))
'(helm-open-github-commit-limit 10000)
'(history-length 500)
'(ibuffer-formats
(quote
((mark modified read-only " "
(name 48 48 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" " filename-and-process)
(mark " "
(name 16 -1)
" " filename))))
'(icomplete-mode t)
'(ido-vertical-define-keys (quote C-n-C-p-up-down-left-right))
'(imenu-auto-rescan t)
'(imenu-max-item-length 160)
'(imenu-max-items 100)
'(isearch-resume-in-command-history t)
'(ispell-program-name "aspell")
'(magit-completing-read-function (quote magit-ido-completing-read))
'(magit-default-tracking-name-function (quote magit-default-tracking-name-branch-only))
'(magit-repository-directories (quote ("~/Projects" "~/src" "~/.emacs.d" "~/.dotfiles")))
'(magit-status-buffer-switch-function (quote switch-to-buffer))
'(markdown-command "redcarpet")
'(mc/edit-lines-empty-lines (quote ignore))
'(minimap-width-fraction 0.1)
'(minimap-window-location (quote right))
'(neo-smart-open t)
'(neo-window-width 54)
'(ns-tool-bar-display-mode nil t)
'(ns-tool-bar-size-mode nil t)
'(nxhtml-skip-welcome t)
'(org-agenda-files
(list "~/.org-files/todos.org" "~/.org-files/notes.org" "~/.org-files/events.org"))
'(org-agenda-ndays 7)
'(org-agenda-show-all-dates t)
'(org-agenda-skip-deadline-if-done t)
'(org-agenda-skip-scheduled-if-done t)
'(org-agenda-start-on-weekday nil)
'(org-deadline-warning-days 14)
'(org-default-notes-files "~/.org-files/notes.org")
'(org-directory "~/.org-files/")
'(org-fast-tag-selection-single-key (quote expert))
'(org-log-done t)
'(org-remember-store-without-prompt t)
'(org-remember-templates
(quote
(("Todo" 116 "** TODO %?
" "~/.org-files/todos.org" "Tasks")
("Note" 110 "** %?
" "~/.org-files/notes.org" "Notes"))))
'(org-reverse-note-order t)
'(package-selected-packages
(quote
(find-file-in-project zencoding-mode yaml-mode writeroom-mode writegood-mode undo-tree twilight-bright-theme twilight-anti-bright-theme textmate stylus-mode string-inflection smooth-scrolling smex smartparens scss-mode sass-mode ruby-interpolation ruby-compilation rubocop rhtml-mode restclient rbenv rainbow-mode puppet-mode pt project-explorer php-mode phi-search nvm neotree multiple-cursors move-text minimap markdown-mode magit less-css-mode jade-mode ido-vertical-mode highlight-indentation helm-projectile helm-open-github helm-github-stars helm-ag helm-ack grizzl go-snippets go-mode go-autocomplete github-browse-file gitconfig-mode git-timemachine git-gutter-fringe full-ack flymake-php flymake-cursor flymake-css flycheck fill-column-indicator feature-mode expand-region exec-path-from-shell ecb dired+ diminish dash-at-point coffee-mode buffer-move browse-kill-ring ace-jump-buffer)))
'(pe/follow-current t)
'(pe/width 54)
'(persp-modestring-dividers (quote (" [" "]" "|")))
'(persp-show-modestring t)
'(php-mode-dot-property-warning t)
'(projectile-enable-caching nil)
'(projectile-globally-ignored-directories
(quote
(".idea" ".eunit" ".git" ".hg" ".fslckout" ".bzr" ".svn" "_darcs" "vendor/bundle" "vendor/ruby" "coverage" "docs" "doc" "log" "logs" "tmp")))
'(projectile-globally-ignored-files (quote ("TAGS" "*.log")))
'(projectile-sort-order (quote recently-active))
'(ruby-use-encoding-map nil)
'(safe-local-variable-values (quote ((eval rainbow-mode 1))))
'(scss-compile-at-save nil)
'(search-exit-option nil)
'(smooth-scroll-margin 6)
'(sort-fold-case t t)
'(sp-autoescape-string-quote nil)
'(speedbar-show-unknown-files t)
'(standard-indent 2)
'(tabbar-mode nil)
'(tool-bar-mode nil)
'(undo-limit 160000)
'(undo-strong-limit 240000)
'(undo-tree-mode-lighter "")
'(visual-line-mode nil t)
'(whitespace-action nil)
'(winner-mode t nil (winner))
'(writeroom-disable-mode-line nil)
'(writeroom-width 78)
'(yas-global-mode t nil (yasnippet))
'(yas-use-menu t))
(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.
'(mumamo-background-chunk-major ((t nil)) t)
'(mumamo-background-chunk-submode1 ((t nil)) t)
'(mumamo-background-chunk-submode2 ((t nil)) t)
'(mumamo-background-chunk-submode3 ((t nil)) t)
'(mumamo-background-chunk-submode4 ((t nil)) t)
'(persp-selected-face ((t (:foreground "royal blue" :weight bold))))
'(sp-pair-overlay-face ((t (:inherit nil)))))

13
custom.el Normal file
View File

@@ -0,0 +1,13 @@
(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.
'(ecb-options-version "2.40")
'(magit-commit-arguments (quote ("-S"))))
(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.
'(sp-pair-overlay-face ((t (:inherit nil)))))

View File

@@ -1,75 +0,0 @@
;;; .ecb-user-layouts.el --- user defined ECB-layouts
;; Copyright (C) 2001 - 2005 Jesper Nordenberg
;; Copyright (C) 2001 - 2005 Free Software Foundation, Inc.
;; Copyright (C) 2001 - 2005 Klaus Berndl <klaus.berndl@sdm.de>
;; Author: Klaus Berndl <klaus.berndl@sdm.de>
;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
;; Keywords: java, class, browser
;; 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 2, 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 GNU Emacs; see the file COPYING. If not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;; Commentary:
;; This file contains all user-defined ECB-layouts created by the command
;; `ecb-create-new-layout'.
;; !!! DO NOT EDIT THIS FILE MANUALLY - IT IS GENERATED BY ECB !!!
(ecb-layout-define "user-left1" left nil
(if (fboundp (quote ecb-set-directories-buffer)) (ecb-set-directories-buffer) (ecb-set-default-ecb-buffer))
(dotimes (i 2) (other-window 1) (if (equal (selected-window) ecb-compile-window) (other-window 1)))
(ecb-split-ver 0.75 t)
(if (fboundp (quote ecb-set-directories-buffer)) (ecb-set-directories-buffer) (ecb-set-default-ecb-buffer))
(dotimes (i 1) (other-window 1) (if (equal (selected-window) ecb-compile-window) (other-window 1)))
(if (fboundp (quote ecb-set-methods-buffer)) (ecb-set-methods-buffer) (ecb-set-default-ecb-buffer))
(dotimes (i 2) (other-window 1) (if (equal (selected-window) ecb-compile-window) (other-window 1)))
(dotimes (i 2) (other-window 1) (if (equal (selected-window) ecb-compile-window) (other-window 1)))
)
(ecb-layout-define "user-left2" left
"This function creates the following layout:
-------------------------------------------------------
| | |
| | |
| | |
| | |
| | |
| Directories | |
| | |
| | Edit |
| | |
| | |
| | |
|--------------| |
| | |
| Methods | |
| | |
-------------------------------------------------------
| |
| Compilation |
| |
-------------------------------------------------------
If you have not set a compilation-window in `ecb-compile-window-height' then
the layout contains no persistent compilation window and the other windows get a
little more place. This layout works best if it is contained in
`ecb-show-sources-in-directories-buffer'!"
(ecb-set-directories-buffer)
(ecb-split-ver 0.75)
(ecb-set-methods-buffer)
(select-window (next-window)))

Submodule el-get/el-get deleted from 4b053bc515

5
env.el
View File

@@ -1,5 +0,0 @@
;; Nix package manager
(push "~/.nix-profile/bin" exec-path)
;; Homebrew
(push "/usr/local/bin" exec-path)

View File

@@ -1,238 +0,0 @@
;;
;; Auto-indent on Paste
;;
(dolist (command '(yank yank-pop))
(eval `(defadvice ,command (after indent-region activate)
(and (not current-prefix-arg)
(member major-mode '(emacs-lisp-mode lisp-mode
clojure-mode scheme-mode
haskell-mode ruby-mode
rspec-mode python-mode
c-mode c++-mode
objc-mode latex-mode
plain-tex-mode))
(let ((mark-even-if-inactive transient-mark-mode))
(indent-region (region-beginning) (region-end) nil))))))
;;
;; Insert Hash
;;
(defun insert-hash()
"Inserts a hash into the buffer. Useful for UK keyboard layout users."
(interactive)
(insert "#"))
;;
;; Duplicate Line
;; - from: http://tuxicity.se/emacs/elisp/2010/03/11/duplicate-current-line-or-region-in-emacs.html
;;
(defun duplicate-current-line-or-region (arg)
"Duplicates the current line or region ARG times.
If there's no region, the current line will be duplicated. However, if
there's a region, all lines that region covers will be duplicated."
(interactive "p")
(let (beg end (origin (point)))
(if (and mark-active (> (point) (mark)))
(exchange-point-and-mark))
(setq beg (line-beginning-position))
(if mark-active
(exchange-point-and-mark))
(setq end (line-end-position))
(let ((region (buffer-substring-no-properties beg end)))
(dotimes (i arg)
(goto-char end)
(newline)
(insert region)
(setq end (point)))
(goto-char (+ origin (* (length region) arg) arg)))))
;;
;; Align Equal Signs
;;
(defun align-region-to-equals (begin end)
"Align region to equal signs"
(interactive "r")
(align-regexp begin end "\\(\\s-*\\)=" 1 1 ))
(defun align-region-to-opening-brace (begin end)
"Align region to equal signs"
(interactive "r")
(align-regexp begin end "\\(\\s-*\\){" 1 1 ))
;;
;; Yank Pop Forwards
;;
(defun yank-pop-forwards (arg)
(interactive "p")
(yank-pop (- arg)))
;;
;; Window Switching
;;
(defun other-window-reverse ()
"Switch to the previous window"
(interactive)
(other-window -1))
;;
;; Window Re-sizing
;;
(defun enlarge-window-down () (interactive) (enlarge-window 1))
(defun enlarge-window-up () (interactive) (enlarge-window -1))
(defun enlarge-window-left () (interactive) (enlarge-window -1 t))
(defun enlarge-window-right () (interactive) (enlarge-window 1 t))
;;
;; Window Swapping
;; - from https://gist.github.com/287633
;;
(defun swap-with (dir)
(interactive)
(let ((other-window (windmove-find-other-window dir)))
(when other-window
(let* ((this-window (selected-window))
(this-buffer (window-buffer this-window))
(other-buffer (window-buffer other-window))
(this-start (window-start this-window))
(other-start (window-start other-window)))
(set-window-buffer this-window other-buffer)
(set-window-buffer other-window this-buffer)
(set-window-start this-window other-start)
(set-window-start other-window this-start)))))
(defun swap-with-down () (interactive) (swap-with 'down))
(defun swap-with-up () (interactive) (swap-with 'up))
(defun swap-with-left () (interactive) (swap-with 'left))
(defun swap-with-right () (interactive) (swap-with 'right))
;;
;; Transparency
;;
(defun transparency-set-initial-value ()
"Set initial value of alpha parameter for the current frame"
(interactive)
(if (equal (frame-parameter nil 'alpha) nil)
(set-frame-parameter nil 'alpha 100)))
(defun transparency-set-value (numb)
"Set level of transparency for the current frame"
(interactive "nEnter transparency level in range 0-100: ")
(if (> numb 100)
(message "Error! The maximum value for transparency is 100!")
(if (< numb 0)
(message "Error! The minimum value for transparency is 0!")
(set-frame-parameter nil 'alpha numb))))
(defun transparency-increase ()
"Increase level of transparency for the current frame"
(interactive)
(transparency-set-initial-value)
(if (> (frame-parameter nil 'alpha) 0)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) -1))
(message "This is a minimum value of transparency!")))
(defun transparency-decrease ()
"Decrease level of transparency for the current frame"
(interactive)
(transparency-set-initial-value)
(if (< (frame-parameter nil 'alpha) 100)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) +1))
(message "This is a minimum value of transparency!")))
;;
;; Escreen Helper
;; - from http://blog.nguyenvq.com/2011/03/07/escreen-instead-of-elscreen-for-screen-like-features-in-emacs/
;;
(defun escreen-get-active-screen-numbers-with-emphasis ()
"what the name says"
(interactive)
(let ((escreens (escreen-get-active-screen-numbers))
(emphased ""))
(dolist (s escreens)
(setq emphased
(concat emphased (if (= escreen-current-screen-number s)
(propertize (number-to-string s)
;;'face 'custom-variable-tag) " ")
;;'face 'info-title-3)
'face 'font-lock-warning-face)
;;'face 'secondary-selection)
(number-to-string s))
" ")))
(message "escreen: active screens: %s" emphased)))
;;
;; File and Buffer Renaming
;; - from: http://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/
;;
(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)))))))
;;
;; HideShow mode helpers
;; - from: http://www.emacswiki.org/emacs/HideShow
;;
(defun toggle-selective-display (column)
(interactive "P")
(set-selective-display
(or column
(unless selective-display
(1+ (current-column))))))
(defun toggle-hiding (column)
(interactive "P")
(if hs-minor-mode
(if (condition-case nil
(hs-toggle-hiding)
(error t))
(hs-show-all))
(toggle-selective-display column)))
;;
;; Remove duplicates lines
;; - from: http://www.emacswiki.org/emacs/DuplicateLines#toc4
;;
(defun uniquify-region-lines (beg end)
"Remove duplicate adjacent lines in region."
(interactive "*r")
(save-excursion
(goto-char beg)
(while (re-search-forward "^\\(.*\n\\)\\1+" end t)
(replace-match "\\1"))))
(defun uniquify-buffer-lines ()
"Remove duplicate adjacent lines in the current buffer."
(interactive)
(uniquify-region-lines (point-min) (point-max)))

94
init.el
View File

@@ -10,38 +10,76 @@
;;
;; (package-initialize)
(setq emacs-config-dir
(file-name-directory (or load-file-name (buffer-file-name))))
(defvar current-user
(getenv
(if (equal system-type 'windows-nt) "USERNAME" "USER")))
;; Determine if GUI or console settings should apply
(setq gui-window-system
(if (or (getenv "EMACS_GUI_SERVER") window-system) t 'nil))
(message "Siren is powering up... Be patient, Master %s!" current-user)
;; Helper function for config path
(defun get-config-path(path)
"Appends argument at the end of emacs-config-dir using expand-file-name"
(expand-file-name path emacs-config-dir))
(when (version< emacs-version "24.1")
(error "Siren requires at least GNU Emacs 24.1, but you're running %s"
emacs-version))
;; Load various config files
(load-file (get-config-path "env.el"))
(load-file (get-config-path "packages.el"))
(load-file (get-config-path "helpers.el"))
(load-file (get-config-path "mode-customizations.el"))
(load-file (get-config-path "vendor.el"))
(load-file (get-config-path "behavior.el"))
(load-file (get-config-path "appearance.el"))
(load-file (get-config-path "keybindings.el"))
(load-file (get-config-path "aliases.el"))
(load-file (get-config-path "remember.el"))
(load-file (get-config-path "project-definitions.el"))
;; Always load newest byte code
(setq load-prefer-newer t)
;; Custom variables file
(setq custom-file (get-config-path "custom-variables.el"))
;; Setup paths
(defvar siren-dir (file-name-directory load-file-name)
"The root dir of the Emacs config.")
(defvar siren-core-dir (expand-file-name "core" siren-dir)
"The home of core stuff.")
(defvar siren-modules-dir (expand-file-name "modules" siren-dir)
"This directory houses all of the modules.")
(defvar siren-themes-dir (expand-file-name "themes" siren-dir)
"This directory houses all of the modules.")
(defvar siren-savefile-dir (expand-file-name "savefile" siren-dir)
"This folder stores all the automatically generated save/history-files.")
(defvar siren-vendor-dir (expand-file-name "vendor" siren-dir)
"This directory houses packages that are not yet available in ELPA (or MELPA).")
(defvar siren-modules-file (expand-file-name "siren-modules.el" siren-dir)
"This files contains a list of modules to be loaded.")
(defvar siren-theme-file (expand-file-name "siren-theme.el" siren-dir)
"This files contains a list of modules to be loaded.")
(unless (file-exists-p siren-savefile-dir)
(make-directory siren-savefile-dir))
(defun siren-add-subfolders-to-load-path (parent-dir)
"Add all level PARENT-DIR subdirs to the `load-path'."
(dolist (f (directory-files parent-dir))
(let ((name (expand-file-name f parent-dir)))
(when (and (file-directory-p name)
(not (string-prefix-p "." f)))
(add-to-list 'load-path name)
(siren-add-subfolders-to-load-path name)))))
(add-to-list 'load-path siren-core-dir)
(add-to-list 'load-path siren-modules-dir)
(add-to-list 'load-path siren-themes-dir)
(add-to-list 'load-path siren-vendor-dir)
(siren-add-subfolders-to-load-path siren-vendor-dir)
;; core stuff
(require 'siren-env)
(require 'siren-custom)
(require 'siren-core)
(require 'siren-packages)
(require 'siren-ui)
(require 'siren-editor)
;; osx specific
(when (eq system-type 'darwin)
(require 'siren-osx))
;; config changes made through the customize UI will be store here
(setq custom-file (expand-file-name "custom.el" siren-dir))
(load-file custom-file)
;; Load runtime specific setup files
(load-file (get-config-path "runtimes/ruby.el"))
(load-file (get-config-path "runtimes/nodejs.el"))
;; the modules
(if (file-exists-p siren-modules-file)
(load siren-modules-file))
;; Initialize packages in packages.el
(initialize-my-packages)
;; the theme
(if (file-exists-p siren-theme-file)
(load siren-theme-file))

View File

@@ -1,342 +0,0 @@
;;
;; Setup a few global keyboard shortcuts
;;
;; Alternative to M-x
(global-set-key (kbd "C-x C-m") 'execute-extended-command)
(global-set-key (kbd "C-c C-m") 'execute-extended-command)
;; Enable dabbrev-expand via custom keybinding.
(global-set-key (kbd "C-x M-/") 'dabbrev-expand)
;; If Smex is available, use it instead of extended-command
(when (require 'smex nil 'noerror)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "C-x C-m") 'smex)
(global-set-key (kbd "C-c C-m") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command))
;; Easier version of "C-x k" to kill buffer
(global-set-key (kbd "C-x C-k") 'kill-buffer)
;; Evaluate buffer
(global-set-key (kbd "C-c C-e") 'eval-buffer)
;; Goto line
(global-set-key (kbd "C-c C-l") 'goto-line)
;; Switch to next/previous buffer
(global-set-key (kbd "C-c C-n") 'switch-to-next-buffer)
(global-set-key (kbd "C-c C-p") 'switch-to-prev-buffer)
;; Duplicate line (via helpers.el)
(global-set-key (kbd "C-x C-d") 'duplicate-current-line-or-region)
;; Window switching (via helpers.el).
(global-set-key (kbd "C-x i") 'other-window-reverse)
(global-set-key (kbd "C-x C-o") 'other-window)
(global-set-key (kbd "C-x C-i") 'other-window-reverse)
;; Kill-Ring related (via helpers.el).
(global-set-key (kbd "M-Y") 'yank-pop-forwards)
;; Align to equal signs (via helpers.el).
(global-set-key (kbd "C-x a =") 'align-region-to-equals)
(global-set-key (kbd "M-]") 'align-region-to-equals)
(global-set-key (kbd "C-x a {") 'align-region-to-opening-brace)
;; align-regexp
(global-set-key (kbd "C-c C-a") 'align-regexp)
;; Toggle auto-fill-mode.
(global-set-key (kbd "C-c q") 'auto-fill-mode)
;; Comment or uncomment line
(global-set-key (kbd "C-c /") 'comment-or-uncomment-region-or-line)
(global-set-key (kbd "C-c C-/") 'comment-or-uncomment-region-or-line)
;; Custom HideShow toggles (via helpers.el)
(global-set-key (kbd "C-=") 'toggle-selective-display)
(global-set-key (kbd "C-\\") 'toggle-hiding)
(when (require 'auto-complete nil 'noerror)
(define-key ac-completing-map (kbd "RET") 'ac-complete)
(define-key ac-completing-map (kbd "C-m") 'ac-complete)
(define-key ac-completing-map (kbd "C-s") 'ac-isearch)
(define-key ac-completing-map (kbd "C-n") 'ac-next)
(define-key ac-completing-map (kbd "C-p") 'ac-previous))
;; phi-search (enables C-s and C-r searching with multiple-cursors-mode).
(when (require 'phi-search nil 'noerror)
(global-set-key (kbd "C-s") 'phi-search)
(global-set-key (kbd "C-r") 'phi-search-backward))
;; Helm
(when (require 'helm nil 'noerror)
(define-key helm-map (kbd "<up>") 'previous-history-element)
(define-key helm-map (kbd "<down>") 'next-history-element)
(define-key helm-map (kbd "M-p") 'helm-previous-source)
(define-key helm-map (kbd "M-n") 'helm-next-source)
(global-set-key (kbd "C-c h") 'helm-mini))
;; Helm Swoop
(when (require 'helm-swoop nil 'noerror)
(global-set-key (kbd "M-r") 'helm-swoop)
(global-set-key (kbd "M-R") 'helm-swoop-back-to-last-point)
(global-set-key (kbd "C-c M-r") 'helm-multi-swoop)
(global-set-key (kbd "C-x M-r") 'helm-multi-swoop-all))
;; Helm Projectile
(when (require 'helm-projectile nil 'noerror)
(global-set-key (kbd "C-c ;") 'helm-projectile)
(global-set-key (kbd "C-c C-;") 'helm-projectile))
;; Helm Open Github
(when (require 'helm-open-github nil 'noerror)
(global-set-key (kbd "C-c o f") 'helm-open-github-from-file)
(global-set-key (kbd "C-c o c") 'helm-open-github-from-commit)
(global-set-key (kbd "C-c o i") 'helm-open-github-from-issues)
(global-set-key (kbd "C-c o p") 'helm-open-github-from-pull-requests))
;; Expand region
(when (require 'expand-region nil 'noerror)
(global-set-key (kbd "M-.") 'er/expand-region)
(global-set-key (kbd "M-,") 'er/contract-region))
;; multiple-cursors
(when (require 'multiple-cursors nil 'noerror)
(global-set-key (kbd "C-x C-@") 'mc/edit-lines) ;; Terminal
(global-set-key (kbd "C-x C-SPC") 'mc/edit-lines) ;; GUI
(global-set-key (kbd "M-/") 'mc/mark-next-like-this)
(global-set-key (kbd "M-m") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c M-/") 'mc/mark-all-like-this)
(global-set-key (kbd "M-RET") 'set-rectangular-region-anchor)
;; Make alt-<click> add additional cursors
(global-unset-key (kbd "M-<down-mouse-1>")) ;; must unset key first
(global-set-key (kbd "M-<mouse-1>") 'mc/add-cursor-on-click))
;; Browse the kill-ring.
(when (require 'browse-kill-ring nil 'noerror)
(global-set-key (kbd "C-x C-y") 'browse-kill-ring))
;; Undo/Redo
(when (require 'undo-tree nil 'noerror)
(global-set-key (kbd "M--") 'undo-tree-undo)
(global-set-key (kbd "M-_") 'undo-tree-redo))
(when (require 'dash-at-point nil 'noerror)
(global-set-key (kbd "C-c d") 'dash-at-point))
;; Mac OS X specific keybindings
(when (eq system-type 'darwin)
;; Mac OS X Fullscreen (requires Emacs 24.4 or later)
(global-set-key (kbd "s-<return>") 'toggle-frame-fullscreen)
;; Undo/Redo (via undo-tree)
(when (require 'undo-tree nil 'noerror)
(global-set-key (kbd "s-z") 'undo-tree-undo)
(global-set-key (kbd "s-Z") 'undo-tree-redo))
;; Flyspell correct previous word
(when (require 'flyspell nil 'noerror)
(global-set-key (kbd "s-.") 'flyspell-correct-word-before-point))
;; Move to beginning/end of buffer
(global-set-key (kbd "s-<up>") 'beginning-of-buffer)
(global-set-key (kbd "s-<down>") 'end-of-buffer)
;; Move to beginning/end of line
(global-set-key (kbd "s-<left>") 'beginning-of-line)
(global-set-key (kbd "s-<right>") 'end-of-line))
;; IBuffer
(when (require 'ibuffer nil 'noerror)
(global-set-key (kbd "C-x C-b") 'ibuffer))
;; ECB
;; (when (require 'ecb nil 'noerror)
;; (global-set-key (kbd "C-c C-.") 'ecb-activate))
;; string-inflection
(when (require 'string-inflection nil 'noerror)
(global-set-key (kbd "C-c C-.") 'string-inflection-cycle))
;; Project Explorer
(when (require 'project-explorer nil 'noerror)
(global-set-key (kbd "C-x p") 'project-explorer-open))
;; Magit
(when (require 'magit nil 'noerror)
(global-set-key (kbd "C-x g") 'magit-status))
;; Avy mode
(when (require 'avy nil 'noerror)
(define-key global-map (kbd "C-c C-j") 'avy-goto-word-or-subword-1)
(define-key global-map (kbd "C-c SPC") 'avy-goto-char))
;; Ace-window
(when (require 'ace-window nil 'noerror)
(define-key global-map (kbd "M-o") 'ace-window))
;; projectile related keybindings
(when (require 'projectile nil 'noerror)
(global-set-key (kbd "C-c C-b") 'projectile-ibuffer)
(global-set-key (kbd "C-x C-t") 'projectile-find-file)
(global-set-key (kbd "C-x t") 'projectile-find-test-file)
(global-set-key (kbd "C-x C-v") 'projectile-switch-to-buffer)
(global-set-key (kbd "C-c C-s") 'projectile-switch-project))
;; Textmate-mode related keybindings
(when (require 'textmate nil 'noerror)
(global-set-key (kbd "C-t") 'textmate-goto-symbol)
;; (global-set-key (kbd "M-p") 'textmate-column-up)
;; (global-set-key (kbd "M-n") 'textmate-column-down)
(global-set-key (kbd "C-c [") 'textmate-shift-left)
(global-set-key (kbd "C-c ]") 'textmate-shift-right))
;; move-text
(when (require 'move-text nil 'noerror)
;; Must be set after textmate is required.
(define-key global-map (kbd "M-p") 'move-text-up)
(define-key global-map (kbd "M-n") 'move-text-down))
;; smartparens
;; (when (require 'smartparens nil 'noerror)
;; ;; Must be set after textmate is required.
;; (define-key sp-keymap (kbd "M-F") 'sp-forward-symbol)
;; (define-key sp-keymap (kbd "M-B") 'sp-backward-symbol)
;; (define-key sp-keymap (kbd "C-M-f") 'sp-forward-sexp)
;; (define-key sp-keymap (kbd "C-M-b") 'sp-backward-sexp))
;; Set/increase/decrease transparency (via helpers.el)
(global-set-key (kbd "C-M-|") 'transparency-set-value)
(global-set-key (kbd "C-M-<") 'transparency-increase)
(global-set-key (kbd "C-M->") 'transparency-decrease)
;; Window Resizing
(define-key global-map (kbd "C-{") 'shrink-window-horizontally)
(define-key global-map (kbd "C-}") 'enlarge-window-horizontally)
(define-key global-map (kbd "C-^") 'enlarge-window)
;; Move buffers between windows
(when (require 'buffer-move nil 'noerror)
(global-set-key (kbd "M-K") 'buf-move-down)
(global-set-key (kbd "M-I") 'buf-move-up)
(global-set-key (kbd "M-J") 'buf-move-left)
(global-set-key (kbd "M-L") 'buf-move-right))
;; Window Tiling (via helpers.el)
(global-set-key (kbd "M-k") 'windmove-down)
(global-set-key (kbd "M-i") 'windmove-up)
(global-set-key (kbd "M-j") 'windmove-left)
(global-set-key (kbd "M-l") 'windmove-right)
;; Org-mode
(define-key global-map (kbd "C-c a") 'org-agenda)
(define-key global-map (kbd "C-c l") 'org-store-link)
;; Remember mode
;; (define-key global-map (kbd "C-c r") 'org-remember)
;; (define-key global-map (kbd "C-M-r") 'org-remember)
;; Rename current file and buffer (via helpers.el)
(global-set-key (kbd "C-c r") 'rename-file-and-buffer)
;; Allow hash to be entered on UK keyboards (via helpers.el)
(global-set-key (kbd "M-3") 'insert-hash)
;; tiling.el related bindings
(when (require 'tiling nil 'noerror)
(define-key global-map (kbd "C-\\") 'tiling-cycle))
;; ElScreen related shortcuts
(when (require 'elscreen nil 'noerror)
(define-key elscreen-map (kbd "C-z") elscreen-map)
;; Goto screens.
(global-set-key (kbd "s-}") 'elscreen-next)
(global-set-key (kbd "s-{") 'elscreen-previous)
;; Set screen nickname
(define-key elscreen-map (kbd ",") 'elscreen-screen-nickname)
(define-key elscreen-map (kbd "C-,") 'elscreen-screen-nickname)
;; Toggle screens.
(define-key elscreen-map (kbd "l") 'elscreen-toggle)
(define-key elscreen-map (kbd "C-l") 'elscreen-toggle)
;; Display list of screens.
(define-key elscreen-map (kbd ";") 'elscreen-display-screen-name-list)
(define-key elscreen-map (kbd "C-;") 'elscreen-display-screen-name-list))
(when (require 'workgroups2 nil 'noerror)
(setq wg-prefix-key (kbd "C-z"))
)
(when (require 'perspective nil 'noerror)
(define-key persp-mode-map (kbd "C-z") perspective-map)
(define-key persp-mode-map (kbd "C-z s") 'persp-switch)
(define-key persp-mode-map (kbd "C-z C-s") 'persp-switch)
(define-key persp-mode-map (kbd "C-z b") 'persp-switch)
(define-key persp-mode-map (kbd "C-z C-b") 'persp-switch)
(define-key persp-mode-map (kbd "C-z c") 'persp-remove-buffer)
(define-key persp-mode-map (kbd "C-z C-c") 'persp-remove-buffer)
(define-key persp-mode-map (kbd "C-z k") 'persp-kill)
(define-key persp-mode-map (kbd "C-z C-k") 'persp-kill)
(define-key persp-mode-map (kbd "C-z r") 'persp-rename)
(define-key persp-mode-map (kbd "C-z C-r") 'persp-rename)
(define-key persp-mode-map (kbd "C-z a") 'persp-add-buffer)
(define-key persp-mode-map (kbd "C-z C-a") 'persp-add-buffer)
(define-key persp-mode-map (kbd "C-z i") 'persp-import)
(define-key persp-mode-map (kbd "C-z C-i") 'persp-import)
(define-key persp-mode-map (kbd "C-z n") 'persp-next)
(define-key persp-mode-map (kbd "C-z C-n") 'persp-next)
(define-key persp-mode-map (kbd "C-z p") 'persp-prev)
(define-key persp-mode-map (kbd "C-z C-p") 'persp-prev)
)
;; Escreen customizations (via helpers.el).
(when (require 'escreen nil 'noerror)
;; Set prefix key to C-z.
(setq escreen-prefix-char (kbd "C-z"))
(global-set-key escreen-prefix-char 'escreen-prefix)
(define-key escreen-map escreen-prefix-char 'escreen-goto-last-screen)
;; Toggle screens.
(define-key escreen-map (kbd "l") 'escreen-goto-last-screen)
(define-key escreen-map (kbd "C-l") 'escreen-goto-last-screen)
;; List screens.
(define-key escreen-map (kbd "a")
'escreen-get-active-screen-numbers-with-emphasis)
(define-key escreen-map (kbd "C-a")
'escreen-get-active-screen-numbers-with-emphasis)
(define-key escreen-map (kbd ";")
'escreen-get-active-screen-numbers-with-emphasis)
(define-key escreen-map (kbd "C-;")
'escreen-get-active-screen-numbers-with-emphasis)
;; Goto screens.
(global-set-key (kbd "s-}") 'escreen-goto-next-screen)
(global-set-key (kbd "s-{") 'escreen-goto-prev-screen)
;; Ctrl versions of default commands.
(define-key escreen-map (kbd "C-c") 'escreen-create-screen)
(define-key escreen-map (kbd "C-g") 'escreen-goto-screen)
(define-key escreen-map (kbd "C-k") 'escreen-kill-screen)
(define-key escreen-map (kbd "C-n") 'escreen-goto-next-screen)
(define-key escreen-map (kbd "C-p") 'escreen-goto-prev-screen)
;; Show list of screens when you switch/create/kill.
(add-hook 'escreen-goto-screen-hook
'escreen-get-active-screen-numbers-with-emphasis))

View File

@@ -1,33 +0,0 @@
;;
;; Load Mode Customizations
;;
;; Programming languages
(load-file (get-config-path "mode-customizations/ack-mode.el"))
(load-file (get-config-path "mode-customizations/coffee-mode.el"))
(load-file (get-config-path "mode-customizations/conf-mode.el"))
(load-file (get-config-path "mode-customizations/css-mode.el"))
(load-file (get-config-path "mode-customizations/dired-mode.el"))
(load-file (get-config-path "mode-customizations/emacs-lisp-mode.el"))
(load-file (get-config-path "mode-customizations/erlang-mode.el"))
(load-file (get-config-path "mode-customizations/feature-mode.el"))
(load-file (get-config-path "mode-customizations/git-commit-mode.el"))
(load-file (get-config-path "mode-customizations/go-mode.el"))
(load-file (get-config-path "mode-customizations/haml-mode.el"))
(load-file (get-config-path "mode-customizations/html-mode.el"))
(load-file (get-config-path "mode-customizations/js-mode.el"))
(load-file (get-config-path "mode-customizations/lisp-mode.el"))
(load-file (get-config-path "mode-customizations/makefile-mode.el"))
(load-file (get-config-path "mode-customizations/markdown-mode.el"))
(load-file (get-config-path "mode-customizations/php-mode.el"))
(load-file (get-config-path "mode-customizations/puppet-mode.el"))
(load-file (get-config-path "mode-customizations/python-mode.el"))
(load-file (get-config-path "mode-customizations/rhtml-mode.el"))
(load-file (get-config-path "mode-customizations/ruby-mode.el"))
(load-file (get-config-path "mode-customizations/sass-mode.el"))
(load-file (get-config-path "mode-customizations/sh-mode.el"))
(load-file (get-config-path "mode-customizations/slim-mode.el"))
(load-file (get-config-path "mode-customizations/yaml-mode.el"))
;; Misc modes
(load-file (get-config-path "mode-customizations/magit-mode.el"))

View File

@@ -1,5 +0,0 @@
(defun customizations-for-ack-mode ()
(interactive)
(define-key ack-mode-map (kbd "q") 'kill-this-buffer))
(add-hook 'ack-mode-hook 'customizations-for-ack-mode)

View File

@@ -1,20 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
(add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode))
(defun customizations-for-coffee-mode ()
(interactive)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(whitespace-mode)
(setq whitespace-action (quote (auto-cleanup)))
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'coffee-mode-hook 'customizations-for-coffee-mode)

View File

@@ -1,8 +0,0 @@
(defun customizations-for-conf-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(auto-complete-mode))
(add-hook 'conf-mode-hook 'customizations-for-conf-mode)

View File

@@ -1,14 +0,0 @@
(defun customizations-for-css-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(setq css-indent-offset 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(define-key css-mode-map (kbd "RET") 'newline-and-indent))
(add-hook 'css-mode-hook 'customizations-for-css-mode)

View File

@@ -1,8 +0,0 @@
(defun customizations-for-dired-mode ()
(interactive)
(linum-mode t)
(define-key dired-mode-map (kbd "c") 'dired-create-directory)
(when (require 'dired+ nil 'noerror)
(toggle-diredp-find-file-reuse-dir 1)))
(add-hook 'dired-mode-hook 'customizations-for-dired-mode)

View File

@@ -1,10 +0,0 @@
(defun customizations-for-emacs-lisp-mode ()
(interactive)
(setq whitespace-action (quote (auto-cleanup)))
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode))
(add-hook 'emacs-lisp-mode-hook 'customizations-for-emacs-lisp-mode)

View File

@@ -1,22 +0,0 @@
;; erlang-mode is part of the Erlang source, and I found
;; no simple way to create a el-get package. So it's one
;; more thing thats not installed through el-get.
(add-to-list 'load-path (get-config-path "mode-customizations/erlang"))
(setq erlang-root-dir "/usr/local")
(setq exec-path (cons "/usr/local/bin" exec-path))
(require 'erlang-start)
(require 'erlang-flymake)
(defun customizations-for-erlang-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'erlang-mode-hook 'customizations-for-erlang-mode)

View File

@@ -1,55 +0,0 @@
User configuration notes
========================
Below is a quick guide to necessary configurations for getting
started with the Erlang mode for Emacs. Please refer to the
Users guide and reference manual in the documentation for the
Erlang/OTP application tools for more information.
For UNIX users
--------------
To set up the Erlang Emacs mode on UNIX systems, edit/create the file
.emacs in the your home directory.
Below is a complete example of what should be added to a user's .emacs
provided that OTP is installed in the directory /usr/local/otp:
(setq load-path (cons "/usr/local/otp/lib/tools-<ToolsVer>/emacs"
load-path))
(setq erlang-root-dir "/usr/local/otp")
(setq exec-path (cons "/usr/local/otp/bin" exec-path))
(require 'erlang-start)
For Windows users
-----------------
To set up the Erlang Emacs mode on Windows systems, edit/create the
file .emacs, the location of the file depends on the configuration of
the system. If the HOME environment variable is set, Emacs will look
for the .emacs file in the directory indicated by the HOME
variable. If HOME is not set, Emacs will look for the .emacs file in
C:\.
Below is a complete example of what should be added to a user's .emacs
provided that OTP is installed in the directory C:\Program
Files\erl-<Ver>:
(setq load-path (cons "C:/Program Files/erl<Ver>/lib/tools-<ToolsVer>/emacs"
load-path))
(setq erlang-root-dir "C:/Program Files/erl<Ver>")
(setq exec-path (cons "C:/Program Files/erl<Ver>/bin" exec-path))
(require 'erlang-start)
Miscellaneous addons
--------------------
In order to check erlang source code on the fly, add the following
line to your .emacs file (after erlang-start, see above). See
erlang-flymake.el for more information on how to customize the syntax
check.
(require 'erlang-flymake)

View File

@@ -1,448 +0,0 @@
;;
;; %CopyrightBegin%
;;
;; Copyright Ericsson AB 2009-2010. All Rights Reserved.
;;
;; The contents of this file are subject to the Erlang Public License,
;; Version 1.1, (the "License"); you may not use this file except in
;; compliance with the License. You should have received a copy of the
;; Erlang Public License along with this software. If not, it can be
;; retrieved online at http://www.erlang.org/.
;;
;; Software distributed under the License is distributed on an "AS IS"
;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
;; the License for the specific language governing rights and limitations
;; under the License.
;;
;; %CopyrightEnd%
;;;
;;; Purpose: Provide EUnit utilities.
;;;
;;; Author: Klas Johansson
(eval-when-compile
(require 'cl))
(defvar erlang-eunit-src-candidate-dirs '("../src" ".")
"*Name of directories which to search for source files matching
an EUnit test file. The first directory in the list will be used,
if there is no match.")
(defvar erlang-eunit-test-candidate-dirs '("../test" ".")
"*Name of directories which to search for EUnit test files matching
a source file. The first directory in the list will be used,
if there is no match.")
(defvar erlang-eunit-autosave nil
"*Set to non-nil to automtically save unsaved buffers before running tests.
This is useful, reducing the save-compile-load-test cycle to one keychord.")
(defvar erlang-eunit-recent-info '((mode . nil) (module . nil) (test . nil) (cover . nil))
"Info about the most recent running of an EUnit test representation.")
;;;
;;; Switch between src/EUnit test buffers
;;;
(defun erlang-eunit-toggle-src-and-test-file-other-window ()
"Switch to the src file if the EUnit test file is the current
buffer and vice versa"
(interactive)
(if (erlang-eunit-test-file-p buffer-file-name)
(erlang-eunit-open-src-file-other-window buffer-file-name)
(erlang-eunit-open-test-file-other-window buffer-file-name)))
;;;
;;; Open the EUnit test file which corresponds to a src file
;;;
(defun erlang-eunit-open-test-file-other-window (src-file-path)
"Open the EUnit test file which corresponds to a src file"
(find-file-other-window (erlang-eunit-test-filename src-file-path)))
;;;
;;; Open the src file which corresponds to the an EUnit test file
;;;
(defun erlang-eunit-open-src-file-other-window (test-file-path)
"Open the src file which corresponds to the an EUnit test file"
(find-file-other-window (erlang-eunit-src-filename test-file-path)))
;;; Return the name and path of the EUnit test file
;;, (input may be either the source filename itself or the EUnit test filename)
(defun erlang-eunit-test-filename (file-path)
(if (erlang-eunit-test-file-p file-path)
file-path
(erlang-eunit-rewrite-filename file-path erlang-eunit-test-candidate-dirs)))
;;; Return the name and path of the source file
;;, (input may be either the source filename itself or the EUnit test filename)
(defun erlang-eunit-src-filename (file-path)
(if (erlang-eunit-src-file-p file-path)
file-path
(erlang-eunit-rewrite-filename file-path erlang-eunit-src-candidate-dirs)))
;;; Rewrite a filename from the src or test filename to the other
(defun erlang-eunit-rewrite-filename (orig-file-path candidate-dirs)
(or (erlang-eunit-locate-buddy orig-file-path candidate-dirs)
(erlang-eunit-buddy-file-path orig-file-path (car candidate-dirs))))
;;; Search for a file's buddy file (a source file's EUnit test file,
;;; or an EUnit test file's source file) in a list of candidate
;;; directories.
(defun erlang-eunit-locate-buddy (orig-file-path candidate-dirs)
(when candidate-dirs
(let ((buddy-file-path (erlang-eunit-buddy-file-path
orig-file-path
(car candidate-dirs))))
(if (file-readable-p buddy-file-path)
buddy-file-path
(erlang-eunit-locate-buddy orig-file-path (cdr candidate-dirs))))))
(defun erlang-eunit-buddy-file-path (orig-file-path buddy-dir-name)
(let* ((orig-dir-name (file-name-directory orig-file-path))
(buddy-dir-name (file-truename
(filename-join orig-dir-name buddy-dir-name)))
(buddy-base-name (erlang-eunit-buddy-basename orig-file-path)))
(filename-join buddy-dir-name buddy-base-name)))
;;; Return the basename of the buddy file:
;;; /tmp/foo/src/x.erl --> x_tests.erl
;;; /tmp/foo/test/x_tests.erl --> x.erl
(defun erlang-eunit-buddy-basename (file-path)
(let ((src-module-name (erlang-eunit-source-module-name file-path)))
(cond
((erlang-eunit-src-file-p file-path)
(concat src-module-name "_tests.erl"))
((erlang-eunit-test-file-p file-path)
(concat src-module-name ".erl")))))
;;; Checks whether a file is a source file or not
(defun erlang-eunit-src-file-p (file-path)
(not (erlang-eunit-test-file-p file-path)))
;;; Checks whether a file is a EUnit test file or not
(defun erlang-eunit-test-file-p (file-path)
(erlang-eunit-string-match-p "^\\(.+\\)_tests.erl$" file-path))
;;; Return the module name of the source file
;;; /tmp/foo/src/x.erl --> x
;;; /tmp/foo/test/x_tests.erl --> x
(defun erlang-eunit-source-module-name (file-path)
(interactive)
(let ((module-name (erlang-eunit-module-name file-path)))
(if (string-match "^\\(.+\\)_tests$" module-name)
(substring module-name (match-beginning 1) (match-end 1))
module-name)))
;;; Return the module name of the file
;;; /tmp/foo/src/x.erl --> x
;;; /tmp/foo/test/x_tests.erl --> x_tests
(defun erlang-eunit-module-name (file-path)
(interactive)
(file-name-sans-extension (file-name-nondirectory file-path)))
;;; Older emacsen don't have string-match-p.
(defun erlang-eunit-string-match-p (regexp string &optional start)
(if (fboundp 'string-match-p) ;; appeared in emacs 23
(string-match-p regexp string start)
(save-match-data ;; fallback for earlier versions of emacs
(string-match regexp string start))))
;;; Join filenames
(defun filename-join (dir file)
(if (or (= (elt file 0) ?/)
(= (car (last (append dir nil))) ?/))
(concat dir file)
(concat dir "/" file)))
;;; Get info about the most recent running of EUnit
(defun erlang-eunit-recent (key)
(cdr (assq key erlang-eunit-recent-info)))
;;; Record info about the most recent running of EUnit
;;; Known modes are 'module-mode and 'test-mode
(defun erlang-eunit-record-recent (mode module test)
(setcdr (assq 'mode erlang-eunit-recent-info) mode)
(setcdr (assq 'module erlang-eunit-recent-info) module)
(setcdr (assq 'test erlang-eunit-recent-info) test))
;;; Record whether the most recent running of EUnit included cover
;;; compilation
(defun erlang-eunit-record-recent-compile (under-cover)
(setcdr (assq 'cover erlang-eunit-recent-info) under-cover))
;;; Determine options for EUnit.
(defun erlang-eunit-opts ()
(if current-prefix-arg ", [verbose]" ""))
;;; Determine current test function
(defun erlang-eunit-current-test ()
(save-excursion
(erlang-end-of-function 1)
(erlang-beginning-of-function 1)
(erlang-name-of-function)))
(defun erlang-eunit-simple-test-p (test-name)
(if (erlang-eunit-string-match-p "^\\(.+\\)_test$" test-name) t nil))
(defun erlang-eunit-test-generator-p (test-name)
(if (erlang-eunit-string-match-p "^\\(.+\\)_test_$" test-name) t nil))
;;; Run one EUnit test
(defun erlang-eunit-run-test (module-name test-name)
(let ((command
(cond ((erlang-eunit-simple-test-p test-name)
(format "eunit:test({%s, %s}%s)."
module-name test-name (erlang-eunit-opts)))
((erlang-eunit-test-generator-p test-name)
(format "eunit:test({generator, %s, %s}%s)."
module-name test-name (erlang-eunit-opts)))
(t (format "%% WARNING: '%s' is not a test function" test-name)))))
(erlang-eunit-record-recent 'test-mode module-name test-name)
(erlang-eunit-inferior-erlang-send-command command)))
;;; Run EUnit tests for the current module
(defun erlang-eunit-run-module-tests (module-name)
(let ((command (format "eunit:test(%s%s)." module-name (erlang-eunit-opts))))
(erlang-eunit-record-recent 'module-mode module-name nil)
(erlang-eunit-inferior-erlang-send-command command)))
(defun erlang-eunit-compile-and-run-recent ()
"Compile the source and test files and repeat the most recent EUnit test run.
With prefix arg, compiles for debug and runs tests with the verbose flag set."
(interactive)
(case (erlang-eunit-recent 'mode)
('test-mode
(erlang-eunit-compile-and-test
'erlang-eunit-run-test (list (erlang-eunit-recent 'module)
(erlang-eunit-recent 'test))))
('module-mode
(erlang-eunit-compile-and-test
'erlang-eunit-run-module-tests (list (erlang-eunit-recent 'module))
(erlang-eunit-recent 'cover)))
(t (error "EUnit has not yet been run. Please run a test first."))))
(defun erlang-eunit-cover-compile ()
"Cover compile current module."
(interactive)
(let* ((erlang-compile-extra-opts
(append (list 'debug_info) erlang-compile-extra-opts))
(module-name
(erlang-add-quotes-if-needed
(erlang-eunit-module-name buffer-file-name)))
(compile-command
(format "cover:compile_beam(%s)." module-name)))
(erlang-compile)
(if (erlang-eunit-last-compilation-successful-p)
(erlang-eunit-inferior-erlang-send-command compile-command))))
(defun erlang-eunit-analyze-coverage ()
"Analyze the data collected by cover tool for the module in the
current buffer.
Assumes that the module has been cover compiled prior to this
call. This function will do two things: print the number of
covered and uncovered functions in the erlang shell and display a
new buffer called *<module name> coverage* which shows the source
code along with the coverage analysis results."
(interactive)
(let* ((module-name (erlang-add-quotes-if-needed
(erlang-eunit-module-name buffer-file-name)))
(tmp-filename (make-temp-file "cover"))
(analyze-command (format "cover:analyze_to_file(%s, \"%s\"). "
module-name tmp-filename))
(buf-name (format "*%s coverage*" module-name)))
(erlang-eunit-inferior-erlang-send-command analyze-command)
;; The purpose of the following snippet is to get the result of the
;; analysis from a file into a new buffer (or an old, if one with
;; the specified name already exists). Also we want the erlang-mode
;; *and* view-mode to be enabled.
(save-excursion
(let ((buf (get-buffer-create (format "*%s coverage*" module-name))))
(set-buffer buf)
(setq buffer-read-only nil)
(insert-file-contents tmp-filename nil nil nil t)
(if (= (buffer-size) 0)
(kill-buffer buf)
;; FIXME: this would be a good place to enable (emacs-mode)
;; to get some nice syntax highlighting in the
;; coverage report, but it doesn't play well with
;; flymake. Leave it off for now.
(view-buffer buf))))
(delete-file tmp-filename)))
(defun erlang-eunit-compile-and-run-current-test ()
"Compile the source and test files and run the current EUnit test.
With prefix arg, compiles for debug and runs tests with the verbose flag set."
(interactive)
(let ((module-name (erlang-add-quotes-if-needed
(erlang-eunit-module-name buffer-file-name)))
(test-name (erlang-eunit-current-test)))
(erlang-eunit-compile-and-test
'erlang-eunit-run-test (list module-name test-name))))
(defun erlang-eunit-compile-and-run-module-tests ()
"Compile the source and test files and run all EUnit tests in the module.
With prefix arg, compiles for debug and runs tests with the verbose flag set."
(interactive)
(let ((module-name (erlang-add-quotes-if-needed
(erlang-eunit-source-module-name buffer-file-name))))
(erlang-eunit-compile-and-test
'erlang-eunit-run-module-tests (list module-name))))
;;; Compile source and EUnit test file and finally run EUnit tests for
;;; the current module
(defun erlang-eunit-compile-and-test (test-fun test-args &optional under-cover)
"Compile the source and test files and run the EUnit test suite.
If under-cover is set to t, the module under test is compile for
code coverage analysis. If under-cover is left out or not set,
coverage analysis is disabled. The result of the code coverage
is both printed to the erlang shell (the number of covered vs
uncovered functions in a module) and written to a buffer called
*<module> coverage* (which shows the source code for the module
and the number of times each line is covered).
With prefix arg, compiles for debug and runs tests with the verbose flag set."
(erlang-eunit-record-recent-compile under-cover)
(let ((src-filename (erlang-eunit-src-filename buffer-file-name))
(test-filename (erlang-eunit-test-filename buffer-file-name)))
;; The purpose of out-maneuvering `save-some-buffers', as is done
;; below, is to ask the question about saving buffers only once,
;; instead of possibly several: one for each file to compile,
;; for instance for both x.erl and x_tests.erl.
(save-some-buffers erlang-eunit-autosave)
(flet ((save-some-buffers (&optional any) nil))
;; Compilation of the source file is mandatory (the file must
;; exist, otherwise the procedure is aborted). Compilation of the
;; test file on the other hand, is optional, since eunit tests may
;; be placed in the source file instead. Any compilation error
;; will prevent the subsequent steps to be run (hence the `and')
(and (erlang-eunit-compile-file src-filename under-cover)
(if (file-readable-p test-filename)
(erlang-eunit-compile-file test-filename)
t)
(apply test-fun test-args)
(if under-cover
(save-excursion
(set-buffer (find-file-noselect src-filename))
(erlang-eunit-analyze-coverage)))))))
(defun erlang-eunit-compile-and-run-module-tests-under-cover ()
"Compile the source and test files and run the EUnit test suite and measure
code coverage.
With prefix arg, compiles for debug and runs tests with the verbose flag set."
(interactive)
(let ((module-name (erlang-add-quotes-if-needed
(erlang-eunit-source-module-name buffer-file-name))))
(erlang-eunit-compile-and-test
'erlang-eunit-run-module-tests (list module-name) t)))
(defun erlang-eunit-compile-file (file-path &optional under-cover)
(if (file-readable-p file-path)
(save-excursion
(set-buffer (find-file-noselect file-path))
;; In order to run a code coverage analysis on a
;; module, we have two options:
;;
;; * either compile the module with cover:compile instead of the
;; regular compiler
;;
;; * or first compile the module with the regular compiler (but
;; *with* debug_info) and then compile it for coverage
;; analysis using cover:compile_beam.
;;
;; We could accomplish the first by changing the
;; erlang-compile-erlang-function to cover:compile, but there's
;; a risk that that's used for other purposes. Therefore, a
;; safer alternative (although with more steps) is to add
;; debug_info to the list of compiler options and go for the
;; second alternative.
(if under-cover
(erlang-eunit-cover-compile)
(erlang-compile))
(erlang-eunit-last-compilation-successful-p))
(let ((msg (format "Could not read %s" file-path)))
(erlang-eunit-inferior-erlang-send-command
(format "%% WARNING: %s" msg))
(error msg))))
(defun erlang-eunit-last-compilation-successful-p ()
(save-excursion
(set-buffer inferior-erlang-buffer)
(goto-char compilation-parsing-end)
(erlang-eunit-all-list-elems-fulfill-p
(lambda (re) (let ((continue t)
(result t))
(while continue ; ignore warnings, stop at errors
(if (re-search-forward re (point-max) t)
(if (erlang-eunit-is-compilation-warning)
t
(setq result nil)
(setq continue nil))
(setq result t)
(setq continue nil)))
result))
(mapcar (lambda (e) (car e)) erlang-error-regexp-alist))))
(defun erlang-eunit-is-compilation-warning ()
(erlang-eunit-string-match-p
"[0-9]+: Warning:"
(buffer-substring (line-beginning-position) (line-end-position))))
(defun erlang-eunit-all-list-elems-fulfill-p (pred list)
(let ((matches-p t))
(while (and list matches-p)
(if (not (funcall pred (car list)))
(setq matches-p nil))
(setq list (cdr list)))
matches-p))
;;; Evaluate a command in an erlang buffer
(defun erlang-eunit-inferior-erlang-send-command (command)
"Evaluate a command in an erlang buffer."
(interactive "P")
(inferior-erlang-prepare-for-input)
(inferior-erlang-send-command command)
(sit-for 0) ;; redisplay
(inferior-erlang-wait-prompt))
;;;====================================================================
;;; Key bindings
;;;====================================================================
(defconst erlang-eunit-key-bindings
'(("\C-c\C-et" erlang-eunit-toggle-src-and-test-file-other-window)
("\C-c\C-ek" erlang-eunit-compile-and-run-module-tests)
("\C-c\C-ej" erlang-eunit-compile-and-run-current-test)
("\C-c\C-el" erlang-eunit-compile-and-run-recent)
("\C-c\C-ec" erlang-eunit-compile-and-run-module-tests-under-cover)
("\C-c\C-ev" erlang-eunit-cover-compile)
("\C-c\C-ea" erlang-eunit-analyze-coverage)))
(defun erlang-eunit-add-key-bindings ()
(dolist (binding erlang-eunit-key-bindings)
(erlang-eunit-bind-key (car binding) (cadr binding))))
(defun erlang-eunit-bind-key (key function)
(erlang-eunit-ensure-keymap-for-key key)
(local-set-key key function))
(defun erlang-eunit-ensure-keymap-for-key (key-seq)
(let ((prefix-keys (butlast (append key-seq nil)))
(prefix-seq ""))
(while prefix-keys
(setq prefix-seq (concat prefix-seq (make-string 1 (car prefix-keys))))
(setq prefix-keys (cdr prefix-keys))
(if (not (keymapp (lookup-key (current-local-map) prefix-seq)))
(local-set-key prefix-seq (make-sparse-keymap))))))
(add-hook 'erlang-mode-hook 'erlang-eunit-add-key-bindings)
(provide 'erlang-eunit)
;; erlang-eunit ends here

View File

@@ -1,102 +0,0 @@
;; erlang-flymake.el
;;
;; Syntax check erlang source code on the fly (integrates with flymake).
;;
;; Start using flymake with erlang by putting the following somewhere
;; in your .emacs file:
;;
;; (require 'erlang-flymake)
;;
;; Flymake is rather eager and does its syntax checks frequently by
;; default and if you are bothered by this, you might want to put the
;; following in your .emacs as well:
;;
;; (erlang-flymake-only-on-save)
;;
;; There are a couple of variables which control the compilation options:
;; * erlang-flymake-get-code-path-dirs-function
;; * erlang-flymake-get-include-dirs-function
;; * erlang-flymake-extra-opts
;;
;; This code is inspired by http://www.emacswiki.org/emacs/FlymakeErlang.
(require 'flymake)
(eval-when-compile
(require 'cl))
(defvar erlang-flymake-command
"erlc"
"The command that will be used to perform the syntax check")
(defvar erlang-flymake-get-code-path-dirs-function
'erlang-flymake-get-code-path-dirs
"Return a list of ebin directories to add to the code path.")
(defvar erlang-flymake-get-include-dirs-function
'erlang-flymake-get-include-dirs
"Return a list of include directories to add to the compiler options.")
(defvar erlang-flymake-extra-opts
(list "+warn_obsolete_guard"
"+warn_unused_import"
"+warn_shadow_vars"
"+warn_export_vars"
"+strong_validation"
"+report")
"A list of options that will be passed to the compiler")
(defun erlang-flymake-only-on-save ()
"Trigger flymake only when the buffer is saved (disables syntax
check on newline and when there are no changes)."
(interactive)
;; There doesn't seem to be a way of disabling this; set to the
;; largest int available as a workaround (most-positive-fixnum
;; equates to 8.5 years on my machine, so it ought to be enough ;-) )
(setq flymake-no-changes-timeout most-positive-fixnum)
(setq flymake-start-syntax-check-on-newline nil))
(defun erlang-flymake-get-code-path-dirs ()
(list (concat (erlang-flymake-get-app-dir) "ebin")))
(defun erlang-flymake-get-include-dirs ()
(list (concat (erlang-flymake-get-app-dir) "include")))
(defun erlang-flymake-get-app-dir ()
(let ((src-path (file-name-directory (buffer-file-name))))
(file-name-directory (directory-file-name src-path))))
(defun erlang-flymake-init ()
(let* ((temp-file
(flet ((flymake-get-temp-dir () (erlang-flymake-temp-dir)))
(flymake-init-create-temp-buffer-copy
'flymake-create-temp-with-folder-structure)))
(code-dir-opts
(erlang-flymake-flatten
(mapcar (lambda (dir) (list "-pa" dir))
(funcall erlang-flymake-get-code-path-dirs-function))))
(inc-dir-opts
(erlang-flymake-flatten
(mapcar (lambda (dir) (list "-I" dir))
(funcall erlang-flymake-get-include-dirs-function))))
(compile-opts
(append inc-dir-opts
code-dir-opts
erlang-flymake-extra-opts)))
(list erlang-flymake-command (append compile-opts (list temp-file)))))
(defun erlang-flymake-temp-dir ()
;; Squeeze the user's name in there in order to make sure that files
;; for two users who are working on the same computer (like a linux
;; box) don't collide
(format "%s/flymake-%s" temporary-file-directory user-login-name))
(defun erlang-flymake-flatten (list)
(apply #'append list))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.erl\\'" erlang-flymake-init))
(add-hook 'erlang-mode-hook 'flymake-mode)
(provide 'erlang-flymake)
;; erlang-flymake ends here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,121 +0,0 @@
;; erlang-start.el --- Load this file to initialize the Erlang package.
;; Copyright (C) 1998 Ericsson Telecom AB
;; Author: Anders Lindgren
;; Version: 2.3
;; Keywords: erlang, languages, processes
;; Created: 1996-09-18
;; Date: 1998-03-16
;;; Commentary:
;; Introduction:
;; ------------
;;
;; This package provides support for the programming language Erlang.
;; The package provides an editing mode with lots of bells and
;; whistles, compilation support, and it makes it possible for the
;; user to start Erlang shells that run inside Emacs.
;;
;; See the Erlang distribution for full documentation of this package.
;; Installation:
;; ------------
;;
;; Place this file in Emacs load path, byte-compile it, and add the
;; following line to the appropriate init file:
;;
;; (require 'erlang-start)
;;
;; The full documentation contains much more extensive description of
;; the installation procedure.
;; Reporting Bugs:
;; --------------
;;
;; Please send bug reports to the following email address:
;; support@erlang.ericsson.se
;;
;; Please state as exactly as possible:
;; - Version number of Erlang Mode (see the menu), Emacs, Erlang,
;; and of any other relevant software.
;; - What the expected result was.
;; - What you did, preferably in a repeatable step-by-step form.
;; - A description of the unexpected result.
;; - Relevant pieces of Erlang code causing the problem.
;; - Personal Emacs customisations, if any.
;;
;; Should the Emacs generate an error, please set the emacs variable
;; `debug-on-error' to `t'. Repeat the error and enclose the debug
;; information in your bug-report.
;;
;; To set the variable you can use the following command:
;; M-x set-variable RET debug-on-error RET t RET
;;; Code:
;;
;; Declare functions in "erlang.el".
;;
(autoload 'erlang-mode "erlang" "Major mode for editing Erlang code." t)
(autoload 'erlang-version "erlang"
"Return the current version of Erlang mode." t)
(autoload 'erlang-shell "erlang" "Start a new Erlang shell." t)
(autoload 'run-erlang "erlang" "Start a new Erlang shell." t)
(autoload 'erlang-compile "erlang"
"Compile Erlang module in current buffer." t)
(autoload 'erlang-man-module "erlang"
"Find manual page for MODULE." t)
(autoload 'erlang-man-function "erlang"
"Find manual page for NAME, where NAME is module:function." t)
(autoload 'erlang-find-tag "erlang"
"Like `find-tag'. Capable of retreiving Erlang modules.")
(autoload 'erlang-find-tag-other-window "erlang"
"Like `find-tag-other-window'. Capable of retreiving Erlang modules.")
;;
;; Associate files extensions ".erl" and ".hrl" with Erlang mode.
;;
(let ((a '("\\.erl\\'" . erlang-mode))
(b '("\\.hrl\\'" . erlang-mode)))
(or (assoc (car a) auto-mode-alist)
(setq auto-mode-alist (cons a auto-mode-alist)))
(or (assoc (car b) auto-mode-alist)
(setq auto-mode-alist (cons b auto-mode-alist))))
;;
;; Associate files using interpreter "escript" with Erlang mode.
;;
(add-to-list 'interpreter-mode-alist (cons "escript" 'erlang-mode))
;;
;; Ignore files ending in ".jam", ".vee", and ".beam" when performing
;; file completion.
;;
(let ((erl-ext '(".jam" ".vee" ".beam")))
(while erl-ext
(let ((cie completion-ignored-extensions))
(while (and cie (not (string-equal (car cie) (car erl-ext))))
(setq cie (cdr cie)))
(if (null cie)
(setq completion-ignored-extensions
(cons (car erl-ext) completion-ignored-extensions))))
(setq erl-ext (cdr erl-ext))))
;;
;; The end.
;;
(provide 'erlang-start)
;; erlang-start.el ends here.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,659 +0,0 @@
%% -*- erlang -*-
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2009-2010. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%%-------------------------------------------------------------------
%%% File : test.erl
%%% Author : Dan Gudmundsson <dan.gudmundsson@ericsson.com>
%%% Description : Test emacs mode indention and font-locking
%%% this file is intentionally not indented.
%%% Copy the file and indent it and you should end up with test.erl.indented
%%% Created : 6 Oct 2009 by Dan Gudmundsson <dan.gudmundsson@ericsson.com>
%%%-------------------------------------------------------------------
%% Start off with syntax highlighting you have to verify this by looking here
%% and see that the code looks alright
-module(test).
-compile(export_all).
%% Module attributes should be highlighted
-export([t/1]).
-record(record1, {a,
b,
c
}).
-record(record2, {
a,
b
}).
-record(record3, {a = 8#42423 bor
8#4234,
b = 8#5432
bor 2#1010101
c = 123 +
234,
d}).
-record(record4, {
a = 8#42423 bor
8#4234,
b = 8#5432
bor 2#1010101
c = 123 +
234,
d}).
-define(MACRO_1, macro).
-define(MACRO_2(_), macro).
-spec t(integer()) -> any().
-type ann() :: Var :: integer().
-type ann2() :: Var ::
'return'
| 'return_white_spaces'
| 'return_comments'
| 'text' | ann().
-type paren() ::
(ann2()).
-type t1() :: atom().
-type t2() :: [t1()].
-type t3(Atom) :: integer(Atom).
-type t4() :: t3(foobar).
-type t5() :: {t1(), t3(foo)}.
-type t6() :: 1 | 2 | 3 |
'foo' | 'bar'.
-type t7() :: [].
-type t71() :: [_].
-type t8() :: {any(),none(),pid(),port(),
reference(),float()}.
-type t9() :: [1|2|3|foo|bar] |
list(a | b | c) | t71().
-type t10() :: {1|2|3|foo|t9()} | {}.
-type t11() :: 1..2.
-type t13() :: maybe_improper_list(integer(), t11()).
-type t14() :: [erl_scan:foo() |
%% Should be highlighted
term() |
bool() |
byte() |
char() |
non_neg_integer() | nonempty_list() |
pos_integer() |
neg_integer() |
number() |
list() |
nonempty_improper_list() | nonempty_maybe_improper_list() |
maybe_improper_list() | string() | iolist() | byte() |
module() |
mfa() |
node() |
timeout() |
no_return() |
%% Should not be highlighted
nonempty_() | nonlist() |
erl_scan:bar(34, 92) | t13() | m:f(integer() | <<_:_*16>>)].
-type t15() :: {binary(),<<>>,<<_:34>>,<<_:_*42>>,
<<_:3,_:_*14>>,<<>>} | [<<>>|<<_:34>>|<<_:16>>|
<<_:3,_:_*1472>>|<<_:19,_:_*14>>| <<_:34>>|
<<_:34>>|<<_:34>>|<<_:34>>].
-type t16() :: fun().
-type t17() :: fun((...) -> paren()).
-type t18() :: fun(() -> t17() | t16()).
-type t19() :: fun((t18()) -> t16()) |
fun((nonempty_maybe_improper_list('integer', any())|
1|2|3|a|b|<<_:3,_:_*14>>|integer()) ->
nonempty_maybe_improper_list('integer', any())|
1|2|3|a|b|<<_:3,_:_*14>>|integer()).
-type t20() :: [t19(), ...].
-type t21() :: tuple().
-type t21(A) :: A.
-type t22() :: t21(integer()).
-type t23() :: #rec1{}.
-type t24() :: #rec2{a :: t23(), b :: [atom()]}.
-type t25() :: #rec3{f123 :: [t24() |
1|2|3|4|a|b|c|d|
nonempty_maybe_improper_list(integer, any())]}.
-type t99() ::
{t2(),t4(),t5(),t6(),t7(),t8(),t10(),t14(),
t15(),t20(),t21(), t22(),t25()}.
-spec t1(FooBar :: t99()) -> t99();
(t2()) -> t2();
(t4()) -> t4() when is_subtype(t4(), t24);
(t23()) -> t23() when is_subtype(t23(), atom()),
is_subtype(t23(), t14());
(t24()) -> t24() when is_subtype(t24(), atom()),
is_subtype(t24(), t14()),
is_subtype(t24(), t4()).
-spec over(I :: integer()) -> R1 :: foo:typen();
(A :: atom()) -> R2 :: foo:atomen();
(T :: tuple()) -> R3 :: bar:typen().
-spec mod:t2() -> any().
-spec handle_cast(Cast :: {'exchange', node(), [[name(),...]]}
| {'del_member', name(), pid()},
#state{}) -> {'noreply', #state{}}.
-spec handle_cast(Cast ::
{'exchange', node(), [[name(),...]]}
| {'del_member', name(), pid()},
#state{}) -> {'noreply', #state{}}.
-spec all(fun((T) -> boolean()), List :: [T]) ->
boolean() when is_subtype(T, term()). % (*)
-spec get_closest_pid(term()) ->
Return :: pid()
| {'error', {'no_process', term()}
| {'no_such_group', term()}}.
-opaque attributes_data() ::
[{'column', column()} | {'line', info_line()} |
{'text', string()}] | {line(),column()}.
-record(r,{
f1 :: attributes_data(),
f222 = foo:bar(34, #rec3{}, 234234234423,
aassdsfsdfsdf, 2234242323) ::
[t24() | 1|2|3|4|a|b|c|d|
nonempty_maybe_improper_list(integer, any())],
f333 :: [t24() | 1|2|3|4|a|b|c|d|
nonempty_maybe_improper_list(integer, any())],
f3 = x:y(),
f4 = x:z() :: t99(),
f17 :: 'undefined',
f18 :: 1 | 2 | 'undefined',
f19 = 3 :: integer()|undefined,
f5 = 3 :: undefined|integer()}).
-record(state, {
sequence_number = 1 :: integer()
}).
highlighting(X) % Function definitions should be highlighted
when is_integer(X) -> % and so should `when' and `is_integer' be
%% Highlighting
%% Various characters (we keep an `atom' after to see that highlighting ends)
$a,atom, % Characters should be marked
"string",atom, % and strings
'asdasd',atom, % quote should be atoms??
'VaV',atom,
'aVa',atom,
'\'atom',atom,
'atom\'',atom,
'at\'om',atom,
'#1',atom,
$", atom, % atom should be ok
$', atom,
"string$", atom, "string$", atom, % currently buggy I know...
"string\$", atom, % workaround for bug above
"char $in string", atom,
$[, ${, $\\, atom,
?MACRO_1,
?MACRO_2(foo),
%% Numerical constants
16#DD, % AD Should not be highlighted
32#dd, % AD Should not be highlighted
32#ddAB, % AD Should not be highlighted
32#101, % AD Should not be highlighted
32#ABTR, % AD Should not be highlighted
%% Variables
Variables = lists:foo(),
_Variables = lists:foo(), % AD
AppSpec = Xyz/2,
Module42 = Xyz(foo, bar),
Module:foo(),
_Module:foo(), % AD
FooÅÅ = lists:reverse([tl,hd,tl,hd]), % AD Should highlight FooÅÅ
_FooÅÅ = 42, % AD Should highlight _FooÅÅ
%% Bifs
erlang:registered(),
registered(),
hd(tl(tl(hd([a,b,c])))),
erlang:anything(lists),
%% Guards
is_atom(foo), is_float(2.3), is_integer(32), is_number(4323.3),
is_function(Fun), is_pid(self()),
not_a_guard:is_list([]),
%% Other Types
atom, % not (currently) hightlighted
234234,
234.43,
[list, are, not, higlighted],
{nor, is, tuple},
ok.
%%%
%%% Indentation
%%%
%%% Left
%% Indented
% Right
indent_basics(X, Y, Z)
when X > 42,
Z < 13;
Y =:= 4711 ->
%% comments
% right comments
case lists:filter(fun(_, AlongName,
B,
C) ->
true
end,
[a,v,b])
of
[] ->
Y = 5 * 43,
ok;
[_|_] ->
Y = 5 * 43,
ok
end,
Y,
%% List, tuples and binaries
[a,
b, c
],
[ a,
b, c
],
[
a,
b
],
{a,
b,c
},
{ a,
b,c
},
{
a,
b
},
<<1:8,
2:8
>>,
<<
1:8,
2:8
>>,
<< 1:8,
2:8
>>,
(a,
b,
c
),
( a,
b,
c
),
(
a,
b,
c
),
call(2#42423 bor
#4234,
2#5432,
other_arg),
ok;
indent_basics(Xlongname,
#struct{a=Foo,
b=Bar},
[X|
Y]) ->
testing_next_clause,
ok;
indent_basics( % AD added clause
X, % not sure how this should look
Y,
Z)
when
X < 42, Z > 13;
Y =:= 4711 ->
foo;
indent_basics(X, Y, Z) when % AD added clause
X < 42, Z > 13; % testing when indentation
Y =:= 4711 ->
foo;
indent_basics(X, Y, Z) % AD added clause
when % testing when indentation
X < 42, Z > 13; % unsure about this one
Y =:= 4711 ->
foo.
indent_nested() ->
[
{foo, 2, "string"},
{bar, 3, "another string"}
].
indent_icr(Z) -> % icr = if case receive
%% If
if Z >= 0 ->
X = 43 div 4,
foo(X);
Z =< 10 ->
X = 43 div 4,
foo(X);
Z == 5 orelse
Z == 7 ->
X = 43 div 4,
foo(X);
true ->
if_works
end,
%% Case
case {Z, foo, bar} of
{Z,_,_} ->
X = 43 div 4,
foo(X);
{Z,_,_} when
Z =:= 42 -> % AD line should be indented as a when
X = 43 div 4,
foo(X);
{Z,_,_}
when Z < 10 -> % AD when should be indented
X = 43 div 4,
foo(X);
{Z,_,_}
when % AD when should be indented
Z < 10 % and the guards should follow when
andalso % unsure about how though
true ->
X = 43 div 4,
foo(X)
end,
%% begin
begin
sune,
X = 74234 + foo(8456) +
345 div 43,
ok
end,
%% receive
receive
{Z,_,_} ->
X = 43 div 4,
foo(X);
Z ->
X = 43 div 4,
foo(X)
end,
receive
{Z,_,_} ->
X = 43 div 4,
foo(X);
Z % AD added clause
when Z =:= 1 -> % This line should be indented by 2
X = 43 div 4,
foo(X);
Z when % AD added clause
Z =:= 2 -> % This line should be indented by 2
X = 43 div 4,
foo(X);
Z ->
X = 43 div 4,
foo(X)
after infinity ->
foo(X),
asd(X),
5*43
end,
receive
after 10 ->
foo(X),
asd(X),
5*43
end,
ok.
indent_fun() ->
%% Changed fun to one indention level
Var = spawn(fun(X)
when X == 2;
X > 10 ->
hello,
case Hello() of
true when is_atom(X) ->
foo;
false ->
bar
end;
(Foo) when is_atom(Foo),
is_integer(X) ->
X = 6* 45,
Y = true andalso
kalle
end),
ok.
indent_try_catch() ->
try
io:format(stdout, "Parsing file ~s, ",
[St0#leex.xfile]),
{ok,Line3,REAs,Actions,St3} =
parse_rules(Xfile, Line2, Macs, St2)
catch
exit:{badarg,R} ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R);
error:R % AD added clause
when R =:= 42 -> % when should be indented
foo(R);
error:R % AD added clause
when % when should be indented
R =:= 42 -> % but unsure about this (maybe 2 more)
foo(R);
error:R when % AD added clause
R =:= foo -> % line should be 2 indented (works)
foo(R);
error:R ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R)
after
foo('after'),
file:close(Xfile)
end;
indent_try_catch() ->
try
foo(bar)
of
X when true andalso
kalle ->
io:format(stdout, "Parsing file ~s, ",
[St0#leex.xfile]),
{ok,Line3,REAs,Actions,St3} =
parse_rules(Xfile, Line2, Macs, St2);
X % AD added clause
when false andalso % when should be 2 indented
bengt ->
gurka();
X when % AD added clause
false andalso % line should be 2 indented
not bengt ->
gurka();
X ->
io:format(stdout, "Parsing file ~s, ",
[St0#leex.xfile]),
{ok,Line3,REAs,Actions,St3} =
parse_rules(Xfile, Line2, Macs, St2)
catch
exit:{badarg,R} ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R);
error:R ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R)
after
foo('after'),
file:close(Xfile),
bar(with_long_arg,
with_second_arg)
end;
indent_try_catch() ->
try foo()
after
foo(),
bar(with_long_arg,
with_second_arg)
end.
indent_catch() ->
D = B +
float(43.1),
B = catch oskar(X),
A = catch (baz +
bax),
catch foo(),
C = catch B +
float(43.1),
case catch foo(X) of
A ->
B
end,
case
catch foo(X)
of
A ->
B
end,
case
foo(X)
of
A ->
catch B,
X
end,
try sune of
_ -> foo
catch _:_ -> baf
end,
try
sune
of
_ ->
X = 5,
(catch foo(X)),
X + 10
catch _:_ -> baf
end,
try
(catch sune)
of
_ ->
catch foo() %% BUGBUG can't handle catch inside try without parentheses
catch _:_ ->
baf
end,
try
(catch exit())
catch
_ ->
catch baf()
end,
ok.
indent_binary() ->
X = lists:foldr(fun(M) ->
<<Ma/binary, " ">>
end, [], A),
A = <<X/binary, 0:8>>,
B.
indent_comprehensions() ->
%% I don't have a good idea how we want to handle this
%% but they are here to show how they are indented today.
Result1 = [X ||
#record{a=X} <- lists:seq(1, 10),
true = (X rem 2)
],
Result2 = [X || <<X:32,_:32>> <= <<0:512>>,
true = (X rem 2)
],
Binary1 = << <<X:8>> ||
#record{a=X} <- lists:seq(1, 10),
true = (X rem 2)
>>,
Binary2 = << <<X:8>> || <<X:32,_:32>> <= <<0:512>>,
true = (X rem 2)
>>,
ok.
%% This causes an error in earlier erlang-mode versions.
foo() ->
[#foo{
foo = foo}].

View File

@@ -1,659 +0,0 @@
%% -*- erlang -*-
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2009-2010. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%%-------------------------------------------------------------------
%%% File : test.erl
%%% Author : Dan Gudmundsson <dan.gudmundsson@ericsson.com>
%%% Description : Test emacs mode indention and font-locking
%%% this file is intentionally not indented.
%%% Copy the file and indent it and you should end up with test.erl.indented
%%% Created : 6 Oct 2009 by Dan Gudmundsson <dan.gudmundsson@ericsson.com>
%%%-------------------------------------------------------------------
%% Start off with syntax highlighting you have to verify this by looking here
%% and see that the code looks alright
-module(test).
-compile(export_all).
%% Module attributes should be highlighted
-export([t/1]).
-record(record1, {a,
b,
c
}).
-record(record2, {
a,
b
}).
-record(record3, {a = 8#42423 bor
8#4234,
b = 8#5432
bor 2#1010101
c = 123 +
234,
d}).
-record(record4, {
a = 8#42423 bor
8#4234,
b = 8#5432
bor 2#1010101
c = 123 +
234,
d}).
-define(MACRO_1, macro).
-define(MACRO_2(_), macro).
-spec t(integer()) -> any().
-type ann() :: Var :: integer().
-type ann2() :: Var ::
'return'
| 'return_white_spaces'
| 'return_comments'
| 'text' | ann().
-type paren() ::
(ann2()).
-type t1() :: atom().
-type t2() :: [t1()].
-type t3(Atom) :: integer(Atom).
-type t4() :: t3(foobar).
-type t5() :: {t1(), t3(foo)}.
-type t6() :: 1 | 2 | 3 |
'foo' | 'bar'.
-type t7() :: [].
-type t71() :: [_].
-type t8() :: {any(),none(),pid(),port(),
reference(),float()}.
-type t9() :: [1|2|3|foo|bar] |
list(a | b | c) | t71().
-type t10() :: {1|2|3|foo|t9()} | {}.
-type t11() :: 1..2.
-type t13() :: maybe_improper_list(integer(), t11()).
-type t14() :: [erl_scan:foo() |
%% Should be highlighted
term() |
bool() |
byte() |
char() |
non_neg_integer() | nonempty_list() |
pos_integer() |
neg_integer() |
number() |
list() |
nonempty_improper_list() | nonempty_maybe_improper_list() |
maybe_improper_list() | string() | iolist() | byte() |
module() |
mfa() |
node() |
timeout() |
no_return() |
%% Should not be highlighted
nonempty_() | nonlist() |
erl_scan:bar(34, 92) | t13() | m:f(integer() | <<_:_*16>>)].
-type t15() :: {binary(),<<>>,<<_:34>>,<<_:_*42>>,
<<_:3,_:_*14>>,<<>>} | [<<>>|<<_:34>>|<<_:16>>|
<<_:3,_:_*1472>>|<<_:19,_:_*14>>| <<_:34>>|
<<_:34>>|<<_:34>>|<<_:34>>].
-type t16() :: fun().
-type t17() :: fun((...) -> paren()).
-type t18() :: fun(() -> t17() | t16()).
-type t19() :: fun((t18()) -> t16()) |
fun((nonempty_maybe_improper_list('integer', any())|
1|2|3|a|b|<<_:3,_:_*14>>|integer()) ->
nonempty_maybe_improper_list('integer', any())|
1|2|3|a|b|<<_:3,_:_*14>>|integer()).
-type t20() :: [t19(), ...].
-type t21() :: tuple().
-type t21(A) :: A.
-type t22() :: t21(integer()).
-type t23() :: #rec1{}.
-type t24() :: #rec2{a :: t23(), b :: [atom()]}.
-type t25() :: #rec3{f123 :: [t24() |
1|2|3|4|a|b|c|d|
nonempty_maybe_improper_list(integer, any())]}.
-type t99() ::
{t2(),t4(),t5(),t6(),t7(),t8(),t10(),t14(),
t15(),t20(),t21(), t22(),t25()}.
-spec t1(FooBar :: t99()) -> t99();
(t2()) -> t2();
(t4()) -> t4() when is_subtype(t4(), t24);
(t23()) -> t23() when is_subtype(t23(), atom()),
is_subtype(t23(), t14());
(t24()) -> t24() when is_subtype(t24(), atom()),
is_subtype(t24(), t14()),
is_subtype(t24(), t4()).
-spec over(I :: integer()) -> R1 :: foo:typen();
(A :: atom()) -> R2 :: foo:atomen();
(T :: tuple()) -> R3 :: bar:typen().
-spec mod:t2() -> any().
-spec handle_cast(Cast :: {'exchange', node(), [[name(),...]]}
| {'del_member', name(), pid()},
#state{}) -> {'noreply', #state{}}.
-spec handle_cast(Cast ::
{'exchange', node(), [[name(),...]]}
| {'del_member', name(), pid()},
#state{}) -> {'noreply', #state{}}.
-spec all(fun((T) -> boolean()), List :: [T]) ->
boolean() when is_subtype(T, term()). % (*)
-spec get_closest_pid(term()) ->
Return :: pid()
| {'error', {'no_process', term()}
| {'no_such_group', term()}}.
-opaque attributes_data() ::
[{'column', column()} | {'line', info_line()} |
{'text', string()}] | {line(),column()}.
-record(r,{
f1 :: attributes_data(),
f222 = foo:bar(34, #rec3{}, 234234234423,
aassdsfsdfsdf, 2234242323) ::
[t24() | 1|2|3|4|a|b|c|d|
nonempty_maybe_improper_list(integer, any())],
f333 :: [t24() | 1|2|3|4|a|b|c|d|
nonempty_maybe_improper_list(integer, any())],
f3 = x:y(),
f4 = x:z() :: t99(),
f17 :: 'undefined',
f18 :: 1 | 2 | 'undefined',
f19 = 3 :: integer()|undefined,
f5 = 3 :: undefined|integer()}).
-record(state, {
sequence_number = 1 :: integer()
}).
highlighting(X) % Function definitions should be highlighted
when is_integer(X) -> % and so should `when' and `is_integer' be
%% Highlighting
%% Various characters (we keep an `atom' after to see that highlighting ends)
$a,atom, % Characters should be marked
"string",atom, % and strings
'asdasd',atom, % quote should be atoms??
'VaV',atom,
'aVa',atom,
'\'atom',atom,
'atom\'',atom,
'at\'om',atom,
'#1',atom,
$", atom, % atom should be ok
$', atom,
"string$", atom, "string$", atom, % currently buggy I know...
"string\$", atom, % workaround for bug above
"char $in string", atom,
$[, ${, $\\, atom,
?MACRO_1,
?MACRO_2(foo),
%% Numerical constants
16#DD, % AD Should not be highlighted
32#dd, % AD Should not be highlighted
32#ddAB, % AD Should not be highlighted
32#101, % AD Should not be highlighted
32#ABTR, % AD Should not be highlighted
%% Variables
Variables = lists:foo(),
_Variables = lists:foo(), % AD
AppSpec = Xyz/2,
Module42 = Xyz(foo, bar),
Module:foo(),
_Module:foo(), % AD
FooÅÅ = lists:reverse([tl,hd,tl,hd]), % AD Should highlight FooÅÅ
_FooÅÅ = 42, % AD Should highlight _FooÅÅ
%% Bifs
erlang:registered(),
registered(),
hd(tl(tl(hd([a,b,c])))),
erlang:anything(lists),
%% Guards
is_atom(foo), is_float(2.3), is_integer(32), is_number(4323.3),
is_function(Fun), is_pid(self()),
not_a_guard:is_list([]),
%% Other Types
atom, % not (currently) hightlighted
234234,
234.43,
[list, are, not, higlighted],
{nor, is, tuple},
ok.
%%%
%%% Indentation
%%%
%%% Left
%% Indented
% Right
indent_basics(X, Y, Z)
when X > 42,
Z < 13;
Y =:= 4711 ->
%% comments
% right comments
case lists:filter(fun(_, AlongName,
B,
C) ->
true
end,
[a,v,b])
of
[] ->
Y = 5 * 43,
ok;
[_|_] ->
Y = 5 * 43,
ok
end,
Y,
%% List, tuples and binaries
[a,
b, c
],
[ a,
b, c
],
[
a,
b
],
{a,
b,c
},
{ a,
b,c
},
{
a,
b
},
<<1:8,
2:8
>>,
<<
1:8,
2:8
>>,
<< 1:8,
2:8
>>,
(a,
b,
c
),
( a,
b,
c
),
(
a,
b,
c
),
call(2#42423 bor
#4234,
2#5432,
other_arg),
ok;
indent_basics(Xlongname,
#struct{a=Foo,
b=Bar},
[X|
Y]) ->
testing_next_clause,
ok;
indent_basics( % AD added clause
X, % not sure how this should look
Y,
Z)
when
X < 42, Z > 13;
Y =:= 4711 ->
foo;
indent_basics(X, Y, Z) when % AD added clause
X < 42, Z > 13; % testing when indentation
Y =:= 4711 ->
foo;
indent_basics(X, Y, Z) % AD added clause
when % testing when indentation
X < 42, Z > 13; % unsure about this one
Y =:= 4711 ->
foo.
indent_nested() ->
[
{foo, 2, "string"},
{bar, 3, "another string"}
].
indent_icr(Z) -> % icr = if case receive
%% If
if Z >= 0 ->
X = 43 div 4,
foo(X);
Z =< 10 ->
X = 43 div 4,
foo(X);
Z == 5 orelse
Z == 7 ->
X = 43 div 4,
foo(X);
true ->
if_works
end,
%% Case
case {Z, foo, bar} of
{Z,_,_} ->
X = 43 div 4,
foo(X);
{Z,_,_} when
Z =:= 42 -> % AD line should be indented as a when
X = 43 div 4,
foo(X);
{Z,_,_}
when Z < 10 -> % AD when should be indented
X = 43 div 4,
foo(X);
{Z,_,_}
when % AD when should be indented
Z < 10 % and the guards should follow when
andalso % unsure about how though
true ->
X = 43 div 4,
foo(X)
end,
%% begin
begin
sune,
X = 74234 + foo(8456) +
345 div 43,
ok
end,
%% receive
receive
{Z,_,_} ->
X = 43 div 4,
foo(X);
Z ->
X = 43 div 4,
foo(X)
end,
receive
{Z,_,_} ->
X = 43 div 4,
foo(X);
Z % AD added clause
when Z =:= 1 -> % This line should be indented by 2
X = 43 div 4,
foo(X);
Z when % AD added clause
Z =:= 2 -> % This line should be indented by 2
X = 43 div 4,
foo(X);
Z ->
X = 43 div 4,
foo(X)
after infinity ->
foo(X),
asd(X),
5*43
end,
receive
after 10 ->
foo(X),
asd(X),
5*43
end,
ok.
indent_fun() ->
%% Changed fun to one indention level
Var = spawn(fun(X)
when X == 2;
X > 10 ->
hello,
case Hello() of
true when is_atom(X) ->
foo;
false ->
bar
end;
(Foo) when is_atom(Foo),
is_integer(X) ->
X = 6* 45,
Y = true andalso
kalle
end),
ok.
indent_try_catch() ->
try
io:format(stdout, "Parsing file ~s, ",
[St0#leex.xfile]),
{ok,Line3,REAs,Actions,St3} =
parse_rules(Xfile, Line2, Macs, St2)
catch
exit:{badarg,R} ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R);
error:R % AD added clause
when R =:= 42 -> % when should be indented
foo(R);
error:R % AD added clause
when % when should be indented
R =:= 42 -> % but unsure about this (maybe 2 more)
foo(R);
error:R when % AD added clause
R =:= foo -> % line should be 2 indented (works)
foo(R);
error:R ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R)
after
foo('after'),
file:close(Xfile)
end;
indent_try_catch() ->
try
foo(bar)
of
X when true andalso
kalle ->
io:format(stdout, "Parsing file ~s, ",
[St0#leex.xfile]),
{ok,Line3,REAs,Actions,St3} =
parse_rules(Xfile, Line2, Macs, St2);
X % AD added clause
when false andalso % when should be 2 indented
bengt ->
gurka();
X when % AD added clause
false andalso % line should be 2 indented
not bengt ->
gurka();
X ->
io:format(stdout, "Parsing file ~s, ",
[St0#leex.xfile]),
{ok,Line3,REAs,Actions,St3} =
parse_rules(Xfile, Line2, Macs, St2)
catch
exit:{badarg,R} ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R);
error:R ->
foo(R),
io:format(stdout,
"ERROR reason ~p~n",
R)
after
foo('after'),
file:close(Xfile),
bar(with_long_arg,
with_second_arg)
end;
indent_try_catch() ->
try foo()
after
foo(),
bar(with_long_arg,
with_second_arg)
end.
indent_catch() ->
D = B +
float(43.1),
B = catch oskar(X),
A = catch (baz +
bax),
catch foo(),
C = catch B +
float(43.1),
case catch foo(X) of
A ->
B
end,
case
catch foo(X)
of
A ->
B
end,
case
foo(X)
of
A ->
catch B,
X
end,
try sune of
_ -> foo
catch _:_ -> baf
end,
try
sune
of
_ ->
X = 5,
(catch foo(X)),
X + 10
catch _:_ -> baf
end,
try
(catch sune)
of
_ ->
catch foo() %% BUGBUG can't handle catch inside try without parentheses
catch _:_ ->
baf
end,
try
(catch exit())
catch
_ ->
catch baf()
end,
ok.
indent_binary() ->
X = lists:foldr(fun(M) ->
<<Ma/binary, " ">>
end, [], A),
A = <<X/binary, 0:8>>,
B.
indent_comprehensions() ->
%% I don't have a good idea how we want to handle this
%% but they are here to show how they are indented today.
Result1 = [X ||
#record{a=X} <- lists:seq(1, 10),
true = (X rem 2)
],
Result2 = [X || <<X:32,_:32>> <= <<0:512>>,
true = (X rem 2)
],
Binary1 = << <<X:8>> ||
#record{a=X} <- lists:seq(1, 10),
true = (X rem 2)
>>,
Binary2 = << <<X:8>> || <<X:32,_:32>> <= <<0:512>>,
true = (X rem 2)
>>,
ok.
%% This causes an error in earlier erlang-mode versions.
foo() ->
[#foo{
foo = foo}].

View File

@@ -1,13 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.feature" . feature-mode))
(defun customizations-for-feature-mode ()
(interactive)
(setq whitespace-action (quote (auto-cleanup)))
(flyspell-mode)
(linum-mode t)
(fci-mode)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'feature-mode-hook 'customizations-for-feature-mode)

View File

@@ -1,10 +0,0 @@
;; Write commit messages in style
(defun customizations-for-git-commit-mode ()
(interactive)
(flyspell-mode)
(linum-mode t)
(auto-fill-mode)
(subword-mode)
(fci-mode))
(add-hook 'git-commit-mode-hook 'customizations-for-git-commit-mode)

View File

@@ -1,18 +0,0 @@
(defun customizations-for-go-mode ()
(interactive)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(whitespace-mode)
(subword-mode)
(setq tab-width 4)
(define-key go-mode-map (kbd "RET") 'newline-and-indent)
)
(add-hook 'go-mode-hook 'customizations-for-go-mode)
(setq gofmt-command "goimports")
(add-hook 'before-save-hook #'gofmt-before-save)

View File

@@ -1,15 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.hamlc\\'" . haml-mode))
(defun customizations-for-haml-mode ()
(interactive)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(auto-complete-mode)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'haml-mode-hook 'customizations-for-haml-mode)

View File

@@ -1,13 +0,0 @@
;; (add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
;; (add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode))
(defun customizations-for-html-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode))
(add-hook 'html-mode-hook 'customizations-for-html-mode)

View File

@@ -1,15 +0,0 @@
(defun customizations-for-js-mode ()
(interactive)
(setq js-indent-level 2)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode))
(add-hook 'js-mode-hook 'customizations-for-js-mode)

View File

@@ -1,10 +0,0 @@
(defun customizations-for-lisp-mode ()
(interactive)
(setq whitespace-action (quote (auto-cleanup)))
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode))
(add-hook 'lisp-mode-hook 'customizations-for-lisp-mode)

View File

@@ -1,6 +0,0 @@
;; Make Magit look a bit prettier with my theme
(defun customizations-for-magit-mode ()
(interactive)
(linum-mode t))
(add-hook 'magit-mode-hook 'customizations-for-magit-mode)

View File

@@ -1,12 +0,0 @@
(defun customizations-for-makefile-mode ()
(interactive)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(auto-complete-mode)
(subword-mode)
(setq tab-width 4)
(highlight-indentation-mode))
(add-hook 'makefile-mode-hook 'customizations-for-makefile-mode)

View File

@@ -1,18 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))
(defun customizations-for-php-mode ()
(interactive)
(setq whitespace-action (quote (auto-cleanup)))
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(setq php-basic-offset 2)
(setq tab-width 4)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'php-mode-hook 'customizations-for-php-mode)

View File

@@ -1,16 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))
(defun customizations-for-puppet-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(auto-complete-mode)
(whitespace-mode)
(subword-mode)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'puppet-mode-hook 'customizations-for-puppet-mode)

View File

@@ -1,14 +0,0 @@
(defun customizations-for-python-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(setq tab-width 4)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(define-key python-mode-map (kbd "RET") 'newline-and-indent))
(add-hook 'python-mode-hook 'customizations-for-python-mode)

View File

@@ -1,12 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.erb$" . rhtml-mode))
(defun customizations-for-rhtml-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode))
(add-hook 'rhtml-mode-hook 'customizations-for-rhtml-mode)

View File

@@ -1,94 +0,0 @@
(autoload 'ruby-mode "ruby-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rabl\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.jbuilder\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.prawn\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Cheffile" . ruby-mode))
(add-to-list 'auto-mode-alist '("Berksfile" . ruby-mode))
(defun customizations-for-ruby-mode ()
(interactive)
(when (require 'ruby-compilation nil 'noerror)
(define-key ruby-mode-map (kbd "s-r") 'ruby-compilation-this-buffer)
(define-key ruby-mode-map (kbd "C-c C-r") 'ruby-compilation-this-buffer))
(when (require 'auto-complete nil 'noerror)
(auto-complete-mode))
(when (require 'rsense nil 'noerror)
(add-to-list 'ac-sources 'ac-source-rsense-method)
(add-to-list 'ac-sources 'ac-source-rsense-constant)
(define-key ruby-mode-map (kbd "C-c C-.") 'ac-complete-rsense))
(when (require 'projectile nil 'noerror)
(define-key ruby-mode-map (kbd "C-x t") 'projectile-find-test-file)
(define-key inf-ruby-minor-mode-map (kbd "C-c C-b") 'projectile-ibuffer)
(define-key inf-ruby-minor-mode-map (kbd "C-c C-s")
'projectile-switch-project))
(linum-mode t)
(fci-mode)
(flyspell-prog-mode)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(hs-minor-mode 1)
(flycheck-mode)
(subword-mode)
(setq ruby-deep-arglist nil)
(setq ruby-deep-indent-paren nil)
(setq c-tab-always-indent nil)
(setq ruby-use-encoding-map nil)
(setq whitespace-action (quote (auto-cleanup)))
(define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
(define-key ruby-mode-map (kbd "C-c C-h") 'toggle-hiding)
(define-key ruby-mode-map (kbd "C-c C-l") 'goto-line)
)
(add-hook 'ruby-mode-hook 'customizations-for-ruby-mode)
;; Set up hs-mode (HideShow) for Ruby
(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do")) ; Block start
,(rx (or "end")) ; Block end
,(rx (or "#" "=begin")) ; Comment start
ruby-forward-sexp nil))
;; Workaround for missing method in ruby-mode.el
;; See: https://gist.github.com/1213051
(defun ruby-insert-end ()
"Insert \"end\" at point and reindent current line."
(interactive)
(insert "end")
(ruby-indent-line t)
(end-of-line))
;; Auto-complete when indenting
(defadvice ruby-indent-command (around ac-before-ruby-indent activate)
"Call `auto-complete' if text was recently entered"
(if (ac-trigger-command-p last-command)
(auto-complete)
ad-do-it))
;; Yasnippet workaround for ruby-electric-mode
;; See: http://code.google.com/p/yasnippet/issues/detail?id=71
(defun yas/advise-indent-function (function-symbol)
(eval `(defadvice ,function-symbol (around yas/try-expand-first activate)
,(format
"Try to expand a snippet before point, then call `%s' as usual"
function-symbol)
(let ((yas/fallback-behavior nil))
(unless (and (interactive-p)
(yas/expand))
ad-do-it)))))
(yas/advise-indent-function 'ruby-indent-line)
(yas/advise-indent-function 'ruby-indent-command)

View File

@@ -1,13 +0,0 @@
(defun customizations-for-sass-mode ()
(interactive)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(auto-complete-mode)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'sass-mode-hook 'customizations-for-sass-mode)

View File

@@ -1,24 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.bash\\'" . sh-mode))
(add-to-list 'auto-mode-alist '("\\.zsh\\'" . sh-mode))
(add-to-list 'auto-mode-alist '("\\.tcsh\\'" . sh-mode))
(add-to-list 'auto-mode-alist '("\\.tmuxtheme\\'" . sh-mode))
(defun customizations-for-sh-mode ()
(interactive)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(whitespace-mode)
(subword-mode)
(setq sh-basic-offset 2)
(setq sh-indentation 2)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(setq whitespace-action (quote (auto-cleanup)))
(highlight-indentation-mode)
(define-key sh-mode-map (kbd "RET") 'reindent-then-newline-and-indent))
(add-hook 'sh-mode-hook 'customizations-for-sh-mode)

View File

@@ -1,11 +0,0 @@
(defun customizations-for-slim-mode ()
(interactive)
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(add-hook 'slim-mode-hook 'customizations-for-slim-mode)

View File

@@ -1,18 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yml\\.example$" . yaml-mode))
(defun customizations-for-yaml-mode ()
(interactive)
(flyspell-prog-mode)
(flycheck-mode)
(linum-mode t)
(fci-mode)
(auto-complete-mode)
(subword-mode)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(define-key yaml-mode-map (kbd "RET") 'newline-and-indent))
(add-hook 'yaml-mode-hook 'customizations-for-yaml-mode)

View File

@@ -9,7 +9,6 @@
(defalias 'sl 'sort-lines)
(defalias 'rr 'reverse-region)
(defalias 'wc 'whitespace-cleanup)
(defalias 'rw 'sp-rewrap-sexp)
(defalias 'lml 'list-matching-lines)
(defalias 'dml 'delete-matching-lines)
@@ -32,5 +31,5 @@
;; Modes
(defalias 'sh 'shell-script-mode)
;; Magit
(defalias 'bl 'magit-blame-mode)
(provide 'siren-aliases)

View File

@@ -0,0 +1,32 @@
;;
;; auto-complete
;;
(siren-require-packages '(auto-complete))
(require 'auto-complete)
;; (require 'auto-complete-config)
;; (ac-config-default)
(ac-flyspell-workaround)
(setq ac-auto-show-menu 0.2)
(setq ac-auto-start 3)
(setq ac-delay 0.05)
(setq ac-menu-height 15)
(let ((map ac-completing-map))
(define-key map (kbd "RET") 'ac-complete)
(define-key map (kbd "C-m") 'ac-complete)
(define-key map (kbd "C-s") 'ac-isearch)
(define-key map (kbd "C-n") 'ac-next)
(define-key map (kbd "C-p") 'ac-previous))
;; Auto-complete when indenting.
(defadvice indent-for-tab-command (around ac-before-indent activate)
"Call `auto-complete' if text was recently entered"
(if (ac-trigger-command-p last-command)
(auto-complete)
ad-do-it))
(provide 'siren-auto-complete)

18
modules/siren-avy.el Normal file
View File

@@ -0,0 +1,18 @@
;;
;; avy allows us to effectively navigate to visible things
;;
(siren-require-packages '(ace-window avy))
(require 'avy)
(require 'ace-window)
(setq avy-background t
avy-style 'at-full)
(define-key global-map (kbd "C-c C-j") 'avy-goto-word-or-subword-1)
(define-key global-map (kbd "C-c SPC") 'avy-goto-char)
(define-key global-map (kbd "M-o") 'ace-window)
(provide 'siren-avy)

36
modules/siren-coffee.el Normal file
View File

@@ -0,0 +1,36 @@
;;
;; coffeescript
;;
(require 'siren-programming)
(eval-after-load 'coffee-mode
'(progn
(siren-require-packages '(coffee-mode))
(setq coffee-tab-width 2)
;; remove the "Generated by CoffeeScript" header
(add-to-list 'coffee-args-compile "--no-header")
(defun siren-coffee-mode-defaults ()
(siren-prog-mode-defaults)
;; Update the already compiled js on save
(and (buffer-file-name)
(file-exists-p (buffer-file-name))
(file-exists-p (coffee-compiled-file-name (buffer-file-name)))
(coffee-cos-mode t))
(setq tab-width 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(subword-mode +1))
(setq siren-coffee-mode-hook 'siren-coffee-mode-defaults)
(add-hook 'coffee-mode-hook (lambda ()
(run-hooks 'siren-coffee-mode-hook)))))
(provide 'siren-coffee)

40
modules/siren-company.el Normal file
View File

@@ -0,0 +1,40 @@
;;
;; company
;;
(siren-require-packages '(company))
(require 'company)
(setq company-idle-delay 0.5
company-tooltip-limit 10
company-minimum-prefix-length 2)
;; invert the navigation direction if the the completion popup-isearch-match
;; is displayed on top (happens near the bottom of windows)
(setq company-tooltip-flip-when-above t)
(global-company-mode 1)
;; Trigger completion popup by pressing tab
;; - from: https://github.com/company-mode/company-mode/issues/94#issuecomment-40884387
(define-key company-mode-map [remap indent-for-tab-command]
'company-indent-for-tab-command)
(setq tab-always-indent 'complete)
(defvar completion-at-point-functions-saved nil)
(defun company-indent-for-tab-command (&optional arg)
(interactive "P")
(let ((completion-at-point-functions-saved completion-at-point-functions)
(completion-at-point-functions '(company-complete-common-wrapper)))
(indent-for-tab-command arg)))
(defun company-complete-common-wrapper ()
(let ((completion-at-point-functions completion-at-point-functions-saved))
(company-complete-common)))
(provide 'siren-company)

27
modules/siren-css.el Normal file
View File

@@ -0,0 +1,27 @@
;;
;; css
;;
(require 'siren-programming)
(eval-after-load 'css-mode
'(progn
(siren-require-packages '(rainbow-mode))
(setq css-indent-offset 2)
(defun siren-css-mode-defaults ()
(siren-prog-mode-defaults)
(rainbow-mode +1)
(setq tab-width 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(run-hooks 'siren-prog-mode-hook))
(setq siren-css-mode-hook 'siren-css-mode-defaults)
(add-hook 'css-mode-hook (lambda ()
(run-hooks 'siren-css-mode-hook)))))
(provide 'siren-css)

22
modules/siren-cucumber.el Normal file
View File

@@ -0,0 +1,22 @@
;;
;; feature
;;
(require 'siren-programming)
(siren-require-packages '(feature-mode))
(defun siren-feature-mode-defaults ()
(siren-prog-mode-defaults)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(setq siren-feature-mode-hook 'siren-feature-mode-defaults)
(add-hook 'feature-mode-hook (lambda ()
(run-hooks 'siren-feature-mode-hook)))
(provide 'siren-cucumber)

19
modules/siren-dired.el Normal file
View File

@@ -0,0 +1,19 @@
;;
;; dired
;;
(siren-require-packages '(dired+))
(require 'dired+)
(defun siren-dired-mode-defaults ()
(linum-mode t)
(define-key dired-mode-map (kbd "c") 'dired-create-directory)
(toggle-diredp-find-file-reuse-dir 1))
(setq siren-dired-mode-hook 'siren-dired-mode-defaults)
(add-hook 'dired-mode-hook (lambda ()
(run-hooks 'siren-dired-mode-hook)))
(provide 'siren-dired)

31
modules/siren-ecb.el Normal file
View File

@@ -0,0 +1,31 @@
;;
;; ecb
;;
(siren-require-packages '(ecb))
(require 'ecb)
(setq ecb-layout-name "left13")
(setq ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
(setq ecb-tree-make-parent-node-sticky nil)
(setq ecb-prescan-directories-for-emptyness nil)
(setq ecb-tip-of-the-day nil)
(setq ecb-tree-indent 3)
(setq ecb-windows-width 0.24)
(setq ecb-source-path
(quote
(("~/Projects" "Projects")
("~/.emacs.d" ".emacs.d")
("~/.dotfiles" ".dotfiles")
("~/Projects/fitzdares" "fitzdares")
("~/.go" ".go")
("~/src" "src")
("~/Sites" "Sites")
("~" "~")
("/" "/"))))
(if window-system (ecb-activate))
(provide 'siren-ecb)

27
modules/siren-elscreen.el Normal file
View File

@@ -0,0 +1,27 @@
;;
;; elscreen
;;
(siren-require-packages '(elscreen))
(require 'elscreen)
(define-key elscreen-map (kbd "C-z") elscreen-map)
;; Goto screens.
(global-set-key (kbd "s-}") 'elscreen-next)
(global-set-key (kbd "s-{") 'elscreen-previous)
;; Set screen nickname
(define-key elscreen-map (kbd ",") 'elscreen-screen-nickname)
(define-key elscreen-map (kbd "C-,") 'elscreen-screen-nickname)
;; Toggle screens.
(define-key elscreen-map (kbd "l") 'elscreen-toggle)
(define-key elscreen-map (kbd "C-l") 'elscreen-toggle)
;; Display list of screens.
(define-key elscreen-map (kbd ";") 'elscreen-display-screen-name-list)
(define-key elscreen-map (kbd "C-;") 'elscreen-display-screen-name-list)
(provide 'siren-elscreen)

View File

@@ -0,0 +1,47 @@
;;
;; emacs-lisp
;;
(siren-require-packages '(rainbow-mode))
(require 'siren-lisp)
(defun siren-recompile-elc-on-save ()
"Recompile your elc when saving an elisp file."
(add-hook 'after-save-hook
(lambda ()
(when (and
(string-prefix-p siren-dir (file-truename buffer-file-name))
(file-exists-p (byte-compile-dest-file buffer-file-name)))
(emacs-lisp-byte-compile)))
nil
t))
(defun siren-conditional-emacs-lisp-checker ()
"Don't check doc style in Emacs Lisp test files."
(let ((file-name (buffer-file-name)))
(when (and file-name (string-match-p ".*-tests?\\.el\\'" file-name))
(setq-local flycheck-checkers '(emacs-lisp)))))
(defun siren-emacs-lisp-mode-defaults ()
"Sensible defaults for `emacs-lisp-mode'."
; (run-hooks 'siren-lisp-coding-hook)
; (eldoc-mode +1)
; (siren-recompile-elc-on-save)
; (rainbow-mode +1)
; (setq mode-name "EL")
; (siren-conditional-emacs-lisp-checker)
)
(setq siren-emacs-lisp-mode-hook 'siren-emacs-lisp-mode-defaults)
(add-hook 'emacs-lisp-mode-hook (lambda ()
(run-hooks 'siren-emacs-lisp-mode-hook)))
(add-to-list 'auto-mode-alist '("Cask\\'" . emacs-lisp-mode))
(eval-after-load "rainbow-mode"
'(diminish 'rainbow-mode))
(provide 'siren-emacs-lisp)

69
modules/siren-escreen.el Normal file
View File

@@ -0,0 +1,69 @@
;;
;; escreen
;;
(siren-require-packages '(escreen))
(require 'escreen)
;;
;; Escreen Helper
;; - from http://blog.nguyenvq.com/2011/03/07/escreen-instead-of-elscreen-for-screen-like-features-in-emacs/
;;
(defun escreen-get-active-screen-numbers-with-emphasis ()
"what the name says"
(interactive)
(let ((escreens (escreen-get-active-screen-numbers))
(emphased ""))
(dolist (s escreens)
(setq emphased
(concat emphased (if (= escreen-current-screen-number s)
(propertize (number-to-string s)
;;'face 'custom-variable-tag) " ")
;;'face 'info-title-3)
'face 'font-lock-warning-face)
;;'face 'secondary-selection)
(number-to-string s))
" ")))
(message "escreen: active screens: %s" emphased)))
;; Initialize escreen
(escreen-install)
;; Set prefix key to C-z.
(setq escreen-prefix-char (kbd "C-z"))
(global-set-key escreen-prefix-char 'escreen-prefix)
(define-key escreen-map escreen-prefix-char 'escreen-goto-last-screen)
;; Toggle screens.
(define-key escreen-map (kbd "l") 'escreen-goto-last-screen)
(define-key escreen-map (kbd "C-l") 'escreen-goto-last-screen)
;; List screens.
(define-key escreen-map (kbd "a")
'escreen-get-active-screen-numbers-with-emphasis)
(define-key escreen-map (kbd "C-a")
'escreen-get-active-screen-numbers-with-emphasis)
(define-key escreen-map (kbd ";")
'escreen-get-active-screen-numbers-with-emphasis)
(define-key escreen-map (kbd "C-;")
'escreen-get-active-screen-numbers-with-emphasis)
;; Goto screens.
(global-set-key (kbd "s-}") 'escreen-goto-next-screen)
(global-set-key (kbd "s-{") 'escreen-goto-prev-screen)
;; Ctrl versions of default commands.
(define-key escreen-map (kbd "C-c") 'escreen-create-screen)
(define-key escreen-map (kbd "C-g") 'escreen-goto-screen)
(define-key escreen-map (kbd "C-k") 'escreen-kill-screen)
(define-key escreen-map (kbd "C-n") 'escreen-goto-next-screen)
(define-key escreen-map (kbd "C-p") 'escreen-goto-prev-screen)
;; Show list of screens when you switch/create/kill.
(add-hook 'escreen-goto-screen-hook
'escreen-get-active-screen-numbers-with-emphasis)
(provide 'siren-escreen)

View File

@@ -0,0 +1,11 @@
;;
;; exec-path-from-shell
;;
(siren-require-packages '(exec-path-from-shell))
(require 'exec-path-from-shell)
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
(provide 'siren-exec-path-from-shell)

12
modules/siren-fci.el Normal file
View File

@@ -0,0 +1,12 @@
;;
;; fci
;;
(siren-require-packages '(fill-column-indicator))
(require 'fill-column-indicator)
(setq fci-rule-width 1
fci-handle-trucate-lines nil)
(provide 'siren-fci)

13
modules/siren-flycheck.el Normal file
View File

@@ -0,0 +1,13 @@
;;
;; flycheck
;;
(siren-require-packages '(flycheck))
(require 'flycheck)
(setq flycheck-completion-system 'ido)
(setq flycheck-idle-change-delay 1.0)
(setq flycheck-indication-mode 'right-fringe)
(provide 'siren-flycheck)

View File

@@ -0,0 +1,48 @@
;;
;; frame transparency
;;
(defun siren-frame-transparency-fix ()
"Set initial value of alpha parameter for the current frame"
(interactive)
(if (equal (frame-parameter nil 'alpha) nil)
(set-frame-parameter nil 'alpha 100)))
(defun siren-frame-transparency-increase ()
"Increase level of transparency for the current frame"
(interactive)
(siren-frame-transparency-fix)
(if (> (frame-parameter nil 'alpha) 0)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) -1))
(message "This is a minimum value of transparency!")))
(defun siren-frame-transparency-decrease ()
"Decrease level of transparency for the current frame"
(interactive)
(siren-frame-transparency-fix)
(if (< (frame-parameter nil 'alpha) 100)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) +1))
(message "This is a minimum value of transparency!")))
(defun siren-frame-transparency (numb)
"Set level of transparency for the current frame"
(interactive "nEnter transparency level in range 0-100: ")
(if (> numb 100)
(message "Error! The maximum value for transparency is 100!")
(if (< numb 0)
(message "Error! The minimum value for transparency is 0!")
(set-frame-parameter nil 'alpha numb))))
(setq siren-transparency-level 99)
(siren-frame-transparency siren-transparency-level)
(add-hook 'after-make-frame-functions
(lambda (selected-frame)
(set-frame-parameter selected-frame 'alpha siren-transparency-level)))
;; Keybindings
(global-set-key (kbd "C-M-|") 'siren-frame-transparency)
(global-set-key (kbd "C-M-<") 'siren-frame-transparency-increase)
(global-set-key (kbd "C-M->") 'siren-frame-transparency-decrease)
(provide 'siren-frame-transparency)

38
modules/siren-full-ack.el Normal file
View File

@@ -0,0 +1,38 @@
;;
;; full-ack
;;
(siren-require-packages '(full-ack))
(require 'full-ack)
(setq ack-arguments
(quote ("--ignore-dir=vendor/ruby"
"--ignore-dir=vendor/bundle"
"--ignore-dir=coverage"
"--ignore-dir=savefile"
"--ignore-dir=Godeps"
"--ignore-dir=elpa"
"--ignore-dir=docs"
"--ignore-dir=doc"
"--type-add=js=.js,.js.erb"
"--type-add=ruby=.jbuilder,.rabl"
"--type-add=html=.haml,.hamlc,.jade"
"--type-add=css=.sass,.scss,.styl"
"--type-set=coffee=.coffee"
"--type-set=cucumber=.feature")))
(setq ack-project-root-file-patterns
(quote (".project\\'"
".xcodeproj\\'"
".sln\\'"
"\\`Project.ede\\'"
"\\`.git\\'"
"\\`.bzr\\'"
"\\`_darcs\\'"
"\\`.hg\\'"
"\\`Gemfile\\'"
"\\`Rakefile\\'"
"\\`Makefile\\'")))
(setq ack-prompt-for-directory 'unless-guessed)
(provide 'siren-full-ack)

10
modules/siren-github.el Normal file
View File

@@ -0,0 +1,10 @@
;;
;; github
;;
(siren-require-packages '(github-browse-file))
(require 'github-browse-file)
(provide 'siren-github)

View File

@@ -0,0 +1,89 @@
;;
;; global keybindings (customized)
;;
(require 'siren-helpers)
;; Enable dabbrev-expand via custom keybinding.
(global-set-key (kbd "C-x M-/") 'dabbrev-expand)
;; Easier version of "C-x k" to kill buffer
(global-set-key (kbd "C-x C-k") 'kill-buffer)
;; Evaluate buffer
(global-set-key (kbd "C-c C-e") 'eval-buffer)
;; Duplicate line (via siren-helpers.el)
(global-set-key (kbd "C-x C-d") 'duplicate-current-line-or-region)
;; Switch to next/previous buffer
(global-set-key (kbd "C-c C-n") 'switch-to-next-buffer)
(global-set-key (kbd "C-c C-p") 'switch-to-prev-buffer)
;; Window switching (via siren-helpers.el).
(global-set-key (kbd "C-x i") 'other-window-reverse)
(global-set-key (kbd "C-x C-o") 'other-window)
(global-set-key (kbd "C-x C-i") 'other-window-reverse)
;; Kill-Ring related (via siren-helpers.el).
(global-set-key (kbd "M-Y") 'yank-pop-forwards)
;; Align to equal signs (via siren-helpers.el).
(global-set-key (kbd "C-x a =") 'align-region-to-equals)
(global-set-key (kbd "M-]") 'align-region-to-equals)
(global-set-key (kbd "C-x a {") 'align-region-to-opening-brace)
;; align-regexp
(global-set-key (kbd "C-c C-a") 'align-regexp)
;; Toggle auto-fill-mode.
(global-set-key (kbd "C-c q") 'auto-fill-mode)
;; Custom HideShow toggles (via siren-helpers.el)
(global-set-key (kbd "C-=") 'toggle-selective-display)
(global-set-key (kbd "C-\\") 'toggle-hiding)
;; undo/redo via undo-tree
(global-set-key (kbd "M--") 'undo-tree-undo)
(global-set-key (kbd "M-_") 'undo-tree-redo)
;; iBuffer
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; String inflections
(siren-require-packages '(string-inflection))
(require 'string-inflection)
(global-set-key (kbd "C-c C-.") 'string-inflection-cycle)
;; Rename current file and buffer (via siren-helpers.el)
(global-set-key (kbd "C-c r") 'rename-file-and-buffer)
;; Use siren-move-beginning-of-line
(global-set-key (kbd "C-a") 'siren-move-beginning-of-line)
;; Mac OS X specific keybindings
(when (eq system-type 'darwin)
;; Mac OS X Fullscreen (requires Emacs 24.4 or later)
(global-set-key (kbd "s-<return>") 'toggle-frame-fullscreen)
;; Undo/Redo (via undo-tree)
(when (require 'undo-tree nil 'noerror)
(global-set-key (kbd "s-z") 'undo-tree-undo)
(global-set-key (kbd "s-Z") 'undo-tree-redo))
;; Flyspell correct previous word
(when (require 'flyspell nil 'noerror)
(global-set-key (kbd "s-.") 'flyspell-correct-word-before-point))
;; Move to beginning/end of buffer
(global-set-key (kbd "s-<up>") 'beginning-of-buffer)
(global-set-key (kbd "s-<down>") 'end-of-buffer)
;; Move to beginning/end of line
(global-set-key (kbd "s-<left>") 'beginning-of-line)
(global-set-key (kbd "s-<right>") 'end-of-line))
(provide 'siren-global-keybindings)

66
modules/siren-go.el Normal file
View File

@@ -0,0 +1,66 @@
;;
;; go
;;
(require 'siren-programming)
(setenv "GOPATH" (expand-file-name "~/.go"))
;; Ignore go test -c output files
(add-to-list 'completion-ignored-extensions ".test")
(define-key 'help-command (kbd "G") 'godoc)
(eval-after-load 'go-mode
'(progn
(siren-require-packages
'(go-mode go-autocomplete go-eldoc go-projectile gotest))
(require 'go-projectile)
(require 'go-autocomplete)
(defun siren-go-mode-defaults ()
(siren-prog-mode-defaults)
;; Add to default go-mode key bindings
(let ((map go-mode-map))
(define-key map (kbd "RET") 'newline-and-indent)
(define-key map (kbd "C-c a") 'go-test-current-project)
(define-key map (kbd "C-c m") 'go-test-current-file)
(define-key map (kbd "C-c .") 'go-test-current-test)
(define-key map (kbd "C-c b") 'go-run)
(define-key map (kbd "C-h f") 'godoc-at-point))
;; Prefer goimports to gofmt if installed
(let ((goimports (executable-find "goimports")))
(when goimports
(setq gofmt-command goimports)))
;; gofmt on save
(add-hook 'before-save-hook 'gofmt-before-save nil t)
;; enable hide/show
(hs-minor-mode 1)
;; stop whitespace being highlighted
(whitespace-toggle-options '(tabs))
;; enable auto-complete
(auto-complete-mode +1)
;; make tabs 4 spaces wide
(setq tab-width 4)
;; El-doc for Go
;; (go-eldoc-setup)
;; CamelCase aware editing operations
(subword-mode +1))
(setq siren-go-mode-hook 'siren-go-mode-defaults)
(add-hook 'go-mode-hook (lambda ()
(run-hooks 'siren-go-mode-hook)))))
(provide 'siren-go)

View File

@@ -0,0 +1,56 @@
;;
;; goto-symbol
;;
;; Shamelessly ripped from Emacs Prelude.
(require 'imenu)
(set-default 'imenu-auto-rescan t)
(set-default 'imenu-max-item-length 160)
(set-default 'imenu-max-items 100)
(defun siren-goto-symbol (&optional symbol-list)
"Refresh imenu and jump to a place in the buffer using Ido."
(interactive)
(cond
((not symbol-list)
(let (name-and-pos symbol-names position)
(while (progn
(imenu--cleanup)
(setq imenu--index-alist nil)
(siren-goto-symbol (imenu--make-index-alist))
(setq selected-symbol
(completing-read "Symbol? " (reverse symbol-names)))
(string= (car imenu--rescan-item) selected-symbol)))
(unless (and (boundp 'mark-active) mark-active)
(push-mark nil t nil))
(setq position (cdr (assoc selected-symbol name-and-pos)))
(cond
((overlayp position)
(goto-char (overlay-start position)))
(t
(goto-char position)))
(recenter)))
((listp symbol-list)
(dolist (symbol symbol-list)
(let (name position)
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(siren-goto-symbol 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)
(string= (car imenu--rescan-item) name))
(add-to-list 'symbol-names (substring-no-properties name))
(add-to-list 'name-and-pos (cons (substring-no-properties name) position))))))))
(global-set-key (kbd "C-t") 'siren-goto-symbol)
(provide 'siren-goto-symbol)

23
modules/siren-haml.el Normal file
View File

@@ -0,0 +1,23 @@
;;
;; haml
;;
(siren-require-packages '(haml-mode))
(require 'siren-programming)
(add-to-list 'auto-mode-alist '("\\.hamlc\\'" . haml-mode))
(defun siren-haml-mode-defaults ()
(siren-prog-mode-defaults)
(setq tab-width 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(setq siren-haml-mode-hook 'siren-haml-mode-defaults)
(add-hook 'haml-mode-hook (lambda () (run-hooks 'siren-haml-mode-hook)))
(provide 'siren-haml)

39
modules/siren-helm.el Normal file
View File

@@ -0,0 +1,39 @@
;;
;; helm
;;
(siren-require-packages '(helm helm-swoop helm-projectile helm-open-github))
(require 'helm)
(require 'helm-swoop)
(require 'helm-projectile)
(require 'helm-open-github)
(setq helm-ag-source-type "file-line"
helm-open-github-commit-limit 10000)
;; Helm
(define-key helm-map (kbd "<up>") 'previous-history-element)
(define-key helm-map (kbd "<down>") 'next-history-element)
(define-key helm-map (kbd "M-p") 'helm-previous-source)
(define-key helm-map (kbd "M-n") 'helm-next-source)
(global-set-key (kbd "C-c h") 'helm-mini)
;; Helm Swoop
(global-set-key (kbd "M-r") 'helm-swoop)
(global-set-key (kbd "M-R") 'helm-swoop-back-to-last-point)
(global-set-key (kbd "C-c M-r") 'helm-multi-swoop)
(global-set-key (kbd "C-x M-r") 'helm-multi-swoop-all)
;; Helm Projectile
(global-set-key (kbd "C-c ;") 'helm-projectile)
(global-set-key (kbd "C-c C-;") 'helm-projectile)
;; Helm Open Github
(global-set-key (kbd "C-c o f") 'helm-open-github-from-file)
(global-set-key (kbd "C-c o c") 'helm-open-github-from-commit)
(global-set-key (kbd "C-c o i") 'helm-open-github-from-issues)
(global-set-key (kbd "C-c o p") 'helm-open-github-from-pull-requests)
(provide 'siren-helm)

107
modules/siren-helpers.el Normal file
View File

@@ -0,0 +1,107 @@
;;
;; helpers
;;
;;
;; Duplicate Line
;; - from: http://tuxicity.se/emacs/elisp/2010/03/11/duplicate-current-line-or-region-in-emacs.html
;;
(defun duplicate-current-line-or-region (arg)
"Duplicates the current line or region ARG times.
If there's no region, the current line will be duplicated. However, if
there's a region, all lines that region covers will be duplicated."
(interactive "p")
(let (beg end (origin (point)))
(if (and mark-active (> (point) (mark)))
(exchange-point-and-mark))
(setq beg (line-beginning-position))
(if mark-active
(exchange-point-and-mark))
(setq end (line-end-position))
(let ((region (buffer-substring-no-properties beg end)))
(dotimes (i arg)
(goto-char end)
(newline)
(insert region)
(setq end (point)))
(goto-char (+ origin (* (length region) arg) arg)))))
;;
;; Align Equal Signs
;;
(defun align-region-to-equals (begin end)
"Align region to equal signs"
(interactive "r")
(align-regexp begin end "\\(\\s-*\\)=" 1 1 ))
(defun align-region-to-opening-brace (begin end)
"Align region to equal signs"
(interactive "r")
(align-regexp begin end "\\(\\s-*\\){" 1 1 ))
;;
;; Yank Pop Forwards
;;
(defun yank-pop-forwards (arg)
(interactive "p")
(yank-pop (- arg)))
;;
;; Window Switching
;;
(defun other-window-reverse ()
"Switch to the previous window"
(interactive)
(other-window -1))
;;
;; HideShow mode helpers
;; - from: http://www.emacswiki.org/emacs/HideShow
;;
(defun toggle-selective-display (column)
(interactive "P")
(set-selective-display
(or column
(unless selective-display
(1+ (current-column))))))
(defun toggle-hiding (column)
(interactive "P")
(if hs-minor-mode
(if (condition-case nil
(hs-toggle-hiding)
(error t))
(hs-show-all))
(toggle-selective-display column)))
;;
;; File and Buffer Renaming
;; - from: http://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/
;;
(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)))))))
(provide 'siren-helpers)

View File

@@ -0,0 +1,12 @@
;;
;; highlight-indentation
;;
(siren-require-packages '(highlight-indentation))
(require 'highlight-indentation)
(diminish 'highlight-indentation-mode)
(diminish 'highlight-indentation-current-column-mode)
(provide 'siren-highlight-indentation)

36
modules/siren-ido.el Normal file
View File

@@ -0,0 +1,36 @@
;;
;; ido relateed
;;
(siren-require-packages '(ido-ubiquitous ido-vertical-mode smex))
(require 'ido)
(require 'ido-ubiquitous)
(require 'ido-vertical-mode)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
ido-max-prospects 10
ido-save-directory-list-file (expand-file-name "ido.hist" siren-savefile-dir)
ido-default-file-method 'selected-window
ido-auto-merge-work-directories-length -1
ido-vertical-define-keys "C-n-C-p-up-down-left-right")
(ido-mode +1)
(ido-ubiquitous-mode +1)
(ido-vertical-mode +1)
;; disable ido faces to see flx highlights
(setq ido-use-faces nil)
;;; smex, remember recently and most frequently used commands
(require 'smex)
(setq smex-save-file (expand-file-name ".smex-items" siren-savefile-dir))
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(provide 'siren-ido)

14
modules/siren-linum.el Normal file
View File

@@ -0,0 +1,14 @@
;;
;; linum
;;
;; Customize line numbers - In gui mode the fringe is the spacer between line
;; numbers and code, while in console mode we add an extra space for it.
(if window-system (setq linum+-dynamic-format " %%%dd")
(setq linum+-dynamic-format " %%%dd "))
(eval-after-load "linum+" '(progn (setq linum-format 'dynamic)))
(require 'linum+)
(provide 'siren-linum)

34
modules/siren-lisp.el Normal file
View File

@@ -0,0 +1,34 @@
;;
;; lisp
;;
(require 'siren-programming)
(siren-require-packages '(rainbow-delimiters))
;; Lisp configuration
(define-key read-expression-map (kbd "TAB") 'completion-at-point)
;; wrap keybindings
(define-key lisp-mode-shared-map (kbd "M-(") (siren-wrap-with "("))
;; FIXME: Pick terminal-friendly binding.
;;(define-key lisp-mode-shared-map (kbd "M-[") (siren-wrap-with "["))
(define-key lisp-mode-shared-map (kbd "M-\"") (siren-wrap-with "\""))
;; a great lisp coding hook
(defun siren-lisp-coding-defaults ()
;; (smartparens-strict-mode +1)
(rainbow-delimiters-mode +1)
)
(setq siren-lisp-coding-hook 'siren-lisp-coding-defaults)
;; interactive modes don't need whitespace checks
(defun siren-interactive-lisp-coding-defaults ()
;; (smartparens-strict-mode +1)
(rainbow-delimiters-mode +1)
(whitespace-mode -1))
(setq siren-interactive-lisp-coding-hook 'siren-interactive-lisp-coding-defaults)
(provide 'siren-lisp)

46
modules/siren-magit.el Normal file
View File

@@ -0,0 +1,46 @@
;;
;; magit
;;
(siren-require-packages '(magit))
(require 'siren-fci)
(require 'magit)
(setq magit-completing-read-function 'magit-ido-completing-read)
(setq magit-status-buffer-switch-function 'switch-to-buffer)
(setq magit-bury-buffer-function 'magit-mode-quit-window)
(setq magit-default-tracking-name-function
'magit-default-tracking-name-branch-only)
(setq magit-repository-directories
(quote ("~/Projects" "~/src" "~/.emacs.d" "~/.dotfiles")))
(global-set-key (kbd "C-x g") 'magit-status)
(defalias 'bl 'magit-blame)
;; Configure magit-mode
(defun siren-magit-mode-defaults ()
;; (linum-mode t) ;; Causes magit to freeze sometimes
)
(setq siren-magit-mode-hook 'siren-magit-mode-defaults)
(add-hook 'magit-mode-hook (lambda () (run-hooks 'siren-magit-mode-hook)))
;; Configure git-commit-mode
(defun siren-git-commit-mode-defaults ()
(subword-mode +1)
(setq tab-width 2)
(flyspell-mode)
(linum-mode t)
(auto-fill-mode)
(subword-mode))
(setq siren-git-commit-mode-hook 'siren-git-commit-mode-defaults)
(add-hook 'git-commit-mode-hook (lambda ()
(run-hooks 'siren-git-commit-mode-hook)))
(provide 'siren-magit)

21
modules/siren-makefile.el Normal file
View File

@@ -0,0 +1,21 @@
;;
;; makefile
;;
(require 'siren-programming)
(defun siren-makefile-mode-defaults ()
(siren-prog-mode-defaults)
(subword-mode)
(setq tab-width 4)
(setq highlight-indentation-offset 4)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode))
(setq siren-makefile-mode-hook 'siren-makefile-mode-defaults)
(add-hook 'makefile-mode-hook (lambda ()
(run-hooks 'siren-makefile-mode-hook)))
(provide 'siren-makefile)

View File

@@ -1,12 +1,22 @@
;;
;; sass
;;
(siren-require-packages '(markdown-mode))
(require 'markdown-mode)
(setq markdown-command "redcarpet")
(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.mkd" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.mkdn" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.mdown" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.markdown" . markdown-mode) auto-mode-alist))
(defun customizations-for-markdown-mode ()
(interactive)
(defun siren-markdown-mode-defaults ()
(setq whitespace-action nil)
(setq fill-column 80)
(fci-mode)
(linum-mode t)
(flyspell-mode)
@@ -14,4 +24,9 @@
(subword-mode)
(define-key markdown-mode-map (kbd "C-c p") 'markdown-preview))
(add-hook 'markdown-mode-hook 'customizations-for-markdown-mode)
(setq siren-markdown-mode-hook 'siren-markdown-mode-defaults)
(add-hook 'markdown-mode-hook (lambda () (run-hooks 'siren-markdown-mode-hook)))
(provide 'siren-markdown)

View File

@@ -0,0 +1,34 @@
;;
;; move-beginning-of-line
;;
;; Borrowed from:
;; - http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/
(defun siren-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))))
(global-set-key [remap move-beginning-of-line]
'siren-move-beginning-of-line)
(provide 'siren-move-beginning-of-line)

View File

@@ -0,0 +1,23 @@
;;
;; multiple-cursors
;;
(siren-require-packages '(multiple-cursors))
(require 'multiple-cursors)
(setq mc/edit-lines-empty-lines 'ignore)
(global-set-key (kbd "C-x C-@") 'mc/edit-lines) ;; Terminal
(global-set-key (kbd "C-x C-SPC") 'mc/edit-lines) ;; GUI
(global-set-key (kbd "M-/") 'mc/mark-next-like-this)
(global-set-key (kbd "M-m") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c M-/") 'mc/mark-all-like-this)
(global-set-key (kbd "M-RET") 'set-rectangular-region-anchor)
;; Make alt-<click> add additional cursors
(global-unset-key (kbd "M-<down-mouse-1>")) ;; must unset key first
(global-set-key (kbd "M-<mouse-1>") 'mc/add-cursor-on-click)
(provide 'siren-multiple-cursors)

10
modules/siren-neotree.el Normal file
View File

@@ -0,0 +1,10 @@
;;
;; neotree
;;
(siren-require-packages '(neotree))
(require 'neotree)
;; (global-set-key (kbd "C-x p") 'neotree-open)
(provide 'siren-neotree)

View File

@@ -0,0 +1,37 @@
;;
;; perspective
;;
(siren-require-packages '(perspective))
(require 'perspective)
(define-key persp-mode-map (kbd "C-z") perspective-map)
(define-key persp-mode-map (kbd "C-z s") 'persp-switch)
(define-key persp-mode-map (kbd "C-z C-s") 'persp-switch)
(define-key persp-mode-map (kbd "C-z b") 'persp-switch)
(define-key persp-mode-map (kbd "C-z C-b") 'persp-switch)
(define-key persp-mode-map (kbd "C-z c") 'persp-remove-buffer)
(define-key persp-mode-map (kbd "C-z C-c") 'persp-remove-buffer)
(define-key persp-mode-map (kbd "C-z k") 'persp-kill)
(define-key persp-mode-map (kbd "C-z C-k") 'persp-kill)
(define-key persp-mode-map (kbd "C-z r") 'persp-rename)
(define-key persp-mode-map (kbd "C-z C-r") 'persp-rename)
(define-key persp-mode-map (kbd "C-z a") 'persp-add-buffer)
(define-key persp-mode-map (kbd "C-z C-a") 'persp-add-buffer)
(define-key persp-mode-map (kbd "C-z i") 'persp-import)
(define-key persp-mode-map (kbd "C-z C-i") 'persp-import)
(define-key persp-mode-map (kbd "C-z n") 'persp-next)
(define-key persp-mode-map (kbd "C-z C-n") 'persp-next)
(define-key persp-mode-map (kbd "C-z p") 'persp-prev)
(define-key persp-mode-map (kbd "C-z C-p") 'persp-prev)
(provide 'siren-perspective)

View File

@@ -0,0 +1,12 @@
;;
;; phi-search
;;
(siren-require-packages '(phi-search))
(require 'phi-search)
(global-set-key (kbd "C-s") 'phi-search)
(global-set-key (kbd "C-r") 'phi-search-backward)
(provide 'siren-phi-search)

View File

@@ -0,0 +1,32 @@
;;
;; programming
;;
(require 'siren-fci)
(require 'siren-flycheck)
(require 'siren-smartparens)
(require 'siren-highlight-indentation)
(defun siren-prog-mode-defaults ()
"Default coding hook, useful with any programming language."
(setq fill-column 80)
(linum-mode t)
(flyspell-prog-mode)
(fci-mode)
(smartparens-mode +1)
(setq whitespace-action (quote (auto-cleanup)))
(visual-line-mode +1)
(whitespace-mode +1))
(setq siren-prog-mode-hook 'siren-prog-mode-defaults)
(add-hook 'prog-mode-hook (lambda ()
(run-hooks 'siren-prog-mode-hook)))
;; enable on-the-fly syntax checking
(if (fboundp 'global-flycheck-mode)
(global-flycheck-mode +1)
(add-hook 'prog-mode-hook 'flycheck-mode))
(provide 'siren-programming)

View File

@@ -0,0 +1,30 @@
;;
;; project-explorer
;;
(siren-require-packages '(project-explorer))
(require 'project-explorer)
(setq pe/follow-current t)
(setq pe/width 54)
(setq pe/cache-directory (expand-file-name
"project-explorer-cache" siren-savefile-dir))
(global-set-key (kbd "C-x p") 'project-explorer-open)
;; Make Project Explorer open selected file in last used buffer
(setq pe/display-content-buffer-function
(lambda (buffer)
(let* (( last-buffer
(car (cl-remove 'project-explorer-mode
(buffer-list)
:key (apply-partially 'buffer-local-value
'major-mode))))
( window (get-buffer-window last-buffer)))
(if window
(set-window-buffer window buffer)
(pe/show-buffer buffer)))
))
(provide 'siren-project-explorer)

View File

@@ -0,0 +1,51 @@
;;
;; projectile
;;
(siren-require-packages '(projectile))
(require 'projectile)
(setq projectile-completion-system 'ido)
(setq projectile-enable-caching nil)
(setq projectile-globally-ignored-directories
(quote (".idea"
".eunit"
".git"
".hg"
".fslckout"
".bzr"
".svn"
"_darcs"
"vendor/bundle"
"vendor/ruby"
"coverage"
"docs"
"doc"
"log"
"logs"
"tmp"
"Godeps"
"elpa"
"savefile")))
(setq projectile-globally-ignored-files (quote ("TAGS" "*.log")))
(setq projectile-sort-order 'recently-active)
(setq projectile-cache-file (expand-file-name
"projectile.cache" siren-savefile-dir))
;; Bug lets projectile write to the file, but not read from it
;; (setq projectile-known-projects-file (expand-file-name
;; "projectile-bookmarks.eld" siren-savefile-dir))
(projectile-global-mode t)
;; Keybindings
(global-set-key (kbd "C-c C-b") 'projectile-ibuffer)
(global-set-key (kbd "C-x C-t") 'projectile-find-file)
(global-set-key (kbd "C-x t") 'projectile-find-test-file)
(global-set-key (kbd "C-x C-v") 'projectile-switch-to-buffer)
(global-set-key (kbd "C-c C-s") 'projectile-switch-project)
(provide 'siren-projectile)

83
modules/siren-ruby.el Normal file
View File

@@ -0,0 +1,83 @@
;;
;; ruby
;;
(require 'siren-programming)
(siren-require-packages '(ruby-tools inf-ruby yari company-inf-ruby))
;; Force-load custom vendored ruby-mode fetched from:
;; - https://raw.github.com/ruby/ruby/trunk/misc/ruby-mode.el
(load (expand-file-name "ruby-mode.el" siren-vendor-dir))
;; Rake files are ruby, too, as are gemspecs, rackup files, and gemfiles.
(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Guardfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.cap\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.thor\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rabl\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Thorfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.jbuilder\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Podfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.podspec\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Puppetfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Berksfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Appraisals\\'" . ruby-mode))
;; We never want to edit Rubinius bytecode
(add-to-list 'completion-ignored-extensions ".rbc")
(define-key 'help-command (kbd "R") 'yari)
;; Set up hs-mode (HideShow) for Ruby
(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do")) ;; Block start
,(rx (or "end")) ;; Block end
,(rx (or "#" "=begin")) ;; Comment start
ruby-forward-sexp nil))
(eval-after-load 'company
'(add-to-list 'company-backends 'company-inf-ruby))
(eval-after-load 'ruby-mode
'(progn
(defun siren-ruby-mode-defaults ()
(siren-prog-mode-defaults)
(inf-ruby-minor-mode +1)
(ruby-tools-mode +1)
(setq tab-width 2)
(hs-minor-mode 1)
(company-mode +1)
(subword-mode +1)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(setq ruby-deep-arglist nil)
(setq ruby-deep-indent-paren nil)
(setq c-tab-always-indent nil)
(setq ruby-use-encoding-map nil)
(define-key ruby-mode-map (kbd "C-j") 'newline-and-indent)
(define-key ruby-mode-map (kbd "RET") 'newline-and-indent)
(define-key ruby-mode-map (kbd "C-c C-h") 'toggle-hiding)
(define-key ruby-mode-map (kbd "C-c C-l") 'goto-line))
(setq siren-ruby-mode-hook 'siren-ruby-mode-defaults)
(add-hook 'ruby-mode-hook (lambda ()
(run-hooks 'siren-ruby-mode-hook)))))
;; ;; Auto-complete when indenting
;; (defadvice ruby-indent-command (around ac-before-ruby-indent activate)
;; "Call `auto-complete' if text was recently entered"
;; (if (ac-trigger-command-p last-command)
;; (auto-complete)
;; ad-do-it))
(provide 'siren-ruby)

19
modules/siren-sass.el Normal file
View File

@@ -0,0 +1,19 @@
;;
;; sass
;;
(require 'siren-css)
(siren-require-packages '(sass-mode))
;; turn off annoying auto-compile on save
(setq sass-compile-at-save nil)
(defun siren-sass-mode-defaults ()
(siren-css-mode-defaults))
(setq siren-sass-mode-hook 'siren-sass-mode-defaults)
(add-hook 'sass-mode-hook (lambda () (run-hooks 'siren-sass-mode-hook)))
(provide 'siren-sass)

View File

@@ -0,0 +1,17 @@
;;
;; scroll-half-screen
;;
;; Scroll half a screen when using scroll-up and scroll-down functions.
(defadvice scroll-up (around half-window activate)
(setq next-screen-context-lines
(max 1 (/ (1- (window-height (selected-window))) 2)))
ad-do-it)
(defadvice scroll-down (around half-window activate)
(setq next-screen-context-lines
(max 1 (/ (1- (window-height (selected-window))) 2)))
ad-do-it)
(provide 'siren-scroll-half-screen)

19
modules/siren-scss.el Normal file
View File

@@ -0,0 +1,19 @@
;;
;; scss
;;
(require 'siren-css)
(siren-require-packages '(scss-mode))
;; turn off annoying auto-compile on save
(setq scss-compile-at-save nil)
(defun siren-scss-mode-defaults ()
(siren-css-mode-defaults))
(setq siren-scss-mode-hook 'siren-scss-mode-defaults)
(add-hook 'scss-mode-hook (lambda () (run-hooks 'siren-scss-mode-hook)))
(provide 'siren-scss)

26
modules/siren-sh.el Normal file
View File

@@ -0,0 +1,26 @@
;;
;; shell
;;
(require 'siren-programming)
(defun siren-sh-mode-defaults ()
(siren-prog-mode-defaults)
(subword-mode +1)
(setq tab-width 2)
(setq sh-basic-offset 2)
(setq sh-indentation 2)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(setq whitespace-action (quote (auto-cleanup)))
(define-key sh-mode-map (kbd "RET") 'newline-and-indent))
(setq siren-sh-mode-hook 'siren-sh-mode-defaults)
(add-hook 'sh-mode-hook (lambda ()
(run-hooks 'siren-sh-mode-hook)))
(provide 'siren-sh)

Some files were not shown because too many files have changed in this diff Show More