|
| 1 | +;; -*- mode: emacs-lisp -*- |
| 2 | + |
| 3 | +(require 'xcscope) |
| 4 | +(require 'cc-mode) |
| 5 | + |
| 6 | +;; MELPA packages |
| 7 | + |
| 8 | +(require 'package) |
| 9 | +(add-to-list 'package-archives |
| 10 | + '("melpa" . "http://melpa.org/packages/") t) |
| 11 | +(when (< emacs-major-version 24) |
| 12 | + ;; For important compatibility libraries like cl-lib |
| 13 | + (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) |
| 14 | +(package-initialize) ;; You might already have this line |
| 15 | + |
| 16 | +(add-to-list 'package-archives |
| 17 | + '("melpa-stable" . "http://stable.melpa.org/packages/") t) |
| 18 | +;; set style |
| 19 | + |
| 20 | +(setq-default c-basic-offset 4 c-default-style "linux") |
| 21 | +(setq-default tab-width 4 indent-tabs-mode t) |
| 22 | +(define-key c-mode-base-map (kbd "RET") 'newline-and-indent) |
| 23 | + |
| 24 | +;; auto repair brackets |
| 25 | +;;(require 'autopair) |
| 26 | +;;(autopair-global-mode 1) |
| 27 | +;;(setq autopair-autowrap t) |
| 28 | + |
| 29 | +;;; yasnippet |
| 30 | +;;; should be loaded before auto complete so that they can work together |
| 31 | +;;(require 'yasnippet) |
| 32 | +;;(yas-global-mode 1) |
| 33 | + |
| 34 | +;;; auto complete mod |
| 35 | +;;; should be loaded after yasnippet so that they can work together |
| 36 | +(require 'auto-complete-config) |
| 37 | +(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict") |
| 38 | +(ac-config-default) |
| 39 | +;;; set the trigger key so that it can work together with yasnippet on tab key, |
| 40 | +;;; if the word exists in yasnippet, pressing tab will cause yasnippet to |
| 41 | +;;; activate, otherwise, auto-complete will |
| 42 | +(ac-set-trigger-key "TAB") |
| 43 | +(ac-set-trigger-key "<tab>") |
| 44 | + |
| 45 | +(require 'ac-clang) |
| 46 | +(define-key c++-mode-map (kbd "C-S-<return>") 'ac-complete-clang) |
| 47 | +;; replace C-S-<return> with a key binding that you want |
| 48 | + |
| 49 | +; change moving between windows to Shift+{left,up,down,right} |
| 50 | +(windmove-default-keybindings) |
| 51 | +(setq windmove-wrap-around t) |
| 52 | + |
| 53 | +; Save space |
| 54 | +(menu-bar-mode nil) |
| 55 | + |
| 56 | +; Handle .gz files |
| 57 | +(auto-compression-mode t) |
| 58 | + |
| 59 | +; Provide templates for new files |
| 60 | +(auto-insert-mode t) |
| 61 | + |
| 62 | +;display column number |
| 63 | +(column-number-mode 1) |
| 64 | + |
| 65 | + |
| 66 | +;;(defun my-c-mode-hook () |
| 67 | +;; (setq c-basic-offset 4 |
| 68 | +;; c-indent-level 4 |
| 69 | +;; c-default-style "cc-mode")) |
| 70 | +;;(add-hook 'c-mode-common-hook 'my-c-mode-hook) |
| 71 | + |
| 72 | +; Allow completions like em-s-region to complete to emacspeak-speak-region |
| 73 | +;;(partial-completion-mode) |
| 74 | + |
| 75 | +;; This somehow produced a failure on excelior |
| 76 | +;;(add-hook 'after-init-hook 'server-start) |
| 77 | +;;(add-hook 'server-done-hook |
| 78 | +;; (lambda () |
| 79 | +;; (shell-command "screen -r -X select `cat ~/tmp/emacsclient-caller`");;)) |
| 80 | + |
| 81 | +;;(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) |
| 82 | + |
| 83 | +;;(unless (featurep 'emacspeak) |
| 84 | +;; (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)) |
| 85 | + |
| 86 | +; Update string in the first 8 lines looking like Timestamp: <> or " " |
| 87 | +;;(add-hook 'write-file-hooks 'time-stamp) |
| 88 | + |
| 89 | +;;; Diary |
| 90 | +;(setq diary-file "~/emacs/diary") |
| 91 | +;(add-hook 'diary-hook 'appt-make-list) |
| 92 | +;(diary 0) |
| 93 | + |
| 94 | +;;; Eshell |
| 95 | +;;(eval-after-load "em-term" |
| 96 | + ;; '(add-to-list 'eshell-visual-commands "zsh")) |
| 97 | + |
| 98 | +;;; Gnus |
| 99 | +;;(setq gnus-init-file "~/emacs/.gnus.el") |
| 100 | + |
| 101 | +;;; Abbrevs |
| 102 | +; Use C-xaig to correct common typos |
| 103 | +(setq abbrev-file-name "~/emacs/abbrev_defs") |
| 104 | +(if (file-exists-p abbrev-file-name) |
| 105 | + (quietly-read-abbrev-file)) |
| 106 | +(set-default 'abbrev-mode t) |
| 107 | + |
| 108 | +;; Misc options I just prefer everytime |
| 109 | +(setq cperl-indent-level 2 |
| 110 | + custom-buffer-indent 2 |
| 111 | + gc-cons-threshold (* 1024 1024) |
| 112 | + european-calendar-style t |
| 113 | + mail-user-agent 'message-user-agent |
| 114 | + message-generate-headers-first t |
| 115 | + w3-display-frames 'ask |
| 116 | + widget-choice-toggle t |
| 117 | + widget-menu-minibuffer-flag t |
| 118 | + url-privacy-level '(os agent) |
| 119 | + vc-cvs-diff-switches "-u") |
| 120 | + |
| 121 | + |
| 122 | +(put 'narrow-to-region 'disabled nil) |
| 123 | + |
| 124 | +;;; Crypt++ |
| 125 | + |
| 126 | +(require 'crypt++ nil t) |
| 127 | +(setq crypt-encryption-type 'mcrypt) |
| 128 | + |
| 129 | +;;; Internet Time |
| 130 | + |
| 131 | +;(add-to-list 'load-path (expand-file-name "~/emacs/lisp/")) |
| 132 | +;(require 'itime) |
| 133 | +;(setq display-time-string-forms |
| 134 | +; '(24-hours ":" minutes " " |
| 135 | +; (itime-string 24-hours minutes seconds) |
| 136 | +; (if mail |
| 137 | +; " Mail" |
| 138 | +; "")) |
| 139 | +; display-time-interval 30) |
| 140 | +;(display-time-mode 1) |
| 141 | + |
| 142 | + |
| 143 | +;;; Load local configuration |
| 144 | +;;(condition-case data |
| 145 | +;; (let ((default-directory "~/emacs/")) |
| 146 | +;; (load-file "./local")) |
| 147 | +;; (file-error 'notfound)) |
| 148 | + |
| 149 | +;;; Load Customize |
| 150 | + |
| 151 | +;;(if (file-exists-p |
| 152 | +;; (setq custom-file; |
| 153 | +;; (concat "~/emacs/custom-" |
| 154 | +;; (int-to-string emacs-major-version)))) |
| 155 | +;; (load-file custom-file)) |
| 156 | + |
| 157 | +;;; Semantic |
| 158 | + |
| 159 | +;(unless (featurep 'emacspeak) |
| 160 | +; (global-semantic-auto-parse-mode 1) |
| 161 | +; (unless (featurep 'emacspeak) |
| 162 | +; (setq semantic-auto-parse-no-working-message t)) |
| 163 | +; (add-hook 'semantic-init-hooks 'senator-minor-mode)) |
| 164 | + |
| 165 | + |
| 166 | +;; Emacs wiki |
| 167 | + |
| 168 | +;;(require 'emacs-wiki) |
| 169 | +;;(add-to-list 'emacs-wiki-interwiki-names '("Bug" . "http://bugs.debian.org/")) |
| 170 | +;;(add-to-list 'emacs-wiki-interwiki-names '("Package" . "http://packages.debian.org/")) |
| 171 | +;;(setq |
| 172 | +;; emacs-wiki-projects |
| 173 | +;; '( |
| 174 | +;; ("PrivateNotes" |
| 175 | +;; (emacs-wiki-directories "~/doc/private")) |
| 176 | +;; ("DebianWiki" |
| 177 | +;; (emacs-wiki-directories "~/debian/notes") |
| 178 | +; (emacs-wiki-publishing-directory . "/[su/[email protected]]~/public_html/") |
| 179 | +;; (emacs-wiki-publishing-directory . "~/debian/public_html") |
| 180 | +;; ))) |
| 181 | + |
| 182 | +(when (featurep 'emacspeak) |
| 183 | + (defun viavoice-set-language (lang) |
| 184 | + (cond |
| 185 | + ((eq lang 'german) |
| 186 | + (dtk-interp-queue "`l4 Deutsch") |
| 187 | + (dtk-interp-speak)) |
| 188 | + ((eq lang 'english) |
| 189 | + (dtk-interp-queue "`l1 English") |
| 190 | + (dtk-interp-speak)) |
| 191 | + (t (error "Unknown language")))) |
| 192 | + (defun emacspeak-set-language-to-german () |
| 193 | + (interactive) |
| 194 | + (viavoice-set-language 'german)) |
| 195 | + (defun emacspeak-set-language-to-english () |
| 196 | + (interactive) |
| 197 | + (viavoice-set-language 'english)) |
| 198 | + (global-set-key (kbd "C-c e") 'emacspeak-set-language-to-english) |
| 199 | + (global-set-key (kbd "C-c d") 'emacspeak-set-language-to-german)) |
| 200 | + |
| 201 | +(define-prefix-command 'f8-map nil "f7=grep, f8=compile") |
| 202 | +(define-key f8-map [f8] 'compile) |
| 203 | +(define-key f8-map [f7] 'grep) |
| 204 | +(global-set-key [f8] 'f8-map) |
| 205 | +(custom-set-variables |
| 206 | + ;; custom-set-variables was added by Custom. |
| 207 | + ;; If you edit it by hand, you could mess it up, so be careful. |
| 208 | + ;; Your init file should contain only one such instance. |
| 209 | + ;; If there is more than one, they won't work right. |
| 210 | + '(column-number-mode t) |
| 211 | + '(load-home-init-file t t)) |
| 212 | +(custom-set-faces |
| 213 | + ;; custom-set-faces was added by Custom. |
| 214 | + ;; If you edit it by hand, you could mess it up, so be careful. |
| 215 | + ;; Your init file should contain only one such instance. |
| 216 | + ;; If there is more than one, they won't work right. |
| 217 | + '(default ((t (:family "DejaVu Sans" :foundry "unknown" :slant normal :weight normal :height 120 :width normal))))) |
| 218 | + |
| 219 | +;;(defun c-lineup-arglist-tabs-only (ignored) |
| 220 | +;; "Line up argument lists by tabs, not spaces" |
| 221 | +;; (let* ((anchor (c-langelem-pos c-syntactic-element)) |
| 222 | +;; (column (c-langelem-2nd-pos c-syntactic-element)) |
| 223 | +;; (offset (- (1+ column) anchor)) |
| 224 | +;; (steps (floor offset c-basic-offset))) |
| 225 | +;; (* (max steps 1) |
| 226 | +;; c-basic-offset))) |
| 227 | + |
| 228 | +;; Add kernel style |
| 229 | +;;(c-add-style |
| 230 | +;; "linux-tabs-only" |
| 231 | +;; '("linux" (c-offsets-alist |
| 232 | +;; (arglist-cont-nonempty |
| 233 | +;; c-lineup-gcc-asm-reg |
| 234 | +;; c-lineup-arglist-tabs-only)))) |
| 235 | +;;(custom-set-variables |
| 236 | +;; '(c-default-style "linux-tabs-only") |
| 237 | +;;) |
| 238 | + |
| 239 | +'(c-max-one-liner-length 80) |
| 240 | + |
| 241 | +'(fill-column 80) |
| 242 | +'(c-ignore-auto-fill (quote (string cpp))) |
| 243 | + |
| 244 | +; cedet semantic |
| 245 | +;;(semantic-mode 1) |
| 246 | + |
| 247 | +;;(require 'semantic/ia) |
| 248 | +;;(require 'semantic/bovine/gcc) |
| 249 | + |
| 250 | +;;(defun my-semantic-hook () |
| 251 | +;; (imenu-add-to-menubar "TAGS")) |
| 252 | +;;(add-hook 'semantic-init-hooks 'my-semantic-hook) |
| 253 | + |
| 254 | +(defun set-frame-size-according-to-resolution () |
| 255 | + (interactive) |
| 256 | + (if window-system |
| 257 | + (progn |
| 258 | + ;; use 120 char wide window for largeish displays |
| 259 | + ;; and smaller 80 column windows for smaller displays |
| 260 | + ;; pick whatever numbers make sense for you |
| 261 | + (if (> (x-display-pixel-width) 1280) |
| 262 | + (add-to-list 'default-frame-alist (cons 'width 120)) |
| 263 | + (add-to-list 'default-frame-alist (cons 'width 80))) |
| 264 | + ;; for the height, subtract a couple hundred pixels |
| 265 | + ;; from the screen height (for panels, menubars and |
| 266 | + ;; whatnot), then divide by the height of a char to |
| 267 | + ;; get the height we want |
| 268 | + (add-to-list 'default-frame-alist |
| 269 | + (cons 'height (/ (- (x-display-pixel-height) 200) |
| 270 | + (frame-char-height))))))) |
| 271 | + |
| 272 | +(set-frame-size-according-to-resolution) |
| 273 | + |
| 274 | +;;;;;;;;;; |
| 275 | +;;; c-mode |
| 276 | +(setq c-default-style '((c-mode . "cc-mode") |
| 277 | + (java-mode . "java") |
| 278 | + (awk-mode . "awk") |
| 279 | + (other . "cc-mode"))) |
| 280 | + |
| 281 | +(setq-default indent-tabs-mode nil) |
| 282 | +;;(setq-default c-default-style "cc-mode") |
| 283 | + |
| 284 | +;;defun my-c-mode-hook () |
| 285 | +;; (setq c-basic-offset 4 |
| 286 | +;; c-indent-level 4 |
| 287 | +;; c-default-style "cc-mode")) |
| 288 | +;;(add-hook 'c-mode-common-hook 'my-c-mode-hook) |
0 commit comments