annotate .elisp/settings/40.modes.el @ 94:9052c3801744

First stab at some menu items for the nose stuff.
author Augie Fackler <durin42@gmail.com>
date Mon, 27 Apr 2009 21:52:04 -0500
parents 68f53fa09e99
children 0c1db2df2bf8
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 ()
89f6d05cd7d5 Fix some ruby mode keybindings.
Augie Fackler <durin42@gmail.com>
parents: 79
diff changeset
29 (af-tab-fix)
89f6d05cd7d5 Fix some ruby mode keybindings.
Augie Fackler <durin42@gmail.com>
parents: 79
diff changeset
30 (local-set-key "\C-m" 'newline-and-indent)))
89f6d05cd7d5 Fix some ruby mode keybindings.
Augie Fackler <durin42@gmail.com>
parents: 79
diff changeset
31
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 (defun af-python-mode-hook ()
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 ; highlight tabs in Python
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 (make-variable-buffer-local 'font-lock-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 (add-hook 'font-lock-mode-hook 'show-ws-highlight-tabs)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 (make-variable-buffer-local 'python-indent)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 (if (and buffer-file-name (string-match "melange" buffer-file-name))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 (set-variable 'python-indent 2))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 (af-tab-fix)
94
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
40 (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
41 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
42 (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
43 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
44 (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
45 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
46 (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
47 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
48 (easy-menu-add-item nil '("Python") ["-" nil t] "Comment Out Region")
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 )
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 (add-hook 'python-mode-hook 'af-python-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51
79
26f1ccac509c Bind g to recompile in compilation-mode buffers.
Augie Fackler <durin42@gmail.com>
parents: 77
diff changeset
52 (add-hook 'compilation-mode-hook '(lambda () (local-set-key "g" 'recompile)))
26f1ccac509c Bind g to recompile in compilation-mode buffers.
Augie Fackler <durin42@gmail.com>
parents: 77
diff changeset
53
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 ; text-mode tries to use M-s for something other than my save shortcut.
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 ; That's evil. Stop it from doing that.
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 (add-hook 'text-mode-hook '(lambda ()
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 (define-key text-mode-map "\M-s"
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 'save-buffer)))