Skip to content

Commit a3c2200

Browse files
author
Graham Lee
committed
objc, java modules
1 parent fcc72ad commit a3c2200

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

init.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
(when (and (>= emacs-major-version 23) (window-system)) ; frame
66
(load "~/.emacs.d/modules/window.el"))
77
(load "~/.emacs.d/modules/theme.el") ; color theme
8+
(load "~/.emacs.d/modules/objc.el") ; objc
9+
(load "~/.emacs.d/modules/java.el") ; java
810
(load "~/.emacs.d/modules/python.el") ; python

modules/java.el

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(add-hook 'java-mode-hook
2+
(lambda ()
3+
"Treat Java 1.5 @-style annotations as comments."
4+
(setq c-comment-start-regexp "(@|/(/|[*][*]?))")
5+
(modify-syntax-entry ?@ "< b" java-mode-syntax-table)))
6+
7+
(add-hook 'java-mode-hook (lambda ()
8+
(setq c-basic-offset 2)))
9+
10+
(add-hook 'java-mode-hook (lambda ()
11+
(setq c-basic-offset 2
12+
tab-width 2
13+
indent-tabs-mode t)))

modules/objc.el

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(add-to-list 'auto-mode-alist '("\\.mm\\'" . objc-mode))
2+
(add-to-list 'magic-mode-alist
3+
`(,(lambda ()
4+
(and (string= (file-name-extension buffer-file-name) "h")
5+
(re-search-forward "@\\<interface\\>"
6+
magic-mode-regexp-match-limit t)))
7+
. objc-mode))
8+
9+
(require 'find-file) ;; for the "cc-other-file-alist" variable
10+
(nconc (cadr (assoc "\\.h\\'" cc-other-file-alist)) '(".m" ".mm"))
11+
12+
(defadvice ff-get-file-name (around ff-get-file-name-framework
13+
(search-dirs
14+
fname-stub
15+
&optional suffix-list))
16+
"Search for Mac framework headers as well as POSIX headers."
17+
(or
18+
(if (string-match "\\(.*?\\)/\\(.*\\)" fname-stub)
19+
(let* ((framework (match-string 1 fname-stub))
20+
(header (match-string 2 fname-stub))
21+
(fname-stub (concat framework ".framework/Headers/" header)))
22+
ad-do-it))
23+
ad-do-it))
24+
(ad-enable-advice 'ff-get-file-name 'around 'ff-get-file-name-framework)
25+
(ad-activate 'ff-get-file-name)
26+
27+
(setq cc-search-directories '("." "../include" "/usr/include" "/usr/local/include/*"
28+
"/System/Library/Frameworks" "/Library/Frameworks"))
29+
30+
31+
(add-hook 'objc-mode-hook (lambda ()
32+
(setq c-basic-offset 2)))
33+
34+
(add-hook 'objc-mode-hook (lambda ()
35+
(setq c-basic-offset 2
36+
tab-width 2
37+
indent-tabs-mode t)))

0 commit comments

Comments
 (0)