summaryrefslogtreecommitdiffstats
path: root/emacs.el
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2011-06-26 12:41:49 +0200
committerGravatar Tom Willemsen2011-06-26 12:41:49 +0200
commit0786ae76879c18744431ed53aa60e6bba82f137f (patch)
treeaf6dcd06f414b2ecb7fc2089fd8d95dcbebbb77a /emacs.el
parent02c6f259b5a753fc514261b1f062126a68523b33 (diff)
downloaddotfiles-0786ae76879c18744431ed53aa60e6bba82f137f.tar.gz
dotfiles-0786ae76879c18744431ed53aa60e6bba82f137f.zip
EMACS: New modes, functions and keys
Added lua-mode Added muttrc-mode Moved all functions to emacs.d/functions.el Added go-mode Set keys M-left, M-right, M-up and M-down to move to relative windows
Diffstat (limited to 'emacs.el')
-rw-r--r--emacs.el235
1 files changed, 24 insertions, 211 deletions
diff --git a/emacs.el b/emacs.el
index 5b744e3..ef5ceb2 100644
--- a/emacs.el
+++ b/emacs.el
@@ -6,6 +6,7 @@
(add-to-list 'load-path "~/.emacs.d/naquadah-theme")
(add-to-list 'load-path "~/.emacs.d/elisp/markdown-mode")
(add-to-list 'load-path "~/.emacs.d/elisp/git-commit-mode")
+(add-to-list 'load-path "~/.emacs.d/elisp/lua-mode")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; REQUIRES ;;
@@ -20,217 +21,28 @@
(require 'server)
(require 'org-publish)
(require 'htmlize)
+(require 'muttrc-mode)
+(load-file "~/.emacs.d/functions.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AUTOLOADS ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(autoload 'vala-mode "vala-mode"
- "A Major mode for editing Vala files" t)
-(autoload 'csharp-mode "csharp-mode"
- "A Major mode for editing C# files" t)
-(autoload 'sqlplus-mode "sqlplus"
- "A Major mode for communicating with Oracle" t)
-(autoload 'batch-mode "batch-mode"
- "A Major mode for editing Batch files" t)
-(autoload 'lua-mode "lua-mode"
- "A Major mode for editing Lua files" t)
-(autoload 'php-mode "php-mode-improved"
- "A Major mode for editing PHP files" t)
-(autoload 'graphviz-dot-mode "graphviz-dot-mode"
- "A Major mode for editing graphviz dot files" t)
-(autoload 'cmake-mode "cmake-mode"
- "A major-mode for editing CMake sources" t)
-(autoload 'markdown-mode "markdown-mode"
- "Major mode for editing Markdown files" t)
-(autoload 'rainbow-mode "rainbow-mode"
- "A Minor mode for showing colors inline" t)
-(autoload 'stumpwm-mode "stumpwm-mode"
- "Special lisp mode for evaluating code into running stumpwm" t)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; DEFUNS ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(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\\|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 set-column-marker ()
- "Default column markers"
- (column-marker-1 73)
- (column-marker-2 81))
-
-(defun setup-system-frame-colours (&rest frame)
- (let ((f (if (car frame)
- (car frame)
- (selected-frame))))
- (progn
- (set-frame-font "-*-tamsyn-medium-*-*-*-15-*-*-*-*-80-*-*"))))
-
-(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 x-init ()
- "Start ide-skel and set some keys")
-
-(defun cli-init ()
- "Add a space to the linum column"
- (setq linum-format "%d "))
-
-(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 "é" "&eacute;"))
-
-(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 on-prog-mode ()
- (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)))
- (set-column-marker)
- (rainbow-delimiters-mode))
-
-(defun on-c-mode ()
- (local-set-key [f8] 'c-toggle-header-source)
- (local-set-key [f9] 'compile)
- (local-set-key [C-m] 'newline-and-indent)
- (local-set-key [C-return] 'newline))
-
-(defun on-html-mode ()
- (local-set-key [f9] 'browse-to-current-file)
- (auto-fill-mode)
- (set-column-marker))
-
-(defun on-markdown-mode ()
- (whitespace-mode)
- (auto-fill-mode))
-
-(defun on-org-mode ()
- (flyspell-mode 1)
- (auto-fill-mode 1))
-
-(defun on-php-mode ()
- (defvar php-warn-if-mumamo-off nil)
- (setq case-fold-search t)
- (c-set-offset 'arglist-intro '+)
- (c-set-offset 'arglist-close '0)
- (column-marker-1 76)
- (column-marker-2 81)
- (local-set-key [f6] 'comment-line))
-
-(defun on-mail-mode ()
- (turn-on-auto-fill)
- (search-forward "\n\n"))
+(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 'lua-mode "lua-mode" "A Major mode for Lua" t)
+(autoload 'php-mode "php-mode-improved" "Major mode for PHP" t)
+(autoload 'graphviz-dot-mode "graphviz-dot-mode" "Major mode for dot" t)
+(autoload 'cmake-mode "cmake-mode" "Major mode for CMake" t)
+(autoload 'markdown-mode "markdown-mode" "Major mode for Markdown" t)
+(autoload 'rainbow-mode "rainbow-mode" "Minor mode for colors" t)
+(autoload 'stumpwm-mode "stumpwm-mode" "Major mode for stumpwm" t)
+(autoload 'muttrc-mode "muttrc-mode" "Major mode for muttrc" t)
+;; Go
+(autoload 'go-mode "go-mode" "Major mode for google go" t)
+(autoload 'gofmt "go-mode" "" t)
+(autoload 'go-fmt-before-save "go-mode" "" t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; VARIABLES ;;
@@ -260,6 +72,7 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
(add-to-list 'auto-mode-alist '("mutt-cloud-" . mail-mode))
(add-to-list 'auto-mode-alist '("stumpwmrc" . stumpwm-mode))
+(add-to-list 'auto-mode-alist '("\\.go$" . go-mode))
(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))
@@ -275,7 +88,10 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(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)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; THEME SETTINGS ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -437,9 +253,6 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
" characters */"
'(fill-paragraph))
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; AUTORUN ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(org-crypt-use-before-save-magic)
(ad-activate 'server-create-window-system-frame)
(add-php-keywords)