annotate .elisp/settings/40.modes.el @ 494:ef22f075b638

hgrc: also ignore NoBackup dir where I hide stuff from time machine
author Augie Fackler <raf@durin42.com>
date Wed, 01 Jul 2020 18:46:56 -0400
parents 601884c45f8a
children
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)
257
31f86a5707ee c++: enable tab completion
Augie Fackler <durin42@gmail.com>
parents: 224
diff changeset
18 (add-hook 'c++-mode-hook 'af-tab-fix)
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 (add-hook 'sh-mode-hook 'af-tab-fix)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 (add-hook 'emacs-lisp-mode-hook 'af-tab-fix)
217
e4842709368a emacs: move colors to their own file and migrate to whitespace from wspace
Augie Fackler <durin42@gmail.com>
parents: 202
diff changeset
21
353
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
22 (defun af-c-mode-hook ()
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
23 (interactive)
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
24 (if (string-match "mercurial/" buffer-file-name)
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
25 (progn
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
26 (message "looks like an hg c file, using kernel style")
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
27 (c-set-style "linux")
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
28 (setq indent-tabs-mode t)
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
29 (setq whitespace-style (remove 'indentation (remove 'tabs whitespace-style))))))
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
30 (add-hook 'c-mode-common-hook 'af-c-mode-hook)
95621f473f7e c-mode: detect when I'm editing a .c file from hg and set style appropriately
Augie Fackler <raf@durin42.com>
parents: 341
diff changeset
31
217
e4842709368a emacs: move colors to their own file and migrate to whitespace from wspace
Augie Fackler <durin42@gmail.com>
parents: 202
diff changeset
32 ;; disable whitespace cleanup in modes sensitive to whitespace
189
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
33 (defun af-no-clean-whitespace ()
223
739d96003993 af-no-clean-whitespace: make interactive for easy disabling when it is just noise.
Augie Fackler <durin42@gmail.com>
parents: 218
diff changeset
34 (interactive)
189
0487f0197755 emacs: disable whitespace-cleanup in makefiles, highlight tabs in makefiles
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
35 (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
36 (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
37 (add-hook 'rst-mode-hook 'af-no-clean-whitespace)
217
e4842709368a emacs: move colors to their own file and migrate to whitespace from wspace
Augie Fackler <durin42@gmail.com>
parents: 202
diff changeset
38 (add-hook 'makefile-mode-hook 'af-no-clean-whitespace)
341
0a593d2c0595 diff-mode: don't clean whitespace
Augie Fackler <raf@durin42.com>
parents: 310
diff changeset
39 (add-hook 'diff-mode-hook 'af-no-clean-whitespace)
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 (autoload 'js2-mode "js2" nil t)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 (add-hook 'js2-mode-hook 'af-tab-fix)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44
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 '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
46 (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
47 (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
48 '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
49 (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
50 'textmate-find-in-project-type)))
121
8989839d4c6c Rakefiles are ruby too.
Augie Fackler <durin42@gmail.com>
parents: 120
diff changeset
51 (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
52
107
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
53 (require 'django-html-mode)
16b57e1fc23d Add django-html-mode.
Augie Fackler <durin42@gmail.com>
parents: 102
diff changeset
54 ;; 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
55 (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
56 (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
57 (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
58 (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
59 (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
60 'reindent-then-newline-and-indent)))
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 (defun af-python-mode-hook ()
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 ; highlight tabs in Python
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 (make-variable-buffer-local 'font-lock-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 (af-tab-fix)
94
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") ["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
66 "Comment Out Region")
120
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 116
diff changeset
67 (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
68 "Comment Out Region")
94
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
69 (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
70 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
71 (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
72 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
73 (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
74 "Comment Out Region")
9052c3801744 First stab at some menu items for the nose stuff.
Augie Fackler <durin42@gmail.com>
parents: 86
diff changeset
75 (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
76 (local-set-key "\M-n" 'nosetests-module)
16472f9a3543 Add some nosetests keybindings.
Augie Fackler <durin42@gmail.com>
parents: 101
diff changeset
77 (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
78 (local-set-key (kbd "RET") 'comment-indent-new-line)
430
5843408c9a38 modes: try and clean up python indentation a bit
Augie Fackler <raf@durin42.com>
parents: 353
diff changeset
79 ; Match existing indentation in a file
5843408c9a38 modes: try and clean up python indentation a bit
Augie Fackler <raf@durin42.com>
parents: 353
diff changeset
80 (python-indent-guess-indent-offset)
77
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 )
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 (add-hook 'python-mode-hook 'af-python-mode-hook)
45d7441d0cf2 Modularize .emacs
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83
79
26f1ccac509c Bind g to recompile in compilation-mode buffers.
Augie Fackler <durin42@gmail.com>
parents: 77
diff changeset
84 (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
85
fed1da889f84 emacs: enable column-number-mode
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
86 (column-number-mode)
202
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
258
863f1503616f emacs java: adjustments from actual java hackery
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
89 (defun af-annotation-fix (unused)
202
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
90 "fix indentation after an annotation"
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
91 (save-excursion
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
92 (beginning-of-line)
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
93 (forward-word -1)
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
94 (if (eq (char-before) ?@) ;; There's an annotation there
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
95 0
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
96 (+ c-basic-offset c-basic-offset))))
84eb8c90ada9 modes: handle annotations better
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
97
258
863f1503616f emacs java: adjustments from actual java hackery
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
98 (defun af-java-mode-hook ()
863f1503616f emacs java: adjustments from actual java hackery
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
99 (c-set-offset 'topmost-intro-cont 'af-annotation-fix)
863f1503616f emacs java: adjustments from actual java hackery
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
100 (local-set-key (kbd "RET") 'comment-indent-new-line)
863f1503616f emacs java: adjustments from actual java hackery
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
101 (af-tab-fix))
863f1503616f emacs java: adjustments from actual java hackery
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
102 (add-hook 'java-mode-hook 'af-java-mode-hook)
218
b9b118dba61a emacs: make diff-mode mq-aware
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
103
b9b118dba61a emacs: make diff-mode mq-aware
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
104 ;; mq diff-mode support
b9b118dba61a emacs: make diff-mode mq-aware
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
105 (add-to-list 'auto-mode-alist '("\\.hg/patches/" . diff-mode))
b9b118dba61a emacs: make diff-mode mq-aware
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
106 (defun mq-patch-set-default-directory ()
b9b118dba61a emacs: make diff-mode mq-aware
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
107 (when (string= ".hg" (nth 2 (reverse (split-string default-directory "/"))))
b9b118dba61a emacs: make diff-mode mq-aware
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
108 (setq default-directory (expand-file-name (concat default-directory "../../")))))
b9b118dba61a emacs: make diff-mode mq-aware
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
109 (add-hook 'diff-mode-hook 'mq-patch-set-default-directory)
310
6a773ec78813 emacs: edit tempfiles from mutt in mail-mode
Augie Fackler <raf@durin42.com>
parents: 302
diff changeset
110
6a773ec78813 emacs: edit tempfiles from mutt in mail-mode
Augie Fackler <raf@durin42.com>
parents: 302
diff changeset
111 ;; Tempfiles from mutt should be edited in mail-mode.
6a773ec78813 emacs: edit tempfiles from mutt in mail-mode
Augie Fackler <raf@durin42.com>
parents: 302
diff changeset
112 (add-to-list 'auto-mode-alist '("/mutt" . mail-mode))
479
601884c45f8a emacs: switch to from-hg hg-test-mode config
Augie Fackler <raf@durin42.com>
parents: 430
diff changeset
113
601884c45f8a emacs: switch to from-hg hg-test-mode config
Augie Fackler <raf@durin42.com>
parents: 430
diff changeset
114 (if (file-exists-p "~/Programming/hg/crew/contrib/hg-test-mode.el")
601884c45f8a emacs: switch to from-hg hg-test-mode config
Augie Fackler <raf@durin42.com>
parents: 430
diff changeset
115 (progn
601884c45f8a emacs: switch to from-hg hg-test-mode config
Augie Fackler <raf@durin42.com>
parents: 430
diff changeset
116 (load "~/Programming/hg/crew/contrib/hg-test-mode.el")
601884c45f8a emacs: switch to from-hg hg-test-mode config
Augie Fackler <raf@durin42.com>
parents: 430
diff changeset
117 (add-to-list 'auto-mode-alist '("\\.t$'" . hg-test-mode))
601884c45f8a emacs: switch to from-hg hg-test-mode config
Augie Fackler <raf@durin42.com>
parents: 430
diff changeset
118 (add-hook 'hg-test-mode-hook 'af-no-clean-whitespace)))