summaryrefslogtreecommitdiff
path: root/.emacs
blob: 50d6ae0c145f4365f564186167945626203f2c62 (plain)
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
;; -*- lexical-binding: t; -*-
;; Set up the keyboard so the delete key on both the regular keyboard
;; and the keypad delete the character under the cursor and to the right
;; under X, instead of the default, backspace behavior.

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;;(package-initialize)

(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)

(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)

;; My own key bindings ;;
;;(global-set-key [f1] 'compile)

;; Turn on font-lock mode for Emacs
(global-font-lock-mode t)

;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(error ((nil (:foreground "Red1"))))
 '(font-lock-builtin-face ((nil (:foreground "dark slate blue"))))
 '(font-lock-comment-face ((nil (:foreground "Firebrick"))))
 '(font-lock-comment-face ((nil (:foreground "red"))))
 '(font-lock-constant-face ((nil (:foreground "dark cyan"))))
 '(font-lock-function-name-face ((nil (:foreground "Blue1"))))
 '(font-lock-keyword-face ((nil (:foreground "Purple"))))
 '(font-lock-string-face ((nil (:foreground "VioletRed4"))))
 '(font-lock-type-face ((nil (:foreground "ForestGreen"))))
 '(font-lock-variable-name-face ((nil (:foreground "sienna"))))
 '(font-lock-warning-face ((nil (:foreground "Red1"))))
 '(warning ((nil (:foreground "DarkOrange"))))
)

;;(setq require-final-newline t)
(setq require-final-newline nil)
;; Stop at the end of the file, not just add lines
(setq next-line-add-newlines nil)

;; Display columns
(setq column-number-mode t)
(setq inhibit-splash-screen t)

;; vim-Scroll 
(setq scroll-conservatively 1)

;; European datatime format
(setq calendar-date-display-form
      '((if dayname (concat dayname ", ")) day " " monthname " " year))
(setq calendar-time-display-form
      '(24-hours ":" minutes (if time-zone " (") time-zone (if time-zone ")")))

;; week starts on Monday
(setq calendar-week-start-day 1)
(setq org-agenda-start-on-weekday 1)

;; display week numbers
(setq calendar-intermonth-text
      '(propertize
        (format "%2d"
                (car
                 (calendar-iso-from-absolute
                  (calendar-absolute-from-gregorian (list month day year)))))
        'font-lock-face 'font-lock-warning-face))

(setq calendar-intermonth-header
      (propertize "Wnr"                  ; or e.g. "KW" in Germany
                  'font-lock-face 'font-lock-keyword-face))

(add-hook 'calendar-load-hook
          (lambda ()
            (calendar-set-date-style 'european)))

;; sunrise / sunset
;; (setq calendar-latitude 59.98765)
;; (setq calendar-longitude 10.98765)
;; (setq calendar-location-name "Oslo")

;; Various
(setq auto-save-default nil)
(setq make-backup-files nil)
(setq display-time-24hr-format t)
(display-time-mode 1)

;; UTF-8 support (legacy workaround for Ubuntu)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)

(put 'downcase-region 'disabled nil)
(kill-buffer "*scratch*")

(setq split-height-threshold nil)
(setq split-width-threshold 160)

;; disable terminal mouse by default
(xterm-mouse-mode -1)


;; Programming section

;; Indentation
;;(setq-default c-basic-offset 4 tab-width 4 indent-tabs-mode nil js-indent-level 4 sgml-basic-offset 4)
(setq-default c-basic-offset 4 tab-width 4 indent-tabs-mode nil)
;;(setq js-indent-level 2)
;;(setq-default c-basic-offset 4 tab-width 4)

;; Default coding style
(setq c-default-style "bsd")

;; Don't attempt to guess the Python-indent
(setq python-indent-guess-indent-offset nil)

;; Bind .ino (Arduino project) extension to C++ mode
(add-to-list 'auto-mode-alist '("\\.ino\\'" . c++-mode))

;; Enable which-function-mode for C, C++ and Python
(setq which-func-modes '(c-mode c++-mode java-mode python-mode))
(which-function-mode t)

;; Python
(require 'whitespace)
(setq whitespace-line-column 79) ;; limit line length
(setq whitespace-style '(face lines-tail))
(add-hook 'prog-mode-hook 'whitespace-mode)
;;(add-hook 'python-mode-hook 'whitespace-mode)  ;; doesn't work in 29

;; Custom plugins
(add-to-list 'load-path "~/.emacs.d/lisp/")

;; PHP
;;(autoload 'php-mode "php-mode" "Mode for editing PHP source files")
;;(add-to-list 'auto-mode-alist '("\\.\\(inc\\|php[s34]?\\)" . php-mode))


;; Lua
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
;;(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))

;; Rust
;; (autoload 'rust-mode "rust-mode" nil t)
;; (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))

;; Markdown
(autoload 'markdown-mode "markdown-mode"
   "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

(autoload 'gfm-mode "markdown-mode"
   "Major mode for editing GitHub Flavored Markdown files" t)
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))


;; YAML
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))


;; yasnippet
(require 'yasnippet)
(yas-global-mode 1)
(yas/load-directory "~/.emacs.d/snippets")


;; nginx
;; (require 'nginx-mode)