diff --git a/.emacs.d/functions.el b/.emacs.d/functions.el deleted file mode 100644 index 8ceed5b..0000000 --- a/.emacs.d/functions.el +++ /dev/null @@ -1,152 +0,0 @@ -(defun quote-region () - (interactive) - (let ((beginning (region-beginning)) - (end (region-end))) - (save-excursion - (goto-char end) - (insert ?') - (goto-char beginning) - (insert ?')))) - -(defun what-face (pos) - "Find out which face the current position uses" - (interactive "d") - (let ((face (or (get-char-property (point) 'read-face-name) - (get-char-property (point) 'face)))) - (if face - (message "Face: %s" face) - (message "No face at %d" pos)))) - -(defun my-comp-finish-function (buf str) - "Don't show compilation window if everything went ok" - (if (string-match "exited abnormally" str) - ;; there were errors - (message "compilation errors, press C-x ` to visit") - ;; no errors, make the compilation window go away in 0.5 seconds - (run-at-time 0.5 nil 'delete-windows-on buf) - (message "NO COMPILATION ERRORS!"))) - -(defun fullscreen () - "Fill the entire screen with emacs" - (interactive) - (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 - '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)) - (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 - '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))) - -(defun c-toggle-header-source () - "Toggle between a C source and header file" - (interactive) - (let ((ext (file-name-extension (buffer-file-name))) - (noext (file-name-sans-extension (buffer-file-name)))) - (if (string= (substring ext 0 1) "c") - (find-file (concat noext ".h")) - (find-file (concat noext ".c"))))) - -(defun browse-to-current-file () - "Show current file in browser" - (interactive) - (browse-url buffer-file-name)) - -(defun comment-line () - "Toggle comment on a line" - (interactive) - (save-excursion - (beginning-of-line) - (insert "//"))) - -(defun add-php-keywords () - "Designed for c and c-style languages - -Currently adds | & ! . + = - / % * , < > ? : ->" - ;; Add ! at the beginning of font lock - (font-lock-add-keywords - 'php-mode - '(("\\([!]\\|\\=>\\)" 1 font-lock-operator-face))) - ;; Add the rest at the end of font lock - (font-lock-add-keywords - 'php-mode - '(("\\(->\\|[|.+=&/%*,:?<>-]\\)" 1 font-lock-operator-face) - ("\\(;\\)" 1 font-lock-end-statement)) 1)) - -(defun add-html-keywords () - "Designed for html, show some smarty tags" - (font-lock-add-keywords - 'html-mode - '(("{\\(\\*.*\\*\\)}" 1 font-comment-face) - ("{\\/?\\(extends\\|block\\|foreach\\(else\\)?\\|if\\)" - 1 font-lock-builtin-face) - ("\\$\\(\\(?:\\sw\\|\\s_\\)+\\)\\(?:|\\(\\(?:\\sw\\|\\s_\\)+\\):\\)" - (1 font-lock-variable-name-face) - (2 font-lock-function-name-face)) - ("\\$\\(\\(?:\\sw\\|\\s_\\)+\\)" - 1 font-lock-variable-name-face) - ("{\\(\\(?:\\sw\\|\\s_\\)+\\).*}" - 1 font-lock-function-name-face)))) - -(defun buffer-major-mode (buffer-or-string) - "Find out which major-mode is currently used" - (with-current-buffer buffer-or-string major-mode)) - -(defun show-init-sections () - (interactive) - (occur ";;\s +.*\s +;;") - (other-window 1)) - -(defun list-functions () - (interactive) - (occur - "\\(?:\\(?:private\\|protected\\|public\\) \\)?function \\(?:\\sw\\)+(\\sw*)")) - -(defun insert-init-title (title width) - (interactive "stitle: \nnwidth: ") - (insert-char ?\; width) - (insert "\n;;") - (insert-char ?\s (floor (/ (- (- width 4.0) (length title)) 2))) - (insert title) - (insert-char ?\s (ceiling (/ (- (- width 4.0) (length title)) 2))) - (insert ";;\n") - (insert-char ?\; width)) - -(defun replace-occurrences (from to) - (save-excursion - (goto-char (point-min)) - (while (search-forward from nil t) - (replace-match to)))) - -(defun replace-html-special-chars () - (replace-occurrences "é" "é")) - -(defun on-before-save () - (if (eq (buffer-major-mode (current-buffer)) 'html-mode) - (replace-html-special-chars)) - (if (not (eq (buffer-major-mode (current-buffer)) 'markdown-mode)) - (delete-trailing-whitespace))) - -(defun on-after-save () - (let ((fname (buffer-file-name))) - (let ((suffix (file-name-extension fname))) - (if (string-equal suffix "el") - (byte-compile-file fname))))) - -(defun pretty-lambdas () - (font-lock-add-keywords - nil `(("(\\(lambda\\>\\)" - (0 (progn - (compose-region (match-beginning 1) - (match-end 1) - ?λ))))))) - -;; http://emacs-fu.blogspot.com/2009/01/navigating-through-source-code-using.html -(defun djcb-gtags-create-or-update () - "create or update the gnu global tag file" - (interactive) - (if (not (= 0 (call-process "global" nil nil nil " -p"))) ; tagfile - (let ((olddir default-directory) ; doesn't exist? - (topdir (read-directory-name - "gtags: top of source tree:" default-directory))) - (cd topdir) - (shell-command "gtags && echo 'created tagfile'") - (cd olddir)) ; restore - ;; tagfile already exists; update it - (shell-command "global -u && echo 'updated tagfile'"))) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 45effaa..c3dfd7e 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,7 +1,74 @@ ;; -*- mode: Emacs-Lisp; -*- (load "~/.emacs.d/ryuslash-load-path") (load "~/.emacs.d/functions") -;;; Theme + +;;-----[ Defun ]--------------------------------------------------------- +(defun oni/what-face (pos) + "Find out which face the current position uses" + (interactive "d") + (let ((face (or (get-char-property (point) 'read-face-name) + (get-char-property (point) 'face)))) + (if face + (message "Face: %s" face) + (message "No face at %d" pos)))) + +(defun oni/what-major-mode (buffer-or-string) + "Find out which major-mode is currently used" + (with-current-buffer buffer-or-string major-mode)) + +(defun oni/my-comp-finish-function (buf str) + "Don't show compilation window if everything went ok" + (if (string-match "exited abnormally" str) + ;; there were errors + (message "compilation errors, press C-x ` to visit") + ;; no errors, make the compilation window go away in 0.5 seconds + (run-at-time 0.5 nil 'delete-windows-on buf) + (message "NO COMPILATION ERRORS!"))) + +(defun oni/c-toggle-header-source () + "Toggle between a C source and header file" + (interactive) + (let ((ext (file-name-extension (buffer-file-name))) + (noext (file-name-sans-extension (buffer-file-name)))) + (if (string= (substring ext 0 1) "c") + (find-file (concat noext ".h")) + (find-file (concat noext ".c"))))) + +(defun oni/init-show-outline () + (interactive) + (occur ";;-----\\[ .* \\]-+") + (other-window 1)) + +(defun oni/replace-occurrences (from to) + (save-excursion + (goto-char (point-min)) + (while (search-forward from nil t) + (replace-match to)))) + +(defun oni/replace-html-special-chars () + (oni/replace-occurrences "é" "é")) + +(defun oni/before-save-hook () + (if (eq (oni/what-major-mode (current-buffer)) 'html-mode) + (oni/replace-html-special-chars)) + (if (not (eq (oni/what-major-mode (current-buffer)) 'markdown-mode)) + (delete-trailing-whitespace))) + +(defun oni/after-save-hook () + (let ((fname (buffer-file-name))) + (let ((suffix (file-name-extension fname))) + (if (string-equal suffix "el") + (byte-compile-file fname))))) + +(defun oni/pretty-lambdas () + (font-lock-add-keywords + nil `(("(\\(lambda\\>\\)" + (0 (progn + (compose-region (match-beginning 1) + (match-end 1) + ?λ))))))) + +;;-----[ Theme ]--------------------------------------------------------- (require 'naquadah-theme) (eval-after-load 'naquadah-theme (naquadah-theme-set-faces @@ -16,7 +83,7 @@ '(markdown-header-face-5 (:inherit 'org-level-5)) '(markdown-header-face-6 (:inherit 'org-level-6)))) -;;; Autopair +;;-----[ Autopair ]------------------------------------------------------ (require 'autopair) (autopair-global-mode t) ; automatically add the other delimiter (setq autopair-skip-criteria 'always @@ -24,23 +91,31 @@ autopair-blink nil) (setq-default autopair-dont-pair '(:string (?\' ?\") :comment (?\'))) -;;; Column marker +;;-----[ Column marker ]------------------------------------------------- (require 'column-marker) (defun set-column-markers (cm1 cm2) (column-marker-1 cm1) (column-marker-2 cm2)) -;;; Prog mode +;;-----[ Prog mode ]----------------------------------------------------- +(defconst integer-regex-1 + (eval-when-compile + (concat "\\b\\(0[xX][0-9a-fA-F]+[lL]?\\|[0-9]+\\.?[0-9]*\\([eE][-+]?" + "[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b"))) + +(defconst integer-regex-2 + (eval-when-compile + (concat "\\b\\(\\.[0-9]+\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]" + "\\)?\\)\\b"))) + (defun oni/prog-mode-hook () (font-lock-add-keywords nil - '(("\\b\\(0[xX][0-9a-fA-F]+[lL]?\\|[0-9]+\\.?[0-9]*\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b" - 0 font-lock-constant-face) - ("\\b\\(\\.[0-9]+\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b" - 0 font-lock-constant-face))) + `((,integer-regex-1 0 font-lock-constant-face) + (,integer-regex-2 0 font-lock-constant-face))) (rainbow-delimiters-mode) - (pretty-lambdas) + (oni/pretty-lambdas) (set-column-markers 73 81)) (if (>= emacs-major-version 24) @@ -49,17 +124,30 @@ (add-hook 'go-mode-hook 'oni/prog-mode-hook) (add-hook 'emacs-lisp-mode-hook 'oni/prog-mode-hook)) -;;; HTML mode +;;-----[ HTML mode ]----------------------------------------------------- (defun oni/html-mode-hook () (set-column-markers 73 81) - (local-set-key [f9] 'browse-to-current-file) (setq fill-column 73)) +(eval-after-load "sgml-mode" + (progn + (font-lock-add-keywords + 'html-mode + '(("{\\(\\*.*\\*\\)}" 1 font-comment-face) + ("{\\/?\\(extends\\|block\\|foreach\\(else\\)?\\|if\\|else\\)" + 1 font-lock-builtin-face) + ("\\$\\(\\(?:\\sw\\|\\s_\\)+\\)\\(?:|\\(\\(?:\\sw\\|\\s_\\)+\\):\\)" + (1 font-lock-variable-name-face) + (2 font-lock-function-name-face)) + ("\\$\\(\\(?:\\sw\\|\\s_\\)+\\)" + 1 font-lock-variable-name-face) + ("{\\(\\(?:\\sw\\|\\s_\\)+\\).*}" + 1 font-lock-function-name-face))))) + (add-hook 'html-mode-hook 'oni/html-mode-hook) (add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode)) -(add-html-keywords) -;;; Org mode +;;-----[ Org mode ]------------------------------------------------------ (require 'org-crypt) (require 'org-publish) @@ -97,15 +185,15 @@ (add-hook 'org-mode-hook 'oni/org-mode-hook) (org-crypt-use-before-save-magic) -;;; Rainbow delimiters +;;-----[ Rainbow delimiters ]-------------------------------------------- (require 'rainbow-delimiters) (setq rainbow-delimiters-max-face-count 8) -;;; Uniquify +;;-----[ Uniquify ]------------------------------------------------------ (require 'uniquify) (setq uniquify-buffer-name-style 'post-forward) -;;; Go mode +;;-----[ Go mode ]------------------------------------------------------- (defun oni/go-mode-hook () (turn-off-auto-fill)) @@ -115,14 +203,14 @@ (add-to-list 'auto-mode-alist '("\\.go$" . go-mode)) (add-hook 'go-mode-hook 'oni/go-mode-hook) -;;; Htmlize +;;-----[ Htmlize ]------------------------------------------------------- (require 'htmlize) (setq htmlize-output-type 'inline-css) -;;; Git +;;-----[ Git ]----------------------------------------------------------- (require 'git) -;;; Markdown mode +;;-----[ Markdown mode ]------------------------------------------------- (defun oni/markdown-mode-hook () (whitespace-mode 1) (turn-on-auto-fill)) @@ -132,11 +220,26 @@ (add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$". markdown-mode)) (add-hook 'markdown-mode-hook 'oni/markdown-mode-hook) -;;; Xmodmap mode +;;-----[ Xmodmap mode ]-------------------------------------------------- (autoload 'xmodmap-mode "xmodmap-mode" "Major mode for xmodmap" t) -(add-to-list 'auto-mode-alist '("\\.[xX]modmap\\(rc\\)?$" . xmodmap-mode)) +(add-to-list 'auto-mode-alist + '("\\.[xX]modmap\\(rc\\)?$" . xmodmap-mode)) -;;; Gtags +;;-----[ Gtags ]--------------------------------------------------------- +;; http://emacs-fu.blogspot.com/2009/01/navigating-through-source-code-using.html +(defun oni/gtags-create-or-update () + "create or update the gnu global tag file" + (interactive) + (if (not (= 0 (call-process "global" nil nil nil " -p"))) ; tagfile + (let ((olddir default-directory) ; doesn't exist? + (topdir (read-directory-name + "gtags: top of source tree:" default-directory))) + (cd topdir) + (shell-command "gtags && echo 'created tagfile'") + (cd olddir)) ; restore + ;; tagfile already exists; update it + (shell-command "global -u && echo 'updated tagfile'"))) + (defun oni/gtags-mode-hook () (local-set-key "\M-," 'gtags-find-tag) (local-set-key "\M-." 'gtags-find-rtag)) @@ -144,13 +247,13 @@ (autoload 'gtags-mode "gtags" "Minor mode for using gtags" t) (add-hook 'gtags-mode-hook 'oni/gtags-mode-hook) -;;; C mode +;;-----[ C mode ]-------------------------------------------------------- (defun oni/c-mode-common-hook () (gtags-mode t) - (djcb-gtags-create-or-update)) + (oni/gtags-create-or-update)) (defun oni/c-mode-hook () - (local-set-key [f8] 'c-toggle-header-source) + (local-set-key [f8] 'oni/c-toggle-header-source) (local-set-key [f9] 'compile) (local-set-key [C-m] 'newline-and-indent) (local-set-key [C-return] 'newline)) @@ -158,10 +261,15 @@ (add-hook 'c-mode-common-hook 'oni/c-mode-common-hook) (add-hook 'c-mode-hook 'oni/c-mode-hook) -;;; PHP mode +;;-----[ PHP mode ]------------------------------------------------------ +(defconst php-outline-regex + (eval-when-compile + (concat "\\(function .*(\\|\\(public\\|private\\|protected\\)\\( " + "static\\)? \\$\\|class \\sw\\)"))) + (defun oni/php-show-outline () (interactive) - (occur "\\(function .*(\\|\\(public\\|private\\|protected\\)\\( static\\)? \\$\\|class \\sw\\)")) + (occur php-outline-regex)) (defun oni/php-mode-hook () (c-set-offset 'arglist-intro '+) @@ -173,17 +281,28 @@ (set-column-markers 76 81) (flymake-mode 1)) +(eval-after-load "php-mode" + (progn + ;; Add ! at the beginning of font lock + (font-lock-add-keywords + 'php-mode + '(("\\([!]\\|\\=>\\)" 1 font-lock-operator-face))) + ;; Add the rest at the end of font lock + (font-lock-add-keywords + 'php-mode + '(("\\(->\\|[|.+=&/%*,:?<>-]\\)" 1 font-lock-operator-face) + ("\\(;\\)" 1 font-lock-end-statement)) 1))) + (autoload 'php-mode "php-mode" "Major mode for PHP" t) (setq-default php-mode-warn-if-mumamo-off nil) ; don't warn me about this (setq php-mode-force-pear t) (add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode)) (add-hook 'php-mode-hook 'oni/php-mode-hook) -(add-php-keywords) -;;; bidi +;;-----[ bidi ]---------------------------------------------------------- (setq-default bidi-display-reordering nil) -;;; Message +;;-----[ Message ]------------------------------------------------------- (defun oni/message-mode-hook () (turn-on-auto-fill) (turn-on-flyspell) @@ -191,137 +310,33 @@ (add-hook 'message-mode-hook 'oni/message-mode-hook) -;;; Gnus +;;-----[ Gnus ]---------------------------------------------------------- (setq gnus-init-file "~/.emacs.d/gnus") -;;; jabber +;;-----[ Jabber ]-------------------------------------------------------- (require 'jabber-autoloads) (setq jabber-account-list '(("ryuslash@gmail.com" (:network-server . "talk.google.com") (:connection-type . ssl)))) -;;; X11 +;;-----[ X11 ]----------------------------------------------------------- (when window-system (setq linum-format " %d") (global-unset-key "\C-z")) -;;; CLI +;;-----[ CLI ]----------------------------------------------------------- (when (not window-system) (setq linum-format "%d ")) -;;; Texinfo +;;-----[ Texinfo ]------------------------------------------------------- (add-hook 'texinfo-mode-hook 'turn-on-auto-fill) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; AUTOLOADS ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(autoload 'vala-mode "vala-mode" "Major mode for Vala" t) -(autoload 'csharp-mode "csharp-mode" "Major mode for C#" t) -(autoload 'sqlplus-mode "sqlplus" "Major mode for PL/SQL" t) -(autoload 'batch-mode "batch-mode" "Major mode for Batch" t) -(autoload 'graphviz-dot-mode "graphviz-dot-mode" "Major mode for dot" t) -(autoload 'cmake-mode "cmake-mode" "Major mode for CMake" t) -(autoload 'rainbow-mode "rainbow-mode" "Minor mode for colors" t) -(autoload 'stumpwm-mode "stumpwm-mode" "Major mode for stumpwm" t) -(autoload 'git-commit-mode "git-commit" "" t) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; VARIABLES ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defvar font-lock-operator-face 'font-lock-operator-face) -(defvar font-lock-end-statement 'font-lock-end-statement) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; SETTINGS ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(setq-default indent-tabs-mode nil) ; spaces, no tabs -(setq-default truncate-lines t) ; don't wrap -(setq-default tab-width 4) - -(setq inhibit-startup-message t) ; Don't show welcome screen -(setq require-final-newline t) ; Always put final newline -(setq inhibit-default-init t) ; Don't load default library -(setq scroll-conservatively 101) ; scroll only one line -(setq browse-url-browser-function 'browse-url-generic) -(setq browse-url-generic-program (getenv "BROWSER")) -(setq uniquify-buffer-name-style 'reverse) -(setq jit-lock-defer-time 0.2) ; Don't fontlock immediately -(setq ido-save-directory-list-file nil) -(setq ido-auto-merge-delay-time 2) ; Wait before fixing names -(setq mouse-autoselect-window t) -(setq pop-up-windows nil) - -(setq frame-title-format ; I don't like emacs@cloud, must have file - '(:eval ; name - (concat "emacs: " (buffer-name)))) - -(setq backup-directory-alist ; backup file location - `((".*" . ,temporary-file-directory))) - -(setq auto-save-file-name-transforms ; autosave file location - `((".*" ,temporary-file-directory t))) - -(setq default-frame-alist ; default frame settings - (append '((font . "DejaVu Sans Mono-11:antialias=true")))) -(setq initial-frame-alist ; initial frame settings - (append '((font . "DejaVu Sans Mono-11:antialias=true")))) - -(fset 'yes-or-no-p 'y-or-n-p) ; switch yes or no to y or n - -(tool-bar-mode -1) ; no toolbar -(menu-bar-mode -1) ; no menubar -(line-number-mode -1) ; don't show line number in splitter -(global-linum-mode t) ; Show line numbers in gutter -(column-number-mode t) ; show column number in splitter -(global-font-lock-mode t) ; show syntax highlighting, old -(delete-selection-mode t) ; delete selection upon typing -(show-paren-mode t) ; show the opposite paren -(ido-mode t) - -(add-to-list 'compilation-finish-functions 'my-comp-finish-function) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; FILE ASSOCIATIONS ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode)) -(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode)) -(add-to-list 'auto-mode-alist '("\\.cs$" . csharp-mode)) -(add-to-list 'auto-mode-alist '("\\.bat$" . batch-mode)) -(add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js-mode)) -(add-to-list 'auto-mode-alist '("CMakeLists\\.txt$" . cmake-mode)) -(add-to-list 'auto-mode-alist '("\\.cmake$" . cmake-mode)) -(add-to-list 'auto-mode-alist '("\\.css$" . css-mode)) -(add-to-list 'auto-mode-alist '("stumpwmrc" . stumpwm-mode)) -(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . git-commit-mode)) - -(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8)) -(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; KEYBINDS ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(global-set-key "\C-m" 'newline-and-indent) -(global-set-key (kbd "C-x n r") 'narrow-to-region) -(global-set-key [f5] '(lambda () - (interactive) - (revert-buffer nil t nil))) -(global-set-key [M-left] 'windmove-left) -(global-set-key [M-right] 'windmove-right) -(global-set-key [M-up] 'windmove-up) -(global-set-key [M-down] 'windmove-down) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; HOOKS ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(add-hook 'before-save-hook 'on-before-save) -(add-hook 'after-save-hook 'on-after-save) -(add-hook 'git-commit-mode-hook 'auto-fill-mode) -(add-hook 'css-mode-hook 'rainbow-mode) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; SKELETONS ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;-----[ Dot ]----------------------------------------------------------- +(autoload 'graphviz-dot-mode "graphviz-dot-mode" "Major mode for dot" t) +(add-to-list 'auto-mode-alist '("\\.dot$" . graphviz-dot-mode)) + +;;-----[ Cmake ]--------------------------------------------------------- (define-skeleton cmake-project-skeleton "A cmake project template file" "Name: " @@ -335,6 +350,87 @@ "set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})\n" "add_subdirectory(src)") +(autoload 'cmake-mode "cmake-mode" "Major mode for CMake" t) +(add-to-list 'auto-mode-alist '("CMakeLists\\.txt$" . cmake-mode)) +(add-to-list 'auto-mode-alist '("\\.cmake$" . cmake-mode)) + +;;-----[ Rainbow ]------------------------------------------------------- +(autoload 'rainbow-mode "rainbow-mode" "Minor mode for colors" t) + +;;-----[ Git-commit mode ]----------------------------------------------- +(autoload 'git-commit-mode "git-commit" "" t) +(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . git-commit-mode)) +(add-hook 'git-commit-mode-hook 'auto-fill-mode) + +;;-----[ Ido ]----------------------------------------------------------- +(ido-mode t) +(setq ido-save-directory-list-file nil) +(setq ido-auto-merge-delay-time 2) + +;;-----[ Js mode ]------------------------------------------------------- +(add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js-mode)) + +;;-----[ CSS mode ]------------------------------------------------------ +(add-to-list 'auto-mode-alist '("\\.css$" . css-mode)) + +;;-----[ Misc ]---------------------------------------------------------- +(defun oni/reload-buffer + (interactive) + (revert-buffer nil t nil)) + +(defvar font-lock-operator-face 'font-lock-operator-face) +(defvar font-lock-end-statement 'font-lock-end-statement) + +(setq-default indent-tabs-mode nil) +(setq-default truncate-lines t) +(setq-default tab-width 4) +(setq-default require-final-newline t) + +(setq inhibit-startup-message t) +(setq inhibit-default-init t) +(setq scroll-conservatively 101) +(setq browse-url-browser-function 'browse-url-generic) +(setq browse-url-generic-program (getenv "BROWSER")) +(setq uniquify-buffer-name-style 'reverse) +(setq jit-lock-defer-time 0.2) +(setq mouse-autoselect-window t) +(setq pop-up-windows nil) +(setq frame-title-format '(:eval (concat "emacs: " (buffer-name)))) +(setq backup-directory-alist `((".*" . ,temporary-file-directory))) +(setq auto-save-file-name-transforms + `((".*" ,temporary-file-directory t))) + +(setq default-frame-alist + (append '((font . "DejaVu Sans Mono-11:antialias=true")))) + +(setq initial-frame-alist + (append '((font . "DejaVu Sans Mono-11:antialias=true")))) + +(fset 'yes-or-no-p 'y-or-n-p) + +(tool-bar-mode -1) +(menu-bar-mode -1) +(line-number-mode -1) +(global-linum-mode t) +(column-number-mode t) +(global-font-lock-mode t) +(delete-selection-mode t) +(show-paren-mode t) + +(add-to-list 'compilation-finish-functions 'oni/my-comp-finish-function) + +(global-set-key "\C-m" 'newline-and-indent) +(global-set-key (kbd "C-x n r") 'narrow-to-region) +(global-set-key [f5] 'oni/reload-buffer) +(global-set-key [M-left] 'windmove-left) +(global-set-key [M-right] 'windmove-right) +(global-set-key [M-up] 'windmove-up) +(global-set-key [M-down] 'windmove-down) + +(add-hook 'before-save-hook 'oni/before-save-hook) +(add-hook 'after-save-hook 'oni/after-save-hook) +(add-hook 'css-mode-hook 'rainbow-mode) + (define-skeleton myaethon-set-varchar-docstring "A docstring for a varchar setter" "" @@ -410,6 +506,8 @@ (setq custom-file "~/.emacs.d/custom.el") (if (file-exists-p custom-file) (load custom-file)) + (defvar home-file "~/wiki.info" "File to open when starting") + (if (file-exists-p home-file) (info home-file))