annotate .elisp/settings/40.modes.el @ 212:4716b238db2e

emacs: add compilation-mode regexp for hg test tracebacks
author Augie Fackler <durin42@gmail.com>
date Thu, 13 May 2010 09:30:46 -0500
parents 84eb8c90ada9
children e4842709368a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 ; use tab for indent or complete
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 (defun indent-or-expand (arg)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 "Either indent according to mode, or expand the word preceding
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 point."
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 (interactive "*P")
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 (if (and
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 (or (bobp) (= ?w (char-syntax (char-before))))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 (or (eobp) (not (= ?w (char-syntax (char-after))))))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 (dabbrev-expand arg)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 (indent-according-to-mode)))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 (defun af-tab-fix ()
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 (local-set-key [tab] 'indent-or-expand))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 ;; add hooks for modes you want to use the tab completion for:
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 (set-variable 'af-cleanup-whitespace t)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 (add-hook 'c-mode-hook 'af-tab-fix)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 (add-hook 'sh-mode-hook 'af-tab-fix)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 (add-hook 'emacs-lisp-mode-hook 'af-tab-fix)
189
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
20 (defun af-no-clean-whitespace ()
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
21 (make-variable-buffer-local 'af-cleanup-whitespace)
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
22 (set-variable 'af-cleanup-whitespace nil))
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
23 (add-hook 'rst-mode-hook 'af-no-clean-whitespace)
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
24 (add-hook 'makefile-mode-hook '(lambda ()
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
25 (af-no-clean-whitespace)
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
26 (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs)))
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 (autoload 'js2-mode "js2" nil t)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 (add-hook 'js2-mode-hook 'af-tab-fix)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31
111
6a64e61359b7 Unbreaks this file, but I am not sure if the django stuff is working properly.
Augie Fackler <durin42@gmail.com>
parents: 109
diff changeset
32 (add-hook 'ruby-mode-hook '(lambda ()
6a64e61359b7 Unbreaks this file, but I am not sure if the django stuff is working properly.
Augie Fackler <durin42@gmail.com>
parents: 109
diff changeset
33 (af-tab-fix)
6a64e61359b7 Unbreaks this file, but I am not sure if the django stuff is working properly.
Augie Fackler <durin42@gmail.com>
parents: 109
diff changeset
34 (local-set-key (kbd "RET")
116
85d912e123af More ruby fixes, set html.erb to be some non-useless mode.
Augie Fackler <durin42@gmail.com>
parents: 111
diff changeset
35 'reindent-then-newline-and-indent)
85d912e123af More ruby fixes, set html.erb to be some non-useless mode.
Augie Fackler <durin42@gmail.com>
parents: 111
diff changeset
36 (local-set-key (kbd "C-M-f")
85d912e123af More ruby fixes, set html.erb to be some non-useless mode.
Augie Fackler <durin42@gmail.com>
parents: 111
diff changeset
37 'textmate-find-in-project-type)))
121
8989839d4c6c Rakefiles are ruby too.
Augie Fackler <durin42@gmail.com>
parents: 120
diff changeset
38 (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
82
89f6d05cd7d5 Fix some ruby mode keybindings.
Augie Fackler <durin42@gmail.com>
parents: 79
diff changeset
39
107
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
40 (require 'django-html-mode)
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
41 ;; I think I probably just always want it in django mode for now
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
42 (add-to-list 'auto-mode-alist '("\\.html$'" . django-html-mode))
116
85d912e123af More ruby fixes, set html.erb to be some non-useless mode.
Augie Fackler <durin42@gmail.com>
parents: 111
diff changeset
43 (add-to-list 'auto-mode-alist '("\\.html.erb$'" . django-html-mode))
85d912e123af More ruby fixes, set html.erb to be some non-useless mode.
Augie Fackler <durin42@gmail.com>
parents: 111
diff changeset
44 (add-to-list 'auto-mode-alist '("\\.rhtml$'" . django-html-mode))
111
6a64e61359b7 Unbreaks this file, but I am not sure if the django stuff is working properly.
Augie Fackler <durin42@gmail.com>
parents: 109
diff changeset
45 (add-hook 'django-html-mode-hook '(lambda ()
6a64e61359b7 Unbreaks this file, but I am not sure if the django stuff is working properly.
Augie Fackler <durin42@gmail.com>
parents: 109
diff changeset
46 (local-set-key (kbd "RET")
6a64e61359b7 Unbreaks this file, but I am not sure if the django stuff is working properly.
Augie Fackler <durin42@gmail.com>
parents: 109
diff changeset
47 'reindent-then-newline-and-indent)))
107
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
48
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 (defun af-python-mode-hook ()
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 ; highlight tabs in Python
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 (make-variable-buffer-local 'font-lock-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53 (make-variable-buffer-local 'python-indent)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 (if (and buffer-file-name (string-match "melange" buffer-file-name))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 (set-variable 'python-indent 2))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 (af-tab-fix)
94
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
57 (easy-menu-add-item nil '("Python") ["Run All Tests" nosetests-all t]
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
58 "Comment Out Region")
120
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 116
diff changeset
59 (easy-menu-add-item nil '("Python") ["Run All Tests with --failed" nosetests-failed t]
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 116
diff changeset
60 "Comment Out Region")
94
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
61 (easy-menu-add-item nil '("Python") ["Run Module Tests" nosetests-module t]
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
62 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
63 (easy-menu-add-item nil '("Python") ["Run One Test" nosetests-one t]
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
64 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
65 (easy-menu-add-item nil '("Python") ["Debug One Test" nosetests-pdb-one t]
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
66 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
67 (easy-menu-add-item nil '("Python") ["-" nil t] "Comment Out Region")
102
16472f9a3543 Add some nosetests keybindings.
Augie Fackler <durin42@gmail.com>
parents: 101
diff changeset
68 (local-set-key "\M-n" 'nosetests-module)
16472f9a3543 Add some nosetests keybindings.
Augie Fackler <durin42@gmail.com>
parents: 101
diff changeset
69 (local-set-key "\M-\C-n" 'nosetests-one)
140
7fa84e297c84 emacs modes: use comment-indent-new-line for python
Augie Fackler <durin42@gmail.com>
parents: 121
diff changeset
70 (local-set-key (kbd "RET") 'comment-indent-new-line)
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 )
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 (add-hook 'python-mode-hook 'af-python-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73
79
26f1ccac509c Bind g to recompile in compilation-mode buffers.
Augie Fackler <durin42@gmail.com>
parents: 77
diff changeset
74 (add-hook 'compilation-mode-hook '(lambda () (local-set-key "g" 'recompile)))
192
fed1da889f84 emacs: enable column-number-mode
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
75
fed1da889f84 emacs: enable column-number-mode
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
76 (column-number-mode)
202
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
77
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
78
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
79 (defun annotation-fix (unused)
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
80 "fix indentation after an annotation"
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
81 (save-excursion
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
82 (beginning-of-line)
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
83 (forward-word -1)
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
84 (if (eq (char-before) ?@) ;; There's an annotation there
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
85 0
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
86 (+ c-basic-offset c-basic-offset))))
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
87
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
88 (add-hook 'java-mode-hook
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
89 (lambda ()
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
90 (c-set-offset 'topmost-intro-cont
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
91 annotation-fix)))