-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsj-langs.el
212 lines (194 loc) · 7.28 KB
/
sj-langs.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
;;; sj-langs --- Programming language modes
;;
;; Copyright: Sudish Joseph <sudish@gmail.com>
;; Created: 1995-06-11
;; Octave
(require 'octave)
(push '("\\.m$" . octave-mode) auto-mode-alist)
;; SQL mode
(eval-when-compile (require 'sql))
(setq sql-product 'mysql
sql-electric-stuff 'semicolon)
;; eldoc: automatic docs in minibuffer
(autoload 'turn-on-eldoc-mode "eldoc" nil t)
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
;; CSS mode
(setq css-indent-offset 2)
;; javascript mode
(setq js-indent-level 2)
;; mmm-mode
(require 'mmm-auto)
(setq mmm-global-mode 'auto
mmm-submode-decoration-level 2
mmm-parse-when-idle t)
(mmm-add-mode-ext-class 'html-erb-mode "\\.html\\.erb\\'" 'erb)
(mmm-add-mode-ext-class 'html-erb-mode "\\.jst\\.ejs\\'" 'ejs)
(mmm-add-mode-ext-class 'html-erb-mode nil 'html-js)
(mmm-add-mode-ext-class 'html-erb-mode nil 'html-css)
(add-to-list 'auto-mode-alist '("\\.html\\.erb\\'" . html-erb-mode))
(add-to-list 'auto-mode-alist '("\\.jst\\.ejs\\'" . html-erb-mode))
;; nXML as primary mode (supports only JS and CSS subregions):
;; (mmm-add-mode-ext-class 'nxml-web-mode nil 'html-js)
;; (mmm-add-mode-ext-class 'nxml-web-mode nil 'html-css)
;; (add-to-list 'auto-mode-alist '("\\.xhtml\\'" . nxml-web-mode))
;; ruby-mode
(setq ruby-deep-indent-paren nil
ruby-deep-arglist nil)
(add-to-list 'viper-vi-state-mode-list 'ruby-mode)
(defun sj/ruby-mode-hook ()
(highlight-parentheses-mode t)
(require 'ruby-end)
(ruby-end-mode +1)
(require 'ruby-block)
(ruby-block-mode t)
(require 'ruby-electric)
(ruby-electric-mode t)
(setq autopair-dont-activate t
show-trailing-whitespace nil))
(eval-after-load 'ruby-mode
'(add-hook 'ruby-mode-hook 'sj/ruby-mode-hook))
;; yaml
(eval-after-load 'yaml-mode
'(define-key yaml-mode-map "\C-m" 'newline-and-indent))
;; cc-mode stuff
(eval-when-compile (require 'cc-mode))
(eval-when-compile (require 'dabbrev))
(defconst sj/c-style
'((c-echo-syntactic-information-p . t)
(c-tab-always-indent . t)
(c-hanging-comment-ender-p . nil)
(c-comment-continuation-stars . "* ")
(c-indent-comments-syntactically-p . t)
(c-cleanup-list . (;brace-else-brace
;empty-defun-braces
defun-close-semi
list-close-comma
scope-operator))
(c-hanging-colons-alist . ((case-label after)
(label after)))
(c-hanging-braces-alist . ((class-open after)
(inline-open after)
(brace-list-open)
(brace-list-intro before)
(brace-list-close)
(substatement-open after)
;(topmost-intro after)
(block-close . c-snug-do-while)))
(c-electric-pound-behavior . (alignleft))
;; copied from the K&R settings
(c-basic-offset . 2)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . 2)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(inline-open . 0)
(inextern-lang . 0)
(statement-case-open . 0)
(label . -)
(statement-cont . +))))
"Settings for my c-mode buffers. Copy at your own risk.")
(defun sj/c-electric-comma ()
"Add a newline after commas when preceded by braces.
See the docs for c-hanging-semi&comma-criteria."
(if (and (eq last-command-event ?,)
(save-excursion
(backward-char)
(skip-chars-backward " \t\n")
(eq (char-before) ?})))
t
nil))
(defun sj/c-mode-common-hook ()
(define-key c-mode-map "\C-m" 'newline-and-indent)
; (define-key viper-insert-local-user-map [backspace] 'c-electric-backspace)
; (define-key (current-local-map) [backspace] 'c-electric-backspace)
(c-add-style "PERSONAL" sj/c-style t)
(c-toggle-auto-hungry-state 1)
(setq indent-tabs-mode nil)
(pushnew 'sj/c-electric-comma c-hanging-semi&comma-criteria :test 'eq)
(set (make-local-variable 'dabbrev-case-replace) nil)
(set (make-local-variable 'dabbrev-case-fold-search) nil)
(setq fill-column 76)
(auto-fill-mode 1)
(turn-on-font-lock)
(setq viper-insert-local-user-map c-mode-map)
(setq imenu-create-index-function 'imenu-example--create-c-index))
(add-hook 'c-mode-common-hook 'sj/c-mode-common-hook)
;; cperl mode
(eval-when-compile (require 'cperl-mode))
(setq cperl-hairy nil
cperl-electric-parens "{"
cperl-font-lock t
cperl-electric-lbrace-space nil
cperl-electric-keywords t
cperl-electric-linefeed t
cperl-auto-newline t
;; indentation
cperl-indent-level 2
cperl-brace-offset -2
cperl-brace-imaginary-offset 0
cperl-label-offset -2
cperl-min-label-indent 1
cperl-continued-statement-offset 2
cperl-continued-brace-offset 0)
(add-hook 'cperl-mode-hook 'sj/cperl-mode-hook)
(defun sj/cperl-mode-hook ()
(viper-mode)
(setq viper-insert-local-user-map cperl-mode-map)
(turn-on-font-lock)
(highlight-parentheses-mode t)
(setq fill-column 76)
(local-set-key "\C-m" 'cperl-linefeed)
(local-set-key "\C-j" 'newline-and-indent))
;; prefer cperl-mode over perl-mode
(dolist (mode-alist '(auto-mode-alist interpreter-mode-alist))
(dolist (entry (symbol-value mode-alist))
(when (eq (cdr entry) 'perl-mode)
(setcdr entry 'cperl-mode))))
;; dmacro: dynamic macros
(sj/load-path-prepend "site-lisp/dmacro" t)
(require 'dmacro)
(dmacro-load (sj/emacs-path "dmacro/defaults.dm"))
(dmacro-load (sj/emacs-path "dmacro/elisp.dm"))
(dmacro-load (sj/emacs-path "dmacro/haskell.dm"))
(dmacro-load (sj/emacs-path "dmacro/makefile.dm"))
(dmacro-load (sj/emacs-path "dmacro/perl.dm"))
(dmacro-load (sj/emacs-path "dmacro/c.dm"))
(dmacro-load (sj/emacs-path "dmacro/c++.dm"))
(setq auto-dmacro-alist '(("\\.c\\(pp\\|xx\\|c\\)?$" . c_masthead)
("\\.h\\(pp\\|xx\\|h\\)?$" . h_masthead)
("\\.x$" . rpc_masthead)
("." . masthead)))
;; RPC .x files
(push '("\\.x$" . c-mode) auto-mode-alist)
;; imenu
(setq imenu-sort-function 'imenu--sort-by-name)
;; Load CEDET
;(setq semantic-load-turn-everything-on t)
;; (setq semantic-imenu-bucketize-file nil
;; semantic-imenu-expand-type-members nil
;; semanticdb-default-save-directory (expand-file-name "~/.semanticdb"))
;; (load-file (sj/emacs-path "external/cedet/common/cedet.el"))
;; * This enables some tools useful for coding, such as summary mode
;; imenu support, and the semantic navigator
;; (semantic-load-enable-code-helpers)
;; * This enables even more coding tools such as the nascent intellisense mode
;; decoration mode, and stickyfunc mode (plus regular code helpers)
;(semantic-load-enable-gaudy-code-helpers)
;; * This turns on which-func support (Plus all other code helpers)
;(semantic-load-enable-excessive-code-helpers)
;; add header file mappings for c/c++
;; (dolist (dir '("/opt/local/include" "/usr/local/include" "/usr/include"))
;; (when (file-directory-p dir)
;; (semantic-add-system-include dir 'c-mode)
;; (semantic-add-system-include dir 'c++-mode)))
;;
;; (dolist (dir (mapcar 'sj/emacs-path '("external/cedet/ede"
;; "external/cedet/eieio"
;; "external/cedet/semantic/doc"
;; "external/cedet/speedbar")))
;; (when (file-directory-p dir)
;; (add-to-list 'Info-additional-directory-list dir)))
;;; Local Variables:
;;; sj/recompile-file:t
;;; End: