forked from technomancy/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdfarkas.el
More file actions
223 lines (176 loc) · 6.93 KB
/
dfarkas.el
File metadata and controls
223 lines (176 loc) · 6.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
;;; dfarkas.el --- Some helpful dfarkas code
;; DESCRIPTION: dfarkas settings
(setq initial-frame-alist '(
(top . 5) (left . 5)
(width . 200) (height . 55)
)
)
;; Apply shell environment to emacs
;; http://paste.lisp.org/display/111574
(defun env-line-to-cons (env-line)
"Convert a string of the form \"VAR=VAL\" to a
cons cell containing (\"VAR\" . \"VAL\")."
(if (string-match "\\([^=]+\\)=\\(.*\\)" env-line)
(cons (match-string 1 env-line) (match-string 2 env-line))))
(defun interactive-env-alist (&optional shell-cmd env-cmd)
"Launch /usr/bin/env or the equivalent from a login
shell, parsing and returning the environment as an alist."
(let ((cmd (concat (or shell-cmd "$SHELL -lc")
" "
(or env-cmd "/usr/bin/env"))))
(mapcar 'env-line-to-cons
(remove-if
(lambda (str)
(string-equal str ""))
(split-string (shell-command-to-string cmd) "[\r\n]")))))
(defun setenv-from-cons (var-val)
"Set an environment variable from a cons cell containing
two strings, where the car is the variable name and cdr is
the value, e.g. (\"VAR\" . \"VAL\")"
(setenv (car var-val) (cdr var-val)))
(defun setenv-from-shell-environment (&optional shell-cmd env-cmd)
"Apply the environment reported by `/usr/bin/env' (or env-cmd)
as launched by `$SHELL -lc' (or shell-cmd) to the current
environment."
(mapc 'setenv-from-cons (interactive-env-alist shell-cmd env-cmd)))
(setenv-from-shell-environment)
(setq exec-path (split-string (getenv "PATH") path-separator))
(add-to-list 'load-path (concat dotfiles-dir "/vendor"))
;; prompt to save scratch file
(defvar scratch-buffer-file-name "~/sktch.el"
"file name for *scratch* buffer")
(defun synch-scratch-with-file ()
"replace *scratch* buffer with the file scratch-buffer-file-name"
(save-window-excursion
(find-file scratch-buffer-file-name)
(kill-buffer "*scratch*")
(rename-buffer "*scratch*")
(lisp-interaction-mode)))
(synch-scratch-with-file)
(require 'dfarkas/meta)
(require 'dfarkas/plain-text)
;; Snippets
(add-to-list 'load-path (concat dotfiles-dir "/vendor/yasnippet.el"))
(require 'yasnippet)
(yas/initialize)
(yas/load-directory (concat dotfiles-dir "/vendor/yasnippet.el/snippets"))
;; Commands
(require 'unbound)
;; Minor Modes
(add-to-list 'load-path (concat dotfiles-dir "/vendor/textmate.el"))
(require 'textmate)
(textmate-mode)
(require 'whitespace)
(add-hook 'ruby-mode-hook 'whitespace-mode)
;; Major Modes
(add-to-list 'load-path (concat dotfiles-dir "/vendor/ruby-complexity"))
(add-to-list 'auto-mode-alist '("Capfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Isolate\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.sake\\'" . ruby-mode))
(require 'linum)
(require 'ruby-complexity)
(require 'dfarkas/js)
;; Remove scrollbars and make hippie expand
;; work nicely with yasnippet
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(require 'hippie-exp)
(setq hippie-expand-try-functions-list
'(yas/hippie-try-expand
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
;; try-expand-dabbrev-from-kill
;; try-complete-file-name
;; try-complete-file-name-partially
;; try-complete-lisp-symbol
;; try-complete-lisp-symbol-partially
;; try-expand-line
;; try-expand-line-all-buffers
;; try-expand-list
;; try-expand-list-all-buffers
;; try-expand-whole-kill
))
(defun indent-or-complete ()
(interactive)
(if (and (looking-at "$") (not (looking-back "^\\s-*")))
(hippie-expand nil)
(indent-for-tab-command)))
(add-hook 'find-file-hooks (function (lambda ()
(local-set-key (kbd "TAB") 'indent-or-complete))))
;; dabbrev-case-fold-search for case-sensitive search
(require 'dfarkas/rinari)
(add-to-list 'load-path (concat dotfiles-dir "/vendor/rspec-mode"))
(require 'rspec-mode)
(require 'textile-mode)
(add-to-list 'auto-mode-alist '("\\.textile\\'" . textile-mode))
(autoload 'markdown-mode "markdown-mode.el"
"Major mode for editing Markdown files" t)
(require 'dfarkas/haml)
(require 'dfarkas/xcode)
(require 'dfarkas/keyboard)
;; gist
(require 'gist)
(prefer-coding-system 'utf-8)
(setq make-backup-files nil) ;; disable backup files
(setq auto-save-default nil) ; turns off that blasted auto-save shit
(add-hook 'before-save-hook 'delete-trailing-whitespace) ;; deletes all whitespace that isn't needed.
;; Color Theme
(add-to-list 'load-path (concat dotfiles-dir "/vendor/color-theme"))
(require 'color-theme)
(color-theme-initialize)
;; Use the solarized-dark color theme
(add-to-list 'load-path (concat user-specific-dir "/color-theme-solarized"))
(require 'color-theme-solarized)
;;(color-theme-solarized-dark)
(load (concat dotfiles-dir "dfarkas/theme.el"))
(color-theme-dfarkas)
;; personal-layout
(defun personal-layout ()
"Arrange windows to my personal layout."
(interactive)
(delete-other-windows)
;; (split-window-horizontally)
(split-window-horizontally)
;; (windmove-right)
(windmove-right)
(split-window-vertically)
;; (windmove-left)
(windmove-left))
(personal-layout)
;; --------------------------------------------------------
;; nice little alternative visual bell; Miles Bader <miles /at/ gnu.org>
(defcustom echo-area-bell-string "*DING* " ;"♪"
"Message displayed in mode-line by `echo-area-bell' function."
:group 'user)
(defcustom echo-area-bell-delay 0.1
"Number of seconds `echo-area-bell' displays its message."
:group 'user)
;; internal variables
(defvar echo-area-bell-cached-string nil)
(defvar echo-area-bell-propertized-string nil)
(defun echo-area-bell ()
"Briefly display a highlighted message in the echo-area.
The string displayed is the value of `echo-area-bell-string',
with a red background; the background highlighting extends to the
right margin. The string is displayed for `echo-area-bell-delay'
seconds.
This function is intended to be used as a value of `ring-bell-function'."
(unless (equal echo-area-bell-string echo-area-bell-cached-string)
(setq echo-area-bell-propertized-string
(propertize
(concat
(propertize
"x"
'display
`(space :align-to (- right ,(+ 2 (length echo-area-bell-string)))))
echo-area-bell-string)
'face '(:background "red")))
(setq echo-area-bell-cached-string echo-area-bell-string))
(message echo-area-bell-propertized-string)
(sit-for echo-area-bell-delay)
(message ""))
(setq ring-bell-function 'echo-area-bell)
(provide 'dfarkas)
;; dfarkas.el ends here