[wplug] Emacs Magic
Zachary Uram
netrek at gmail.com
Thu Oct 15 13:04:14 EDT 2009
;;; Zachary Uram's GNU Emacs config file
;;; Version 1.0 (c) 05/08/09
;; set the fg/bg font colors
;(set-face-foreground 'default "lightgrey")
(set-face-foreground 'default "green")
;(set-face-background 'default "white")
(set-face-foreground 'bold "white")
;(set-face-background 'bold "white")
;(set-face-background 'mode-line "slategray3")
(set-face-background 'mode-line "black")
;; enable syntax highlighting - colors are pretty!
(setq-default font-lock-maximum-decoration t)
(if (fboundp 'global-font-lock-mode)
(global-font-lock-mode 1) ; GNU Emacs
(setq font-lock-auto-fontify t)) ; XEmacs
;;; C preferences
(setq c-basic-offset 2)
;; set tab width to 2 spaces
(setq-default tab-width 2)
(setq c-tab-width 2)
(require 'cc-mode)
(setq c-indent-level 2)
(setq c-brace-offset 0)
(setq c-brace-imaginary-offset 0)
(setq c-argdecl-indent 2)
(setq c-label-offset -2)
(setq c-continued-statement-offset 2)
(setq c-auto-newline t)
(setq c-tab-always-indent nil)
; Define the K&R C indenting style
(setq c-indent-level 4)
(setq c-continued-statement-offset 2)
(setq c-brace-offset 0)
(setq c-argdecl-indent 0)
(setq c-label-offset -4)
;; -----------------------[ cc-mode ]-----------------------
;; minor modes
(add-hook 'c-mode-common-hook
(lambda () (c-toggle-auto-hungry-state
1)))
;; indent
;(add-hook 'c-mode-common-hook
; (global-set-key (kbd "RET") 'newline-and-indent))
;; font lock settings
(setq c-font-lock-extra-types '())
(setq c-font-lock-extra-types
(append
'("Gdk\\sw+" "Gtk\\sw+" "gchar"
"guint" "gint" "glong" "gdouble"
"gpointer" "gboolean" "GList" "GSList")
c-font-lock-extra-types))
(setq auto-mode-alist
(append '(("\\.cpp$" . c++-mode)
("\\.hpp$" . c++-mode)
("\\.lsp$" . lisp-mode)
("\\.scm$" . scheme-mode)
("\\.pl$" . perl-mode)
) auto-mode-alist))
;; Auto font lock mode
(defvar font-lock-auto-mode-list
(list 'c-mode 'c++-mode 'c++-c-mode 'emacs-lisp-mode 'lisp-mode 'perl-mode
'scheme-mode)
"List of modes to always start in font-lock-mode")
(defvar font-lock-mode-keyword-alist
'((c++-c-mode . c-font-lock-keywords)
(perl-mode . perl-font-lock-keywords))
"Associations between modes and keywords")
(defun font-lock-auto-mode-select ()
"Automatically select font-lock-mode if the current major mode is
in font-lock-auto-mode-list"
(if (memq major-mode font-lock-auto-mode-list)
(progn
(font-lock-mode t))
)
)
;; Color errors
(setq compile-auto-highlight 'all)
;; activate show paren
(show-paren-mode 1)
(custom-set-variables
'(current-language-environment "English"))
;; set time to show in corner
(setq display-time-day-and-date t)
(display-time)
;;; perl mode
;; load cperl-mode for perl files
(fset 'perl-mode 'cperl-mode)
;;Show only the toplevel modules when loading a file
(add-hook `cperl-mode-hook `hide-body)
;;outline minor mode with cperl
(add-hook `cperl-mode-hook `outline-minor-mode)
;;Change the prefix for outline commands
(setq outline-minor-mode-prefix "C-co")
;; Enable wheelmouse support by default
(cond (window-system
(mwheel-install)))
;;; SLIME and generic Lisp
(require 'slime)
(setq inferior-lisp-program "/usr/bin/sbcl")
(slime-setup)
(add-hook 'lisp-mode-hook (lambda () (slime-mode t)))
(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
(add-to-list 'auto-mode-alist '("\\.cl$" . lisp-mode))
(add-to-list 'auto-mode-alist '("\\.l$" . lisp-mode))
(defun insert-current-time()
(interactive)
(insert (current-time-string)))
(define-key global-map "\C-ct" 'insert-current-time)
; for the purpose of not using cursor key.
(define-key global-map "\C-c," 'previous-buffer)
(define-key global-map "\C-c." 'next-buffer)
(define-key global-map "\C-cr" 'find-library)
(put 'upcase-region 'disabled nil)
(defun kill-this-word ()
"kill a word now pointed to"
(interactive)
(kill-region (progn (backward-word)(point)) (progn (forward-word) (point)))
)
(define-key global-map "\C-cd" 'kill-this-word)
;;; html helper mode
(add-hook 'html-helper-load-hook
'(lambda () (require'html-font)(font-lock-mode)))
(add-hook 'html-helper-mode-hook
'(lambda () (font-lock-fontify-buffer)))
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist
(append '(("\\.html$" . html-helper-mode)
("\\.shtml$" . html-helper-mode)
("\\.html$" . html-helper-mode)
("\\.shtml$" . html-helper-mode)
) auto-mode-alist))
(setq html-helper-build-new-buffer t)
(defvar html-helper-new-buffer-template
'("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/
html4/strict.dtd\">\n"
"<html>\n"
"<head>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n"
"<title>" p "</title>\n"
"<link rel=\"stylesheet\" href=\"\" type=\"text/css\">\n"
"<script type=\"text/javascript\" src=\"\"></script>\n"
"</head>\n"
"<body>\n"
html-helper-timestamp-start
html-helper-timestamp-end
"\n<addrss>netrek at gmail.com</address>\n"
"\n</body>\n</html>\n")
"*Template for new buffers, inserted by html-helper-insert-new-buffer-strings
if
html-helper-build-new-buffer is set to t")
;;; CSS mode
(autoload 'css-mode "css-mode")
(setq auto-mode-alist
(cons '("\\.css\\'" . css-mode) auto-mode-alist))
(setq cssm-indent-function #'cssm-c-style-indenter)
;;; Jscript mode
(add-to-list 'auto-mode-alist (cons "\\.js\\'" 'javascript-mode))
(autoload 'javascript-mode "javascript" nil t)
(setq js-indent-level 2)
;; show parentheses matching
(show-paren-mode t)
;; no annoying beeps
(set-message-beep nil)
;; show column and line (row) numbers
(line-number-mode t)
(column-number-mode t)
;; no annoying startup messages
(setq inhibit-startup-message t)
;(setq next-line-add-newlines nil)
(transient-mark-mode t)
(set-language-environment 'English)
(setq host (getenv "HOSTNAME"))
;; All done
(setq user-login-name (getenv "USER"))
(message "All done, %s%s" (user-login-name) ".")
More information about the wplug
mailing list