annotate .elisp/settings/40.modes.el @ 109:8e04d9d41a55

reindent-then-newline-and-indent is the best discovery of the week.
author Augie Fackler <durin42@gmail.com>
date Wed, 17 Jun 2009 15:47:51 -0500
parents 16b57e1fc23d
children 6a64e61359b7
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)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 (add-hook 'rst-mode-hook '(lambda ()
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 (make-variable-buffer-local 'af-cleanup-whitespace)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 (set-variable 'af-cleanup-whitespace nil)))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 (autoload 'js2-mode "js2" nil t)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 (add-hook 'js2-mode-hook 'af-tab-fix)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27
82
89f6d05cd7d5 Fix some ruby mode keybindings.
Augie Fackler <durin42@gmail.com>
parents: 79
diff changeset
28 (add-hook 'ruby-mode-hook (lambda ()
109
8e04d9d41a55 reindent-then-newline-and-indent is the best discovery of the week.
Augie Fackler <durin42@gmail.com>
parents: 107
diff changeset
29 (af-tab-fix))
8e04d9d41a55 reindent-then-newline-and-indent is the best discovery of the week.
Augie Fackler <durin42@gmail.com>
parents: 107
diff changeset
30 (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
82
89f6d05cd7d5 Fix some ruby mode keybindings.
Augie Fackler <durin42@gmail.com>
parents: 79
diff changeset
31
107
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
32 (require 'django-html-mode)
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
33 ;; 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
34 (add-to-list 'auto-mode-alist '("\\.html$'" . django-html-mode))
109
8e04d9d41a55 reindent-then-newline-and-indent is the best discovery of the week.
Augie Fackler <durin42@gmail.com>
parents: 107
diff changeset
35 (define-key django-html-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
107
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
36
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 (defun af-python-mode-hook ()
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 ; highlight tabs in Python
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 (make-variable-buffer-local 'font-lock-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 (make-variable-buffer-local 'python-indent)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 (if (and buffer-file-name (string-match "melange" buffer-file-name))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 (set-variable 'python-indent 2))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 (af-tab-fix)
94
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
45 (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
46 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
47 (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
48 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
49 (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
50 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
51 (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
52 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
53 (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
54 (local-set-key "\M-n" 'nosetests-module)
16472f9a3543 Add some nosetests keybindings.
Augie Fackler <durin42@gmail.com>
parents: 101
diff changeset
55 (local-set-key "\M-\C-n" 'nosetests-one)
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 )
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 (add-hook 'python-mode-hook 'af-python-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58
79
26f1ccac509c Bind g to recompile in compilation-mode buffers.
Augie Fackler <durin42@gmail.com>
parents: 77
diff changeset
59 (add-hook 'compilation-mode-hook '(lambda () (local-set-key "g" 'recompile)))