-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdavid.emacs
97 lines (77 loc) · 3.05 KB
/
david.emacs
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
;;Erlang mode
(add-to-list 'load-path "/opt/local/lib/erlang/lib/tools-2.6.8/emacs")
(setq erlang-root-dir "/opt/local/lib/erlang")
(setq exec-path (cons "/opt/local/lib/erlang/bin" exec-path))
(require 'erlang-start)
;;Flymake + syntaxerl (https://github.com/ten0s/syntaxerl)
(require 'flymake)
(defun flymake-erlang-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name temp-file
(file-name-directory buffer-file-name))))
(list "/Users/davidalmroth/add-ons/flymake-script/fly-compile"
(list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.erl\\'" flymake-erlang-init))
(defun my-erlang-mode-hook ()
(flymake-mode 1))
(add-hook 'erlang-mode-hook 'my-erlang-mode-hook)
;;Disable audio bell when scrolling up and down too far
(setq visible-bell t)
;; Always read file from disk automatically to prevent accidents after git pull
(global-auto-revert-mode t)
;; Enable copy + paste (Windows style)
(cua-mode t)
;; Show line-number in the mode line
(line-number-mode 1)
;; Show column-number in the mode line
(column-number-mode 1)
;;Warn with colors when lines are too long
(require 'whitespace)
(setq whitespace-style
(quote (face tabs trailing lines-trail lines whitespace-line)))
(custom-set-variables
'(global-whitespace-mode t)
)
;; I hate tabs!
(setq tab-width 4)
(setq-default indent-tabs-mode nil)
;;To make it possible to write [] and {} the normal Mac way on a keyboard
(setq mac-option-modifier nil
mac-command-modifier 'meta
x-select-enable-clipboard t)
;;David extra key bindings for Copy and Paste
(global-set-key "\M-c" 'clipboard-kill-ring-save)
(global-set-key "\M-n" 'clipboard-yank)
(global-set-key "\M-b" 'clipboard-yank)
;;Distel
(add-to-list 'load-path "~/add-ons/distel/rost-distel-ab45c21/elisp")
(require 'distel)
(distel-setup)
;; scroll x lines at a time, 3 is nice for Mac
;; (makes emacs vertical scroll less "jumpy" than defaults)
(setq mouse-wheel-scroll-amount '(3 ((shift) . 3)))
;;(add-hook 'erlang-mode-hook
;; (lambda ()
;; ;; when starting an Erlang shell in Emacs, default in the node name
;; (setq inferior-erlang-machine-options '("-sname" "emacs"))
;; ;; add Erlang functions to an imenu menu
;; (imenu-add-to-menubar "imenu")))
;; David & Andreas hackathon solution:
;; Transforms long host name like "Davids-MacBook-Pro-7.local"
;; "to Davids-MacBook-Pro-7" (removes everthing behind the first dot)
;; Why? -> Erlang remote shell requires this kind of short host name.
(defun short-host-name ()
(string-match "[^\.]+" system-name)
(substring system-name (match-beginning 0) (match-end 0))
)
;; default nodename for distel (= also for erlang-shell-connect-to-node)
(setq erl-nodename-cache (intern (concat "dev" "@" (short-host-name))))
;; connect to remote node
(defun erlang-shell-connect-to-node ()
(interactive)
(let* ((inferior-erlang-machine-options
(list "-sname" "emacs"
"-remsh" (format "%s" erl-nodename-cache))))
(erlang-shell-display)))