Created
March 28, 2011 21:49
-
-
Save forkandwait/891362 to your computer and use it in GitHub Desktop.
My dot emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; set current working directory somewhere reasonable -- home. on | |
;; windows, set this in the short cut | |
(setq default-directory "~") | |
(cd "~") | |
;; MS Windows specific | |
(if (eq system-type 'windows-nt) | |
(progn (message "Running windows -- ack!") | |
(tool-bar-mode 0) | |
(setq temporary-file-directory "C:\\Temp") | |
(push "C:/GetGnuWin32/gnuwin32/bin" exec-path) | |
(setenv "PATH" (concat "C:\\GetGnuWin32\\gnuwin32\\bin;" | |
(getenv "PATH"))))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Overall stuff -- editing, saving etc | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; various nifty things | |
(menu-bar-mode 0) | |
(show-paren-mode 1) | |
(line-number-mode 1) | |
(column-number-mode 1) | |
(setq make-backup-files nil) | |
(setq auto-save-list-file-prefix nil) | |
(fset 'yes-or-no-p 'y-or-n-p) ;; Changes all yes/no questions abc to y/n type | |
(auto-compression-mode t) ;; Handle .gz files | |
(modify-syntax-entry ?_ "w") ;; make '_' a regular word symbol | |
(setq delete-selection-mode 1) | |
(setq show-paren-style 'expression) | |
(setq-default dabbrev-abbrev-skip-leading-regexp "[~!@#$%^&*()+=';`\\{}/.,\"]") ;; so we can dynamically complete %WS_MATCH etc | |
;; fontification stuff | |
(autoload 'font-lock-mode "font-lock") | |
(autoload 'turn-on-font-lock "font-lock") | |
(font-lock-mode t) | |
;;; Tell emacs to keep the point when we scroll back | |
(setq scroll-preserve-screen-position t) | |
(setq scroll-step 1) | |
;; allow up/down case | |
(put 'upcase-region 'disabled nil) | |
(put 'downcase-region 'disabled nil) | |
;; tabs - blech! | |
(setq default-tab-width 4) | |
(setq-default default-tab-width 4) | |
;; (setq indent-tabs-mode t) | |
;; (setq-default indent-tabs-mode t) | |
;; (setq c-basic-indent 4) | |
;; (setq-default tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 | |
;; 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120)) | |
;; (define-key text-mode-map (kbd "TAB") 'self-insert-command); | |
;; emulate search histor http://www.emacswiki.org/emacs/MinibufferHistory | |
(define-key minibuffer-local-map (kbd "M-p") 'previous-complete-history-element) | |
(define-key minibuffer-local-map (kbd "M-n") 'next-complete-history-element) | |
(define-key minibuffer-local-map (kbd "<up>") 'previous-complete-history-element) | |
(define-key minibuffer-local-map (kbd "<down>") 'next-complete-history-element) | |
;; Load fastnav thing for good zapping | |
(load-file "~/.emacs.d/fastnav.el") | |
(global-set-key (kbd "C-c z") 'zap-up-to-char-forward) | |
(global-set-key (kbd "C-c Z") 'zap-up-to-char-backward) | |
;; Load hide-region.el | |
(load-file "~/.emacs.d/hide-region.el") | |
(global-set-key (kbd "C-c h") 'hide-region-hide) | |
(global-set-key (kbd "C-c H") 'hide-region-unhide) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Program/ mode specific | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Load ess and sas mode customizations | |
(defun load-ess () | |
(interactive) | |
(load-file "~/.emacs.d/ess-5.13/lisp/ess-site.el") | |
(setq ess-sas-edit-keys-toggle t)) | |
(add-hook 'sas-mode-hook | |
'(lambda () | |
(setq fill-column 88) | |
(setq ess-sas-edit-keys-toggle t) | |
(setq tab-width 4) | |
(local-set-key (kbd "<return>") 'newline-and-indent) | |
(local-set-key (kbd "<tab>") '(insert " ")) | |
)) | |
;; octave customizations | |
(autoload 'octave-mode "octave-mod" nil t) | |
(setq auto-mode-alist | |
(cons '("\\.m$" . octave-mode) auto-mode-alist)) | |
;; text mode customizations | |
(add-hook 'text-mode-hook | |
'(lambda () | |
(auto-fill-mode 0) | |
(setq fill-column 88) | |
(setq tab-width 4) | |
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 | |
64 68 72 76 80 84 88 92 96 100 104 108 112 116 120)) | |
(modify-syntax-entry ?_ "w") ; now '_' is not considered a word-delimiter | |
(modify-syntax-entry ?- "w") ; now '-' is not considered a word-delimiter | |
)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Longwinded definitions and macros, usually accompanied by key | |
;; bindings | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Sorts all the words on a line. Would be better in a region, maybe. | |
(defun sort-words-in-lines (start end) | |
(interactive "r") | |
(goto-char start) | |
(beginning-of-line) | |
(while (< (setq start (point)) end) | |
(let ((words (sort (split-string (buffer-substring start (line-end-position))) | |
(function string-lessp)))) | |
(delete-region start (line-end-position)) | |
(dolist (word words ) (insert word " ")) | |
(delete-trailing-whitespace)) | |
(beginning-of-line) (forward-line 1))) | |
;; wrap with text -- comment, arbitrary | |
(defun wrap-comment () | |
(interactive) | |
(let ((beg (region-beginning)) | |
(end (region-end))) | |
(goto-char beg) | |
(insert "/*") | |
(goto-char (+ 2 end)) | |
(insert "*/"))) | |
(global-set-key (kbd "C-c c") 'wrap-comment) | |
(defun insert-or-wrap (string) | |
(interactive "*Mtext to wrap with") | |
(if (not (use-region-p)) | |
(insert string) | |
(let ((beg (region-beginning)) | |
(end (region-end))) | |
(goto-char beg) | |
(insert string) | |
(goto-char (+ (length string) end)) | |
(insert string)))) | |
(global-set-key (kbd "C-c w") 'insert-or-wrap) | |
;; switch between non-system buffers | |
;; http://xahlee.org/emacs/elisp_examples.html | |
(defun next-user-buffer () | |
"Switch to the next user buffer in cyclic order.\n User buffers are those not starting with *." | |
(interactive) | |
(next-buffer) | |
(let ((i 0)) | |
(while (and (string-match "^*" (buffer-name)) (< i 50)) | |
(setq i (1+ i)) (next-buffer) ))) | |
(defun previous-user-buffer () | |
"Switch to the previous user buffer in cyclic order.\n User buffers are those not starting with *." | |
(interactive) | |
(previous-buffer) | |
(let ((i 0)) | |
(while (and (string-match "^*" (buffer-name)) (< i 50)) | |
(setq i (1+ i)) (previous-buffer) ))) | |
(global-set-key (kbd "C-<prior>") 'previous-user-buffer) ; Ctrl+PageDown | |
(global-set-key (kbd "C-<next>") 'next-user-buffer) ; Ctrl+PageUp | |
(global-set-key (kbd "C-<f12>") 'previous-user-buffer) ; Ctrl+PageDown | |
(global-set-key (kbd "C-<f11>") 'next-user-buffer) ; Ctrl+PageUp | |
;; Rigidly indent. C-c 4 indents in, C-c - 4 outdents the same. Keeps | |
;; working on the same region if repeated (highlight disappears) | |
(fset 'ind4 | |
[?\C-u ?4 ?\C-x tab]) | |
(global-set-key (kbd "C-c 4") 'ind4) | |
(fset 'ind2 | |
[?\C-u ?2 ?\C-x tab]) | |
(global-set-key (kbd "C-c 2") 'ind2) | |
(fset 'outd4 | |
[?\C-u ?- ?4 ?\C-x tab]) | |
(global-set-key (kbd "C-c - 4") 'outd4) | |
;; Search to the front of a word... | |
(defun fw() | |
"move to the front of the next word" | |
(interactive) | |
(forward-char) | |
(re-search-forward "[^[:alnum:]-/]\\b[[:alnum:]]") | |
(backward-char)) | |
(global-set-key (kbd "C-M-f") 'fw) | |
;; Insert dates, times, notes | |
(defun note () | |
"Insert string for the current time formatted like '2:34 PM'." | |
(interactive) ; permit invocation in minibuffer | |
(insert (format-time-string "%Y-%m-%d WS: "))) | |
(global-set-key (kbd "M-n") 'note) | |
;; copy the buffer to the clipboard. Recorded macro. No idea what | |
;; the weird kmacro-exec... thing does. | |
(setq last-kbd-macro | |
[?\M-< ?\C- ?\M-> ?\M-w ?\C-u ?\C- ?\C-u ?\C- ]) | |
(fset 'pa | |
(lambda (&optional arg) | |
"Keyboard macro." (interactive "p") | |
(kmacro-exec-ring-item | |
(quote ([134217788 67108896 134217790 134217847 21 67108896 21 67108896] 0 "%d")) arg))) | |
;; Insert a header regarding code | |
(defun bp () (interactive) | |
(insert(format-time-string | |
"/********************************************************************************* | |
PROGRAM: | |
DESCRIPTION: | |
PROGRAMMERS: [email protected] | |
DATE STARTED: %Y-%m-%d | |
NOTES: | |
**********************************************************************************/ | |
")) | |
(previous-line 11) | |
(forward-char 13) | |
) | |
;; Insert a "section break" comment | |
(defun com () (interactive) | |
(insert(format-time-string | |
"/********************************************************************************* | |
**********************************************************************************/")) | |
(previous-line 2) | |
(forward-char 4) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment