cosmin / shared-profile

This URL has Read+Write access

shared-profile / setup.el
100644 168 lines (132 sloc) 4.962 kb
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
(setq home-directory (getenv "HOME"))
(setq shared-profile-home (getenv "SHARED_PROFILE_HOME"))
(setq shared-profile-elisp (concat shared-profile-home "/emacs-lisp/"))
 
(if (string= (substring home-directory -1 nil) "/")
    (setq home-directory (substring home-directory nil -1)))
 
(if (string= (substring shared-profile-home -1 nil) "/")
    (setq shared-profile-home (substring shared-profile-home nil -1)))
 
(add-to-list 'load-path shared-profile-elisp)
(add-to-list 'load-path (concat shared-profile-elisp "python-mode/"))
(add-to-list 'load-path (concat shared-profile-elisp "git/"))
(add-to-list 'load-path (concat shared-profile-elisp "slime/"))
 
;; Put autosave files (ie #foo#) in one place
(defvar autosave-dir
 (concat "/tmp/emacs_autosaves/" (user-login-name) "/"))
 
(make-directory autosave-dir t)
 
(defun auto-save-file-name-p (filename)
  (string-match "^#.*#$" (file-name-nondirectory filename)))
 
(defun make-auto-save-file-name ()
  (concat autosave-dir
   (if buffer-file-name
      (concat "#" (file-name-nondirectory buffer-file-name) "#")
    (expand-file-name
     (concat "#%" (buffer-name) "#")))))
 
;; Put backup files (ie foo~) in one place too. (The backup-directory-alist
;; list contains regexp=>directory mappings; filenames matching a regexp are
;; backed up in the corresponding directory. Emacs will mkdir it if necessary.)
(defvar backup-dir (concat "/tmp/emacs_backups/" (user-login-name) "/"))
 
(make-directory backup-dir t)
 
(setq backup-directory-alist (list (cons "." backup-dir)))
 
;; make comint act more like ipython shell
(require 'comint)
(define-key comint-mode-map [(meta p)]
  'comint-previous-matching-input-from-input)
(define-key comint-mode-map [(meta n)]
  'comint-next-matching-input-from-input)
(define-key comint-mode-map [(control meta n)]
   'comint-next-input)
(define-key comint-mode-map [(control meta p)]
   'comint-previous-input)
 
 
;; git stuff
(require 'git)
(add-to-list 'vc-handled-backends 'GIT)
(autoload 'git-blame-mode "git-blame"
  "Minor mode for incremental blame for Git." t)
 
(define-key ctl-x-map "g" 'git-status)
 
;; ipython
(require 'ipython)
 
;; clojure stuff
(add-to-list 'load-path (concat shared-profile-home "/" "cljenv/emacs/"))
(require 'cljenv-autoload)
 
;; paren mode
(show-paren-mode 1)
 
;; objective-c stuff
 
(setq auto-mode-alist
      (cons '("\\.m$" . objc-mode) auto-mode-alist))
(setq auto-mode-alist
      (cons '("\\.mm$" . objc-mode) auto-mode-alist))
 
(defun xcode-compile ()
  (interactive)
  (let ((df (directory-files "."))
        (has-proj-file nil)
        )
    (while (and df (not has-proj-file))
      (let ((fn (car df)))
        (if (> (length fn) 10)
            (if (string-equal (substring fn -10) ".xcodeproj")
                (setq has-proj-file t)
              )
          )
        )
      (setq df (cdr df))
      )
    (if has-proj-file
        (compile "xcodebuild -configuration Debug")
      (compile "make")
      )
    )
  )
 
;; css mode
(autoload 'css-mode "css-mode")
(setq auto-mode-alist (cons '("\\.css$" . css-mode) auto-mode-alist))
 
;; js2 mode
;; (autoload 'js2-mode "js2")
;; (setq auto-mode-alist (cons '("\\.js$" . js2-mode) auto-mode-alist))
 
;; espresso mode and mozrepl
(autoload #'espresso-mode "espresso" "Start espresso-mode" t)
(add-to-list 'auto-mode-alist '("\\.js$" . espresso-mode))
(add-to-list 'auto-mode-alist '("\\.json$" . espresso-mode))
 
(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
(add-hook 'espresso-mode-hook 'espresso-custom-setup)
(defun espresso-custom-setup ()
  (moz-minor-mode 1))
 
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
 
;; show column number
(setq column-number-mode t)
 
;; ido mode
(setq ido-enable-flex-matching t)
(ido-mode t)
 
;; django html mode
(require 'django-html-mode)
 
;; CUDA stuff
(setq auto-mode-alist (append
                       '(("\\.cu$" . c++-mode))
                       auto-mode-alist))
 
;; show me the time
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
 
;; show me whitespace, allow to untabify
(require 'show-wspace)
(add-hook 'python-mode-hook 'show-ws-highlight-tabs)
(add-hook 'python-mode-hook 'show-ws-highlight-trailing-whitespace)
(define-key ctl-x-map "t" 'untabify)
(setq-default indent-tabs-mode nil)
 
;; tab indent or expand
 
(defun indent-or-expand (arg)
  "Either indent according to mode, or expand the word preceding
point."
  (interactive "*P")
  (if (and
       (or (bobp) (= ?w (char-syntax (char-before))))
       (or (eobp) (not (= ?w (char-syntax (char-after))))))
      (dabbrev-expand arg)
    (indent-according-to-mode)))
 
(defun my-tab-fix ()
  (local-set-key [tab] 'indent-or-expand))
 
;; add hooks for modes you want to use the tab completion for:
(add-hook 'python-mode-hook 'my-tab-fix)
(add-hook 'sh-mode-hook 'my-tab-fix)
(add-hook 'emacs-lisp-mode-hook 'my-tab-fix)
(add-hook 'clojure-mode-hook 'my-tab-fix)