minor config update
[dot-emacs] / misc-disabled.el
1 ;; git version of gnus
2 ;; (add-to-list 'load-path "~/.emacs.d/src/gnus/lisp")
3 ;; (eval-after-load "info"
4 ;; (quote (add-to-list 'Info-default-directory-list "~/.emacs.d/src/gnus/texi")))
5
6 ;; needed for git version
7 ;;(add-to-list 'load-path "~/.emacs.d/src/haskell-mode")
8 ;;(require 'haskell-mode-autoloads)
9 ;;(add-to-list 'Info-default-directory-list "~/.emacs.d/src/haskell-mode")
10
11 ;; for using custom/upstream bbdb
12 ;;(require 'bbdb-loaddefs "~/.emacs.d/src/bbdb/lisp/bbdb-loaddefs.el")
13 ;;(setq bbdb-print-tex-path "~/.emacs.d/src/bbdb/tex")
14
15
16 ;; iank: dunno what this was about
17 ;;(add-hook 'server-visit-hook 'raise-frame)
18
19
20 ;;;; alternate keyboards
21 ;; todo, figure out an easy way to disable this when using external keyboard
22 ;; (if (display-graphic-p)
23 ;; (setq
24 ;; enter-key (kbd "<return>")
25 ;; s-enter-key (kbd "<S-return>")
26 ;; c-m-enter-key (kbd "<C-M-return>")
27 ;; m-enter (kbd "<M-return>")
28 ;; c-enter (kbd "<C-return>"))
29 ;; (setq
30 ;; enter-key (kbd "C-m")
31 ;; s-enter-key (kbd "C-8")
32 ;; c-m-enter-key (kbd "C-M-8")
33 ;; m-enter (kbd "M-m")
34 ;; c-enter (kbd "C-8")))
35
36
37 (setq tp (string= (system-name) "tp"))
38 (setq x200 (string= (system-name) "x2"))
39 (setq laptop-keyboard (or tp x200))
40
41
42
43 ;;; abreviations
44 ;; turn on abbrev mode globally
45 (setq-default abbrev-mode t)
46
47 ;; default abbreviation mode file is .emacs.d/abbrev_defs.
48 ;; add-global-abbrev, add-mode-abbrev for expansion at point
49 ;; if all else fails, edit the abbrev file
50
51
52 ;;; bbdb
53 ;; based on bbdb manual
54 ;; also has instructions to integrate with gnus,
55
56 (bbdb-initialize 'message)
57
58 ;; recommended by gnus,
59 ;; but seems like it could be good to have set for other stuff
60 (setq user-full-name "Ian Kelling")
61 ;; general email setting? recommended by mu4e
62 (setq message-kill-buffer-on-exit t)
63
64
65
66 ;; use d instead
67 (add-hook 'bbdb-mode-hook
68 (lambda () (define-key bbdb-mode-map (kbd "C-k") nil))
69 ;; based on emacs24-starter-kit
70 (setq bbdb-offer-save 'auto
71 bbdb-notice-auto-save-file t
72 bbdb-expand-mail-aliases t
73 bbdb-canonicalize-redundant-nets-p t
74 bbdb-complete-name-allow-cycling t)
75 )
76
77 ;;(require 'bbdb-csv-import)
78
79
80
81
82 ;;; yasnippet
83 ;;; todo: learn and use yasnippet
84
85 ;; cd ~/.emacs.d/src
86 ;; git clone --recursive https://github.com/capitaomorte/yasnippet
87 ;; touch snippets/.yas-make-groups
88
89 ;; This all makes it so I can look through the default snippets
90 ;; in the menu bar, but they don't show up elsewhere, because they are
91 ;; mostly things I don't want.
92
93
94 (require 'yasnippet)
95 ;; this needs to be before yas-global-mode
96 (setq yas-snippet-dirs (list "~/.emacs.d/snippets"))
97 (yas-global-mode 1)
98
99 (setq
100 yas-also-auto-indent-first-line t
101 yas-choose-tables-first t
102 yas-use-menu (quote full)
103 ;; this sets ido-prompt as first function
104 yas-prompt-functions
105 '(yas-ido-prompt yas-dropdown-prompt yas-x-prompt yas-completing-prompt yas-no-prompt))
106
107 ;; todo, explore this option for wrapping region
108 ;; '(yas/wrap-around-region t))
109
110 (defun ac-common-setup ()
111 (add-to-list 'ac-sources 'ac-source-yasnippet))
112
113
114
115 ;;; haskell
116
117 ;; useful comint-shell mode commands. If not prefaced with *, it means it is not in the haskell custom repl
118 ;; *todo: setup haskell c-t toggle arrow keys
119 ;; tab completion
120 ;; C-q insert prev arg
121 ;; C-( history search
122 ;; c-m-left/right move to next/prev prompts
123 ;; *c-enter, multi-line input
124 ;; *s-delete, send input across windows. (i can implement this)
125 ;; *c-m-l clear screen
126 ;; *haskell-process-interrupt, c-cc terminate job (i can implement this maybe)
127
128 ;; nice bash/readline functions missing in comint:
129 ;; yank-nth-arg
130 ;; operate-get-next
131 ;; menu-complete
132
133 ;; usefull comint commands:
134 ;; c-cl : list historic command in temp buffer
135 ;; C-c C-o comint-delete-output
136 ;; comint-restore-input, todo: put this on a randomish c-c key
137
138
139
140 ;; todo:
141 ;; checkout haskell repl functions:
142 ;; c-cv haskell-check, hlint
143 ;; C-M-q prog-indent-sexp
144 ;; c-c. haskell-mode-format-imports
145 ;; C-c M-/ haskell-doc-check-active
146 ;; haskell-process-generate-tags
147 ;; haskell-process-cabal-build
148 ;; haskell-cabal-command.. or something
149 ;; haskell-process-restart
150 ;; C-h v haskell-process-log
151 ;; C-h v haskell-process-show-debug-tips
152
153 ;; various not immediately useful functions:
154 ;; haskell-process-add-dependency
155 ;; haskell-process-touch-buffer
156 ;; haskell-process-cd
157 ;; haskell-process-unignore
158 ;; haskell-process-reload-devel-main
159
160
161 ;; rebind
162 ;; home: C-a haskell-interactive-mode-beginning
163 ;; c-return: C-j haskell-interactive-mode-newline-indent
164 ;; up/down: <C-down> haskell-interactive-mode-history-next
165
166 ;; todo haskell mode better binds for:
167 ;; 'haskell-process-load-file
168 ;; 'haskell-process-do-type
169 ;; 'haskell-process-do-info
170 ;; 'inferior-haskell-send-decl
171
172
173 ;; commands which don't work in haskell-interactive-mode(hi) vs inferior-haskell-mode(ih, default)
174 ;; functions not in hi:
175 ;; inferior-haskell-find-definition, use tags instead
176 ;; inferior-haskell-find-haddock, todo, test if this works
177
178 ;; redefined ih to hi
179 ;; switch-to-haskell -> 'haskell-interactive-switch
180 ;; haskell-process-load-file -> inferior-haskell-load-file
181 ;; haskell-process-do-type -> inferior-haskell-type
182 ;; switch-to-haskell -> haskell-interactive-switch
183 ;; inferior-haskell-load-file -> 'haskell-process-load-file
184
185
186 ;; haskell-mode installation from source, based on its readme
187 ;; in the git directory,
188 ;; make all
189
190
191
192
193 ;; remove default option to not link the file
194 (setq haskell-compile-command "ghc -Wall -ferror-spans -fforce-recomp %s")
195 (add-hook 'haskell-indentation-mode-hook
196 (lambda ()
197 (define-key haskell-indentation-mode-map [?\C-d] nil)
198 (define-key haskell-indentation-mode-map
199 (kbd "<deletechar>")
200 'haskell-indentation-delete-char)))
201
202 ;;copied from haskell-mode docs in order to use the new, better, nondefault
203 ;;interactive mode.
204 (eval-after-load "haskell-mode"
205 '(progn
206 (define-key haskell-mode-map (kbd "C-x C-d") nil)
207 (define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch)
208 (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-file)
209 (define-key haskell-mode-map (kbd "C-c C-b") 'haskell-interactive-switch)
210 (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
211 (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
212 (define-key haskell-mode-map (kbd "C-c M-.") nil)
213 (define-key haskell-mode-map (kbd "C-c C-d") nil)))
214
215 ;; ghc-mod install http://www.mew.org/~kazu/proj/ghc-mod/en/emacs.html
216 ;; todo, try this out
217 ;; (autoload 'ghc-init "ghc" nil t)
218 ;;(add-hook 'haskell-mode-hook (lambda () (ghc-init) (flymake-mode)))
219
220
221
222 ;; from the package readme for ghci-completion
223 (add-hook 'inferior-haskell-mode-hook 'turn-on-ghci-completion)
224
225
226 ;; disable some rebinds. they are set to appropriate keys in the keybinds section
227 (eval-after-load "haskell-mode"
228 '(progn
229 (define-key haskell-mode-map (kbd "C-a") 'nil)
230 (define-key haskell-mode-map (kbd "C-j") 'nil)))
231
232
233 (defun pretty-lambdas-haskell ()
234 (font-lock-add-keywords
235 nil `((,(concat "(?\\(" (regexp-quote "\\") "\\)")
236 (0 (progn (compose-region (match-beginning 1) (match-end 1)
237 ,(make-char 'greek-iso8859-7 107))
238 nil))))))
239 ;; from haskell-mode manual
240 (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
241 (when (window-system)
242 (add-hook 'haskell-mode-hook 'pretty-lambdas-haskell))
243
244 ;; added from haskell-mode website install instructions
245 ;(load "/usr/share/emacs/site-lisp/haskell-mode/haskell-site-file")
246 (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
247 ;;the three indentation modules are mutually exclusive - add at most one. Trying out the "most advanced"
248 (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
249 ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
250 ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
251
252
253 ;; todo, set this to some other key
254 ;; (local-set-key (kbd "C-e") 'my-haskell-load-and-run)
255
256 (defun my-haskell-load-and-run ()
257 "Loads and runs the current Haskell file."
258 (interactive)
259 (let ((start-buffer (current-buffer)))
260 (inferior-haskell-load-and-run inferior-haskell-run-command)
261 (sleep-for 0 100)
262 (end-of-buffer)
263 (pop-to-buffer start-buffer)))
264
265 ;; show haskell function in mode line
266 ;; todo, this broke after updating emacs
267 ;;(eval-after-load "which-func"
268 ;; '(add-to-list 'which-func-modes 'haskell-mode))
269
270
271
272 (add-hook 'interactive-haskell-mode-hook 'ac-haskell-process-setup)
273 (add-hook 'haskell-interactive-mode-hook 'ac-haskell-process-setup)
274 (eval-after-load "auto-complete"
275 '(add-to-list 'ac-modes 'haskell-interactive-mode))
276
277 (add-hook 'haskell-mode-hook
278 (lambda () (define-key haskell-mode-map (kbd "C-(")
279 (lambda () (interactive)
280 (basic-save-buffer)
281 (haskell-compile)
282 (run-with-timer .3 nil 'repeat-shell)))))
283 (add-hook 'haskell-cabal-mode-hook
284 (lambda () (define-key haskell-cabal-mode-map (kbd "C-(") 'haskell-compile)))
285
286
287
288 (add-hook 'haskell-interactive-mode-hook
289 (lambda ()
290 (define-key haskell-interactive-mode-map "\r" nil)
291 (define-key haskell-interactive-mode-map (kbd "RET")
292 'haskell-interactive-mode-return)))
293 (add-hook 'haskell-indentation-mode-hook (lambda () (define-key haskell-indentation-mode-map "\r" nil)))
294
295
296
297 (add-hook 'haskell-interactive-mode-hook
298 (lambda ()
299 (define-key haskell-interactive-mode-map (kbd "<C-M-return>") 'haskell-interactive-mode-newline-indent)))
300
301
302 ;;; mediawiki
303
304 (eval-after-load "mediawiki"
305 '(progn
306 (remove-hook 'outline-minor-mode-hook 'mediawiki-outline-magic-keys)
307 (add-hook 'mediawiki-mode-hook
308 (lambda () (define-key mediawiki-mode-map (kbd "C-(") 'mediawiki-save-reload)))
309
310 ;; mediawiki mode has a bug that it will claim an edit conflict unless you reload after saving.
311 ;; I also like to save with no edit summary for previewing on my local mw instance
312 (defun mediawiki-save-reload ()
313 (interactive)
314 (and (mediawiki-save "") (mediawiki-reload)))))
315
316
317 (setq org-caldav-url "https://cal.iankelling.org"
318 org-caldav-calendar-id "ian"
319 org-caldav-inbox "/p/cal.org")
320 ;;(org-caldav-sync)
321
322
323 ;;(require 'dtrt-indent)
324 ;;(setq dtrt-indent-mode t)
325
326
327 ;; gnu global
328 (add-hook 'c-mode-common-hook
329 (lambda () (ggtags-mode 1)
330 (setq c-label-minimum-indentation 0)))
331
332 (defun my-ggtags-init()
333 ;; specific to my unusual keybind setup, you may want to
334 ;; pick different keys
335 (define-key ggtags-mode-map (kbd "C-M-o") 'ggtags-find-tag-dwim)
336 (define-key ggtags-mode-map (kbd "C-M-m") 'ggtags-grep))
337 (eval-after-load "ggtags" '(my-ggtags-init))
338
339
340 (defun gtags-update-single(filename)
341 "Update Gtags database for changes in a single file"
342 (interactive)
343 (start-process "update-gtags" "update-gtags" "bash" "-c" (concat "cd " ggtags-project-root " ; gtags --single-update " filename )))
344
345 (defun gtags-update-current-file()
346 (interactive)
347 (let ((rel-filename (replace-regexp-in-string
348 ggtags-project-root "."
349 (buffer-file-name (current-buffer)))))
350 (gtags-update-single rel-filename)))
351
352 (defun gtags-update-hook()
353 "Update GTAGS file incrementally upon saving a file"
354 (when (and (boundp 'ggtags-mode) ggtags-mode ggtags-project-root)
355 (gtags-update-current-file)))
356
357 (add-hook 'after-save-hook 'gtags-update-hook)
358
359 ;; i'd like to make some elisp which modifies a keymap to remove
360 ;; all binds which don't match a predicate.
361 ;; I tried setting a keymap to a new keymap,
362 ;; but that didn't register as functional.
363 ;; so I'd need to modify the list in place.
364
365 ;; colorize hex colors: use rainbow mode
366
367
368 (global-set-key (kbd "C-M-w") 'spray-mode)
369 ;; remember, h/l = move. f/s = faster/slower, space = pause, all others quit
370
371
372 ;; disabled because it takes 400ms on startup
373 ;; ;; emacs regexes are too limited.
374 ;; (require 'foreign-regexp)
375 ;; ;; perl is most powerful, but javascript is pretty close and
376 ;; ;; I'd rather know javascript stuff than perl
377 ;; (custom-set-variables
378 ;; '(foreign-regexp/regexp-type 'javascript) ;; Choose by your preference.
379 ;; '(reb-re-syntax 'foreign-regexp)) ;; Tell re-builder to use foreign regexp.
380 ;; ;; it would be nice to add documentation to do this for more commands to that package
381 ;; ;; disabled because it's too slow. but I'd still m-x it for advanced replacements
382 ;; ;;(define-key global-map [remap isearch-forward-regexp] 'foreign-regexp/isearch-forward)
383
384
385 ;;;; keybinds for wow mouse
386
387 (global-set-key (kbd "<mouse-6>") 'move-mouse-to-point)
388 (global-set-key (kbd "<kp-left>") 'indent-region)
389 (global-set-key (kbd "<kp-begin>") 'mark-defun)
390 (global-set-key (kbd "<kp-right>") 'ibuffer)
391 (global-set-key (kbd "<kp-prior>") 'delete-horizontal-space)
392
393
394 ;; give us a shell to start instead of scratch
395 ;;(setq initial-buffer-choice (lambda () (new-shell)))
396
397
398 ;;; smartparens
399 ;; the melpa git version had a catastrophic bug I reported.
400 ;; downgraded to marmalade version and everything is working fine.
401 (require 'smartparens-config)
402
403 (defun gp/sp/pair-on-newline-and-indent (id action context)
404 "Open a new brace or bracket expression, with relevant newlines and indent. "
405 (save-excursion
406 (newline)
407 (indent-according-to-mode))
408 (indent-according-to-mode))
409
410 ;; when opening a pair, and then inserting a newline, push the closing pair to another newline
411 (sp-pair "{" nil :post-handlers
412 '(:add ((lambda (id action context)
413 (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
414 (sp-pair "[" nil :post-handlers
415 '(:add ((lambda (id action context)
416 (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
417
418
419 ;; in my version, this is not a pairing.
420 ;; not sure if it is in a future version since I reverted to marmalade
421 ;; Don't need c-comments in strings -- they frustrate filename globs
422 ;; (sp-pair "/*" nil :unless '(sp-in-string-p))
423
424 ;; Don't need quotes to pair next to words
425 (sp-pair "\"" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
426 (sp-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
427
428
429 ;; todo, testout these mode specific settings from graphene.
430 ;; Ruby-specific pairs and handlers
431
432 (eval-after-load "ruby"
433 '(require 'smartparens-ruby))
434
435 ;; Markdown
436 (sp-local-pair '(markdown-mode gfm-mode) "*" "*"
437 :unless '(sp-in-string-p)
438 :actions '(insert wrap))
439
440 ;; Except in HTML
441 (sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p))
442
443
444
445
446 ;; alias the new `flymake-report-status-slim' to
447 ;; `flymake-report-status'
448 (defalias 'flymake-report-status 'flymake-report-status-slim)
449 (defun flymake-report-status-slim (e-w &optional status)
450 "Show \"slim\" flymake status in mode line."
451 (when e-w
452 (setq flymake-mode-line-e-w e-w))
453 (when status
454 (setq flymake-mode-line-status status))
455 (let* ((mode-line " Φ"))
456 (when (> (length flymake-mode-line-e-w) 0)
457 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
458 (setq mode-line (concat mode-line flymake-mode-line-status))
459 (setq flymake-mode-line mode-line)
460 (force-mode-line-update)))
461
462
463
464
465 ;; this seems like it could be useful, but I havent been using it, so disabled
466 ;; from http://www.emacswiki.org/emacs/TransposeWindows
467 (setq swapping-buffer nil)
468 (setq swapping-window nil)
469 (defun swap-buffers-in-windows ()
470 "Swap buffers between two windows"
471 (interactive)
472 (if (and swapping-window
473 swapping-buffer)
474 (let ((this-buffer (current-buffer))
475 (this-window (selected-window)))
476 (if (and (window-live-p swapping-window)
477 (buffer-live-p swapping-buffer))
478 (progn (switch-to-buffer swapping-buffer)
479 (select-window swapping-window)
480 (switch-to-buffer this-buffer)
481 (select-window this-window)
482 (message "Swapped buffers."))
483 (message "Old buffer/window killed. Aborting."))
484 (setq swapping-buffer nil)
485 (setq swapping-window nil))
486 (progn
487 (setq swapping-buffer (current-buffer))
488 (setq swapping-window (selected-window))
489 (message "Buffer and window marked for swapping."))))
490
491 (global-set-key (kbd "C-M-d") 'swap-buffers-in-windows)