;; git version of gnus ;; (add-to-list 'load-path "~/.emacs.d/src/gnus/lisp") ;; (eval-after-load "info" ;; (quote (add-to-list 'Info-default-directory-list "~/.emacs.d/src/gnus/texi"))) ;; needed for git version ;;(add-to-list 'load-path "~/.emacs.d/src/haskell-mode") ;;(require 'haskell-mode-autoloads) ;;(add-to-list 'Info-default-directory-list "~/.emacs.d/src/haskell-mode") ;; for using custom/upstream bbdb ;;(require 'bbdb-loaddefs "~/.emacs.d/src/bbdb/lisp/bbdb-loaddefs.el") ;;(setq bbdb-print-tex-path "~/.emacs.d/src/bbdb/tex") ;; iank: dunno what this was about ;;(add-hook 'server-visit-hook 'raise-frame) ;;;; alternate keyboards ;; todo, figure out an easy way to disable this when using external keyboard ;; (if (display-graphic-p) ;; (setq ;; enter-key (kbd "") ;; s-enter-key (kbd "") ;; c-m-enter-key (kbd "") ;; m-enter (kbd "") ;; c-enter (kbd "")) ;; (setq ;; enter-key (kbd "C-m") ;; s-enter-key (kbd "C-8") ;; c-m-enter-key (kbd "C-M-8") ;; m-enter (kbd "M-m") ;; c-enter (kbd "C-8"))) (setq tp (string= (system-name) "tp")) (setq x200 (string= (system-name) "x2")) (setq laptop-keyboard (or tp x200)) ;;; abreviations ;; turn on abbrev mode globally (setq-default abbrev-mode t) ;; default abbreviation mode file is .emacs.d/abbrev_defs. ;; add-global-abbrev, add-mode-abbrev for expansion at point ;; if all else fails, edit the abbrev file ;;; bbdb ;; based on bbdb manual ;; also has instructions to integrate with gnus, (bbdb-initialize 'message) ;; recommended by gnus, ;; but seems like it could be good to have set for other stuff (setq user-full-name "Ian Kelling") ;; general email setting? recommended by mu4e (setq message-kill-buffer-on-exit t) ;; use d instead (add-hook 'bbdb-mode-hook (lambda () (define-key bbdb-mode-map (kbd "C-k") nil)) ;; based on emacs24-starter-kit (setq bbdb-offer-save 'auto bbdb-notice-auto-save-file t bbdb-expand-mail-aliases t bbdb-canonicalize-redundant-nets-p t bbdb-complete-name-allow-cycling t) ) ;;(require 'bbdb-csv-import) ;;; yasnippet ;;; todo: learn and use yasnippet ;; cd ~/.emacs.d/src ;; git clone --recursive https://github.com/capitaomorte/yasnippet ;; touch snippets/.yas-make-groups ;; This all makes it so I can look through the default snippets ;; in the menu bar, but they don't show up elsewhere, because they are ;; mostly things I don't want. (require 'yasnippet) ;; this needs to be before yas-global-mode (setq yas-snippet-dirs (list "~/.emacs.d/snippets")) (yas-global-mode 1) (setq yas-also-auto-indent-first-line t yas-choose-tables-first t yas-use-menu (quote full) ;; this sets ido-prompt as first function yas-prompt-functions '(yas-ido-prompt yas-dropdown-prompt yas-x-prompt yas-completing-prompt yas-no-prompt)) ;; todo, explore this option for wrapping region ;; '(yas/wrap-around-region t)) (defun ac-common-setup () (add-to-list 'ac-sources 'ac-source-yasnippet)) ;;; haskell ;; useful comint-shell mode commands. If not prefaced with *, it means it is not in the haskell custom repl ;; *todo: setup haskell c-t toggle arrow keys ;; tab completion ;; C-q insert prev arg ;; C-( history search ;; c-m-left/right move to next/prev prompts ;; *c-enter, multi-line input ;; *s-delete, send input across windows. (i can implement this) ;; *c-m-l clear screen ;; *haskell-process-interrupt, c-cc terminate job (i can implement this maybe) ;; nice bash/readline functions missing in comint: ;; yank-nth-arg ;; operate-get-next ;; menu-complete ;; usefull comint commands: ;; c-cl : list historic command in temp buffer ;; C-c C-o comint-delete-output ;; comint-restore-input, todo: put this on a randomish c-c key ;; todo: ;; checkout haskell repl functions: ;; c-cv haskell-check, hlint ;; C-M-q prog-indent-sexp ;; c-c. haskell-mode-format-imports ;; C-c M-/ haskell-doc-check-active ;; haskell-process-generate-tags ;; haskell-process-cabal-build ;; haskell-cabal-command.. or something ;; haskell-process-restart ;; C-h v haskell-process-log ;; C-h v haskell-process-show-debug-tips ;; various not immediately useful functions: ;; haskell-process-add-dependency ;; haskell-process-touch-buffer ;; haskell-process-cd ;; haskell-process-unignore ;; haskell-process-reload-devel-main ;; rebind ;; home: C-a haskell-interactive-mode-beginning ;; c-return: C-j haskell-interactive-mode-newline-indent ;; up/down: haskell-interactive-mode-history-next ;; todo haskell mode better binds for: ;; 'haskell-process-load-file ;; 'haskell-process-do-type ;; 'haskell-process-do-info ;; 'inferior-haskell-send-decl ;; commands which don't work in haskell-interactive-mode(hi) vs inferior-haskell-mode(ih, default) ;; functions not in hi: ;; inferior-haskell-find-definition, use tags instead ;; inferior-haskell-find-haddock, todo, test if this works ;; redefined ih to hi ;; switch-to-haskell -> 'haskell-interactive-switch ;; haskell-process-load-file -> inferior-haskell-load-file ;; haskell-process-do-type -> inferior-haskell-type ;; switch-to-haskell -> haskell-interactive-switch ;; inferior-haskell-load-file -> 'haskell-process-load-file ;; haskell-mode installation from source, based on its readme ;; in the git directory, ;; make all ;; remove default option to not link the file (setq haskell-compile-command "ghc -Wall -ferror-spans -fforce-recomp %s") (add-hook 'haskell-indentation-mode-hook (lambda () (define-key haskell-indentation-mode-map [?\C-d] nil) (define-key haskell-indentation-mode-map (kbd "") 'haskell-indentation-delete-char))) ;;copied from haskell-mode docs in order to use the new, better, nondefault ;;interactive mode. (eval-after-load "haskell-mode" '(progn (define-key haskell-mode-map (kbd "C-x C-d") nil) (define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch) (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-file) (define-key haskell-mode-map (kbd "C-c C-b") 'haskell-interactive-switch) (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type) (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info) (define-key haskell-mode-map (kbd "C-c M-.") nil) (define-key haskell-mode-map (kbd "C-c C-d") nil))) ;; ghc-mod install http://www.mew.org/~kazu/proj/ghc-mod/en/emacs.html ;; todo, try this out ;; (autoload 'ghc-init "ghc" nil t) ;;(add-hook 'haskell-mode-hook (lambda () (ghc-init) (flymake-mode))) ;; from the package readme for ghci-completion (add-hook 'inferior-haskell-mode-hook 'turn-on-ghci-completion) ;; disable some rebinds. they are set to appropriate keys in the keybinds section (eval-after-load "haskell-mode" '(progn (define-key haskell-mode-map (kbd "C-a") 'nil) (define-key haskell-mode-map (kbd "C-j") 'nil))) (defun pretty-lambdas-haskell () (font-lock-add-keywords nil `((,(concat "(?\\(" (regexp-quote "\\") "\\)") (0 (progn (compose-region (match-beginning 1) (match-end 1) ,(make-char 'greek-iso8859-7 107)) nil)))))) ;; from haskell-mode manual (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan) (when (window-system) (add-hook 'haskell-mode-hook 'pretty-lambdas-haskell)) ;; added from haskell-mode website install instructions ;(load "/usr/share/emacs/site-lisp/haskell-mode/haskell-site-file") (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) ;;the three indentation modules are mutually exclusive - add at most one. Trying out the "most advanced" (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) ;; todo, set this to some other key ;; (local-set-key (kbd "C-e") 'my-haskell-load-and-run) (defun my-haskell-load-and-run () "Loads and runs the current Haskell file." (interactive) (let ((start-buffer (current-buffer))) (inferior-haskell-load-and-run inferior-haskell-run-command) (sleep-for 0 100) (end-of-buffer) (pop-to-buffer start-buffer))) ;; show haskell function in mode line ;; todo, this broke after updating emacs ;;(eval-after-load "which-func" ;; '(add-to-list 'which-func-modes 'haskell-mode)) (add-hook 'interactive-haskell-mode-hook 'ac-haskell-process-setup) (add-hook 'haskell-interactive-mode-hook 'ac-haskell-process-setup) (eval-after-load "auto-complete" '(add-to-list 'ac-modes 'haskell-interactive-mode)) (add-hook 'haskell-mode-hook (lambda () (define-key haskell-mode-map (kbd "C-(") (lambda () (interactive) (basic-save-buffer) (haskell-compile) (run-with-timer .3 nil 'repeat-shell))))) (add-hook 'haskell-cabal-mode-hook (lambda () (define-key haskell-cabal-mode-map (kbd "C-(") 'haskell-compile))) (add-hook 'haskell-interactive-mode-hook (lambda () (define-key haskell-interactive-mode-map "\r" nil) (define-key haskell-interactive-mode-map (kbd "RET") 'haskell-interactive-mode-return))) (add-hook 'haskell-indentation-mode-hook (lambda () (define-key haskell-indentation-mode-map "\r" nil))) (add-hook 'haskell-interactive-mode-hook (lambda () (define-key haskell-interactive-mode-map (kbd "") 'haskell-interactive-mode-newline-indent))) ;;; mediawiki (eval-after-load "mediawiki" '(progn (remove-hook 'outline-minor-mode-hook 'mediawiki-outline-magic-keys) (add-hook 'mediawiki-mode-hook (lambda () (define-key mediawiki-mode-map (kbd "C-(") 'mediawiki-save-reload))) ;; mediawiki mode has a bug that it will claim an edit conflict unless you reload after saving. ;; I also like to save with no edit summary for previewing on my local mw instance (defun mediawiki-save-reload () (interactive) (and (mediawiki-save "") (mediawiki-reload))))) (setq org-caldav-url "https://cal.iankelling.org" org-caldav-calendar-id "ian" org-caldav-inbox "/p/cal.org") ;;(org-caldav-sync) ;;(require 'dtrt-indent) ;;(setq dtrt-indent-mode t) ;; gnu global (add-hook 'c-mode-common-hook (lambda () (ggtags-mode 1) (setq c-label-minimum-indentation 0))) (defun my-ggtags-init() ;; specific to my unusual keybind setup, you may want to ;; pick different keys (define-key ggtags-mode-map (kbd "C-M-o") 'ggtags-find-tag-dwim) (define-key ggtags-mode-map (kbd "C-M-m") 'ggtags-grep)) (eval-after-load "ggtags" '(my-ggtags-init)) (defun gtags-update-single(filename) "Update Gtags database for changes in a single file" (interactive) (start-process "update-gtags" "update-gtags" "bash" "-c" (concat "cd " ggtags-project-root " ; gtags --single-update " filename ))) (defun gtags-update-current-file() (interactive) (let ((rel-filename (replace-regexp-in-string ggtags-project-root "." (buffer-file-name (current-buffer))))) (gtags-update-single rel-filename))) (defun gtags-update-hook() "Update GTAGS file incrementally upon saving a file" (when (and (boundp 'ggtags-mode) ggtags-mode ggtags-project-root) (gtags-update-current-file))) (add-hook 'after-save-hook 'gtags-update-hook) ;; i'd like to make some elisp which modifies a keymap to remove ;; all binds which don't match a predicate. ;; I tried setting a keymap to a new keymap, ;; but that didn't register as functional. ;; so I'd need to modify the list in place. ;; colorize hex colors: use rainbow mode (global-set-key (kbd "C-M-w") 'spray-mode) ;; remember, h/l = move. f/s = faster/slower, space = pause, all others quit ;; disabled because it takes 400ms on startup ;; ;; emacs regexes are too limited. ;; (require 'foreign-regexp) ;; ;; perl is most powerful, but javascript is pretty close and ;; ;; I'd rather know javascript stuff than perl ;; (custom-set-variables ;; '(foreign-regexp/regexp-type 'javascript) ;; Choose by your preference. ;; '(reb-re-syntax 'foreign-regexp)) ;; Tell re-builder to use foreign regexp. ;; ;; it would be nice to add documentation to do this for more commands to that package ;; ;; disabled because it's too slow. but I'd still m-x it for advanced replacements ;; ;;(define-key global-map [remap isearch-forward-regexp] 'foreign-regexp/isearch-forward) ;;;; keybinds for wow mouse (global-set-key (kbd "") 'move-mouse-to-point) (global-set-key (kbd "") 'indent-region) (global-set-key (kbd "") 'mark-defun) (global-set-key (kbd "") 'ibuffer) (global-set-key (kbd "") 'delete-horizontal-space) ;; give us a shell to start instead of scratch ;;(setq initial-buffer-choice (lambda () (new-shell))) ;;; smartparens ;; the melpa git version had a catastrophic bug I reported. ;; downgraded to marmalade version and everything is working fine. (require 'smartparens-config) (defun gp/sp/pair-on-newline-and-indent (id action context) "Open a new brace or bracket expression, with relevant newlines and indent. " (save-excursion (newline) (indent-according-to-mode)) (indent-according-to-mode)) ;; when opening a pair, and then inserting a newline, push the closing pair to another newline (sp-pair "{" nil :post-handlers '(:add ((lambda (id action context) (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET")))) (sp-pair "[" nil :post-handlers '(:add ((lambda (id action context) (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET")))) ;; in my version, this is not a pairing. ;; not sure if it is in a future version since I reverted to marmalade ;; Don't need c-comments in strings -- they frustrate filename globs ;; (sp-pair "/*" nil :unless '(sp-in-string-p)) ;; Don't need quotes to pair next to words (sp-pair "\"" nil :unless '(sp-point-before-word-p sp-point-after-word-p)) (sp-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p)) ;; todo, testout these mode specific settings from graphene. ;; Ruby-specific pairs and handlers (eval-after-load "ruby" '(require 'smartparens-ruby)) ;; Markdown (sp-local-pair '(markdown-mode gfm-mode) "*" "*" :unless '(sp-in-string-p) :actions '(insert wrap)) ;; Except in HTML (sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p)) ;; alias the new `flymake-report-status-slim' to ;; `flymake-report-status' (defalias 'flymake-report-status 'flymake-report-status-slim) (defun flymake-report-status-slim (e-w &optional status) "Show \"slim\" flymake status in mode line." (when e-w (setq flymake-mode-line-e-w e-w)) (when status (setq flymake-mode-line-status status)) (let* ((mode-line " Φ")) (when (> (length flymake-mode-line-e-w) 0) (setq mode-line (concat mode-line ":" flymake-mode-line-e-w))) (setq mode-line (concat mode-line flymake-mode-line-status)) (setq flymake-mode-line mode-line) (force-mode-line-update))) ;; this seems like it could be useful, but I havent been using it, so disabled ;; from http://www.emacswiki.org/emacs/TransposeWindows (setq swapping-buffer nil) (setq swapping-window nil) (defun swap-buffers-in-windows () "Swap buffers between two windows" (interactive) (if (and swapping-window swapping-buffer) (let ((this-buffer (current-buffer)) (this-window (selected-window))) (if (and (window-live-p swapping-window) (buffer-live-p swapping-buffer)) (progn (switch-to-buffer swapping-buffer) (select-window swapping-window) (switch-to-buffer this-buffer) (select-window this-window) (message "Swapped buffers.")) (message "Old buffer/window killed. Aborting.")) (setq swapping-buffer nil) (setq swapping-window nil)) (progn (setq swapping-buffer (current-buffer)) (setq swapping-window (selected-window)) (message "Buffer and window marked for swapping.")))) (global-set-key (kbd "C-M-d") 'swap-buffers-in-windows)