- Professional Skills
- Articles
- Bookmarklets
- Javascript Console For IE
- Neural Net Extension for Ruby
- Writing a PDF Generation Framework In Ruby
- Developing Mambo Components
- PayPal Website Payments Pro
- Bulk File Renaming
- Displaying a Maintenance Page
- Ruby: escape, unescape
- Clojure Tutorial For the Non-Lisp Programmer
- Complex mocking with PHPUnit
- PHP Coding Tips
- Simple CRUD Application
- External Links
- Recent posts
My dot emacs file (.emacs)
Submitted by moxley on Tue, 2006-09-19 18:32
It's not pretty, but it (mostly) works:
;; Set the load path
(setq load-path (cons "~/.emacs.d" load-path))
;; Don't make me type out 'yes' and 'no'
(fset 'yes-or-no-p 'y-or-n-p)
;; Color the code
(require 'font-lock)
(global-font-lock-mode t)
;; Set the starting appearance
(setq default-frame-alist
'(;;(cursor-color . "Firebrick")
(cursor-color . "White")
(cursor-type . box)
;;(foreground-color . "White")
;;(background-color . "DarkSlateGray")
(foreground-color . "White")
(background-color . "Black")
(vertical-scroll-bars . right)))
;;;;Change backup behavior to save in a directory, not in a miscellany
;;;;of files all over the place.
(setq
backup-by-copying t ; don't clobber symlinks
backup-directory-alist
'(("." . "~/.saves")) ; don't litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t) ; use versioned backups
;;;;Make sure that .emacs file is edited in lisp mode:
(setq auto-mode-alist (cons '("\.emacs" . lisp-mode) auto-mode-alist))
(setq default-tab-width 4)
;; Fix the worse part about emacs: indentation craziness
;; 1. When I hit the TAB key, I always want a TAB character inserted
;; 2. Don't automatically indent the line I am editing.
;; 3. When I hit C-j, I always want a newline, plus enough tabs to put me on
;; the same column I was at before.
;; 4. When I hit the BACKSPACE key to the right of a TAB character, I want the
;; TAB character deleted-- not replaced with tabwidth-1 spaces.
(defun newline-and-indent-relative ()
"Insert a newline, then indent relative to the previous line."
(interactive "*") (newline) (indent-relative))
(defun indent-according-to-mode () ())
(defalias 'newline-and-indent 'newline-and-indent-relative)
(defun my-c-hook ()
(defalias 'c-electric-backspace 'delete-backward-char)
(defun c-indent-command () (interactive "*") (self-insert-command 1)))
(add-hook 'c-mode-common-hook 'my-c-hook)
(defun indent-region-with-tab ()
(interactive)
(save-excursion
(if (< (point) (mark)) (exchange-point-and-mark))
(let ((save-mark (mark)))
(if (= (point) (line-beginning-position)) (previous-line 1))
(goto-char (line-beginning-position))
(while (>= (point) save-mark)
(goto-char (line-beginning-position))
(insert "\t")
(previous-line 1)))))
;;(global-set-key [?\C-x tab] 'indent-region-with-tab)
(global-set-key [f4] 'indent-region-with-tab)
(defun unindent-region-with-tab ()
(interactive)
(save-excursion
(if (< (point) (mark)) (exchange-point-and-mark))
(let ((save-mark (mark)))
(if (= (point) (line-beginning-position)) (previous-line 1))
(goto-char (line-beginning-position))
(while (>= (point) save-mark)
(goto-char (line-beginning-position))
(if (= (string-to-char "\t") (char-after (point))) (delete-char 1))
(previous-line 1)))))
; Moxley's php-mode customizations
(require 'php-mode)
(defun my-php-mode-common-hook ()
;; my customizations for php-mode
(setq tab-width 4)
(setq c-basic-offset 4)
(c-set-offset 'topmost-intro-cont 4)
(c-set-offset 'class-open 0)
(c-set-offset 'inline-open 0)
(c-set-offset 'substatement-open 0)
(c-set-offset 'arglist-intro '+)
)
(defun pear-php-mode-hook ()
(setq tab-width 4
c-basic-offset 4
indent-tabs-mode
(string-match "\.php$" (buffer-file-name))))
(add-hook 'php-mode-hook 'pear-php-mode-hook)
;; Hide password prompts
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt)
;; Display the time
(setq display-time-day-and-date t
display-time-24hr-format t)
(display-time)
;; Show the column number
(column-number-mode t)
;; Key bindings
(global-set-key [?\C-z] 'shell)
(global-set-key [?\C-x ?\C-g] 'goto-line)
(setq temporary-file-directory "/Users/moxleys/tmp")
(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.
)
(custom-set-variables
;; custom-set-variables 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.
'(c-offsets-alist nil))
(setq tramp-default-method "ssh")
(require 'tramp)
;;;;"I always compile my .emacs, saves me about two seconds
;;;;startuptime. But that only helps if the .emacs.elc is newer
;;;;than the .emacs. So compile .emacs if it's not."
(defun autocompile nil
"compile itself if ~/.emacs"
(interactive)
(require 'bytecomp)
(if (string= (buffer-file-name) (expand-file-name (concat
default-directory ".emacs")))
(byte-compile-file (buffer-file-name))))
(add-hook 'after-save-hook 'autocompile)


Cape Cod Cottage for Rent