Created
March 22, 2016 14:30
-
-
Save gcamp806/331404a241089fb1c0b0 to your computer and use it in GitHub Desktop.
.emacs
This file contains 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
(setq load-path (append load-path (list "~/elisp"))) | |
(setq inhibit-splash-screen t) | |
;; Turn on mouse wheel | |
;;(mouse-wheel-mode t) | |
(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. | |
'(add-log-full-name "Greg Camp") | |
'(add-log-mailing-address "gcamp@icsolutions.com") | |
'(c-default-style (quote ((c-mode . "bsd") (java-mode . "java") (other . "gnu")))) | |
'(minibuffer-prompt-properties (quote (read-only t point-entered minibuffer-avoid-prompt))) | |
'(mouse-wheel-scroll-amount (quote (1))) | |
'(mouse-wheel-follow-mouse t)) | |
;; turn on paren matching | |
(require 'paren) (show-paren-mode t) | |
(setq show-paren-style 'mixed) | |
;; fix End key for PuTTY using xterm | |
(define-key global-map [select] 'end-of-line) | |
;; Show column number at bottom of screen | |
(column-number-mode 1) | |
;; get rid of the menubar | |
(menu-bar-mode -1) | |
;; Use "y or n" answers instead of full words "yes or no" | |
(fset 'yes-or-no-p 'y-or-n-p) | |
;; highlight region between point and mark | |
(setq transient-mark-mode t) | |
;; Cut/Copy similar to SlickEdit | |
(defadvice kill-ring-save (before slick-copy activate compile) | |
"When called interactively with no active region, copy a single line instead." | |
(interactive | |
(if mark-active (list (region-beginning) (region-end)) | |
(message "Copied line") | |
(list (line-beginning-position) | |
(line-beginning-position 2))))) | |
(defadvice kill-region (before slick-cut activate compile) | |
"When called interactively with no active region, kill a single line instead." | |
(interactive | |
(if mark-active (list (region-beginning) (region-end)) | |
(list (line-beginning-position) | |
(line-beginning-position 2))))) | |
;; Moving cursor down at bottom scrolls only a single line, not half page | |
(setq scroll-step 1) | |
(setq scroll-conservatively 5) | |
;; | |
;; -- individual download of NXML not needed on FC11 | |
;; | |
;; configuration for nXML | |
;;(setq load-path (append load-path (list "~/elisp/nxml"))) | |
;; | |
;; make sure that nxml-mode can auto-load | |
;;(load "~/elisp/nxml/rng-auto.el") | |
;; | |
;; -- individual download of NXML not needed on FC11 | |
;; | |
;; load nxml-mode for files ending in .xml, .xsl, .xsd, .rng, .xhtml | |
(setq auto-mode-alist | |
(cons '("\\.\\(xml\\|xsl\\|xsd\\|rng\\|xhtml\\)\\'" . nxml-mode) | |
auto-mode-alist)) | |
;;; Use nxml-mode instead of sgml, xml or html mode. | |
(mapc | |
(lambda (pair) | |
(if (or (eq (cdr pair) 'xml-mode) | |
(eq (cdr pair) 'sgml-mode) | |
(eq (cdr pair) 'html-mode)) | |
(setcdr pair 'nxml-mode))) | |
magic-mode-alist) | |
(setq magic-mode-alist | |
(cons '("<\\?xml " . nxml-mode) | |
magic-mode-alist)) | |
;; Centering code stolen from somewhere and restolen from | |
;; http://www.chrislott.org/geek/emacs/dotemacs.html | |
;; centers the screen around a line... | |
(global-set-key [(control l)] 'centerer) | |
(defun centerer () | |
"Repositions current line: once middle, twice top, thrice bottom" | |
(interactive) | |
(cond ((eq last-command 'centerer2) ; 3 times pressed = bottom | |
(recenter -1)) | |
((eq last-command 'centerer1) ; 2 times pressed = top | |
(recenter 0) | |
(setq this-command 'centerer2)) | |
(t ; 1 time pressed = middle | |
(recenter) | |
(setq this-command 'centerer1)))) | |
;; will make "Ctrl-k" kills an entire line if the cursor is at the beginning of line -- very useful. | |
(setq kill-whole-line t) | |
;; will delete "hungrily" in C mode! Use it to see what it does -- very useful. | |
(setq c-hungry-delete-key t) | |
;; will let emacs put in a "carriage-return" for you automatically after left curly braces, right curly braces, and semi-colons in "C mode" -- very useful. | |
;(setq c-auto-newline 1) | |
;; set default tab width | |
(setq-default tab-width 4) | |
;;(which-func-mode t) | |
(which-function-mode t) | |
;; Turn on use of tabs for indentation in many modes | |
(setq-default indent-tabs-mode t) | |
;;(setq tab-always-indent t) | |
(require 'smarttabs) | |
(require 'cc-mode) | |
;; set a small compile window | |
(setq compilation-window-height 8) | |
;; close window if no grep matches found or no compile errors | |
;; otherwise keep window open and move to first match / error | |
(setq compilation-finish-function | |
(lambda (buf str) | |
(set-buffer buf) | |
;; check for matches found (grep mode) | |
(if (string-match ".*no matches found.*" (buffer-string)) | |
;; no matches, make the window go away in 1 second | |
(progn | |
(run-at-time 1.0 nil 'delete-windows-on buf) | |
(message "No matches found")) | |
(if (string-match ".*matches found.*" (buffer-string)) | |
;; matches found for grep | |
(progn | |
(next-error) | |
(message "Press Ctrl-x ` for next match")) | |
;; check for compiler errors | |
(if (string-match "exited abnormally" (buffer-string)) | |
;;there were errors during compile | |
(progn | |
(next-error) | |
(message "Press Ctrl-x ` for next error")) | |
(if (string-match "Compilation finished" (buffer-string)) | |
;;no errors, make the window go away in 2 seconds | |
(progn | |
(run-at-time 2.0 nil 'delete-windows-on buf) | |
(message "NO COMPILATION ERRORS!")))))))) | |
(defun my-build-tab-stop-list (width) | |
(let ((num-tab-stops (/ 80 width)) | |
(counter 1) | |
(ls nil)) | |
(while (<= counter num-tab-stops) | |
(setq ls (cons (* width counter) ls)) | |
(setq counter (1+ counter))) | |
(set (make-local-variable 'tab-stop-list) (nreverse ls)))) | |
(add-hook 'c-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
;; (my-build-tab-stop-list tab-width) | |
(setq c-basic-offset tab-width) | |
;; (setq indent-tabs-mode nil) | |
(c-set-style "stroustrup") ; set indentation style | |
;; (turn-on-auto-fill) | |
;; (setq fill-column 80) | |
;; (setq comment-column 60) | |
(modify-syntax-entry ?_ "w") ; now '_' is not considered a word-delimiter | |
;; (local-set-key [(control tab)] ; move to next tempo mark | |
;; 'tempo-forward-mark) | |
)) | |
(add-hook 'c++-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
;; (my-build-tab-stop-list tab-width) | |
(setq c-basic-offset tab-width) | |
;; (setq indent-tabs-mode nil) | |
(c-set-style "stroustrup") ; set indentation style | |
(modify-syntax-entry ?_ "w") ; now '_' is not considered a word-delimiter | |
;; (local-set-key [(control tab)] ; move to next tempo mark | |
;; 'tempo-forward-mark) | |
)) | |
;; style I want to use in c++ mode | |
;;(c-add-style "my-style" | |
;; '("stroustrup" | |
;; (indent-tabs-mode . nil) ; use spaces rather than tabs | |
;; (c-basic-offset . 4) ; indent by four spaces | |
;; (c-offsets-alist . ((inline-open . 0) ; custom indentation rules | |
;; (brace-list-open . 0) | |
;; (statement-case-open . +))))) | |
;;(defun my-c++-mode-hook () | |
;; (c-set-style "my-style") ; use my-style defined above | |
;; (auto-fill-mode) | |
;; (c-toggle-auto-hungry-state 1)) | |
;;(add-hook 'c++-mode-hook 'my-c++-mode-hook) | |
(cond (window-system | |
(setq hilit-mode-enable-list '(not text-mode) | |
hilit-background-mode 'light | |
hilit-inhibit-hooks nil | |
hilit-inhibit-rebinding nil) | |
;; keep the menubar | |
(menu-bar-mode 1) | |
(dolist (func '(tabbar-mode tabbar-forward-tab tabbar-forward-group tabbar-backward-tab tabbar-backward-group)) | |
(autoload func "tabbar" "Tabs at the top of buffers and easy control-tab navigation")) | |
(tabbar-mode 1) | |
;; define custom tab groups | |
(defun tabbar-buffer-groups () | |
"Return the list of group names BUFFER belongs to. Return only one group for each buffer." | |
(list | |
(cond | |
((or (get-buffer-process (current-buffer)) | |
;; Check if the major mode derives from `comint-mode' or | |
;; `compilation-mode'. | |
(tabbar-buffer-mode-derived-p | |
major-mode '(comint-mode compilation-mode))) | |
"Process" | |
) | |
((string-equal "*" (substring (buffer-name) 0 1)) | |
"Emacs" | |
) | |
;; ((eq major-mode 'dired-mode) | |
;; "Dired") | |
(t | |
"User") | |
))) | |
(setq tabbar-buffer-groups-function 'tabbar-buffer-groups) | |
;; ;; add a buffer modification state indicator in the tab label, | |
;; ;; and place a space around the label to make it looks less crowd | |
;; (defadvice tabbar-buffer-tab-label (after fixup_tab_label_space_and_flag activate) | |
;; (setq ad-return-value | |
;; (if (and (buffer-modified-p (tabbar-tab-value tab)) | |
;; (buffer-file-name (tabbar-tab-value tab))) | |
;; (concat " + " (concat ad-return-value " ")) | |
;; (concat " " (concat ad-return-value " "))))) | |
;; | |
;; ;; called each time the modification state of the buffer changed | |
;; (defun glc-modification-state-change () | |
;; (tabbar-set-template tabbar-current-tabset nil) | |
;; (tabbar-display-update)) | |
;; ;; first-change-hook is called BEFORE the change is made | |
;; (defun glc-on-buffer-modification () | |
;; (set-buffer-modified-p t) | |
;; (glc-modification-state-change)) | |
;; (add-hook 'after-save-hook 'glc-modification-state-change) | |
;; ;; this doesn't work for revert, I don't know why | |
;; ;;(add-hook 'after-revert-hook 'glc-modification-state-change) | |
;; (add-hook 'first-change-hook 'glc-on-buffer-modification) | |
(defmacro defun-prefix-alt (name on-no-prefix on-prefix &optional do-always) | |
`(defun ,name (arg) | |
(interactive "P") | |
,do-always | |
(if (equal nil arg) | |
,on-no-prefix | |
,on-prefix))) | |
(defun-prefix-alt glc-tabbar-next (tabbar-forward-tab) (tabbar-forward-group) (tabbar-mode 1)) | |
(defun-prefix-alt glc-tabbar-prev (tabbar-backward-tab) (tabbar-backward-group) (tabbar-mode 1)) | |
;; (global-set-key [(control tab)] 'glc-tabbar-next) | |
;; (global-set-key [(control shift tab)] 'glc-tabbar-prev) | |
;; C-<tab> ;; C-S-<tab> | |
(global-set-key (kbd "<C-tab>") 'glc-tabbar-next) | |
(global-set-key (kbd "<C-S-iso-lefttab>") 'glc-tabbar-prev) | |
;; Window-<tab> ;; Window-S-<tab> | |
(global-set-key (kbd "<s-tab>") 'tabbar-forward-group) | |
(global-set-key (kbd "<S-s-iso-lefttab>") 'tabbar-backward-group) | |
)) | |
;;(defun fix-backspace () | |
;; (interactive) | |
;; (keyboard-translate ?\C-h ?\C-?) | |
;; (keyboard-translate ?\C-? ?\C-h)) | |
(autoload 'javascript-mode "javascript" nil t) | |
(add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode)) | |
;;(if (string-equal (getenv "TERM") "vt220") | |
;; (fix-backspace)) | |
;;(defun fix-sun-escape () | |
;; (interactive) | |
;; (keyboard-translate ?\C-@ ?\C-[)) | |
;;(fix-sun-escape) | |
;;(require 'uncompress) | |
;;(setq calendar-latitude 42.161220) | |
;;(setq calendar-longitude -71.402400) | |
;;(setq calendar-location-name "Westminster, MA") | |
(defun tab3 () | |
(interactive) | |
(setq tab-width 3)) | |
(setq Info-enable-edit t) | |
(global-set-key "g" 'goto-line) | |
(defun goto-match-paren (arg) | |
"Go to the matching parenthesis if on parenthesis. | |
Else go to the opening parenthesis one level up." | |
(interactive "p") | |
(cond ((looking-at "\\s\(") (forward-list 1)) | |
(t | |
(backward-char 1) | |
(cond ((looking-at "\\s\)") | |
(forward-char 1) (backward-list 1)) | |
(t | |
(while (not (looking-at "\\s(")) | |
(backward-char 1) | |
(cond ((looking-at "\\s\)") | |
(message "->> )") | |
(forward-char 1) | |
(backward-list 1) | |
(backward-char 1))) | |
)))))) | |
(global-set-key (kbd "M-]") 'goto-match-paren) | |
(defun forward-or-backward-sexp (&optional arg) | |
"Go to the matching parenthesis character if one is adjacent to point." | |
(interactive "^p") | |
(cond ((looking-at "\\s(") (forward-sexp arg)) | |
((looking-back "\\s)" 1) (backward-sexp arg)) | |
;; Now, try to succeed from inside of a bracket | |
((looking-at "\\s)") (forward-char) (backward-sexp arg)) | |
((looking-back "\\s(" 1) (backward-char) (forward-sexp arg)))) | |
;; for some reason this causes "bad things" to happen in emacs now | |
;; specifically, page-up/dn and arrow keys no longer work | |
;;(global-set-key (kbd "M-[") 'forward-or-backward-sexp) | |
(defun bzr-cmp () | |
"Using 'bzr cat', create a copy of 'buffer' in /tmp. | |
Then use ediff to compare that file to the current buffer." | |
(interactive) | |
;; Get the name of the file being edited in the current buffer | |
(setq base-file-name (file-name-nondirectory buffer-file-name)) | |
(setq scm-file-name (concat "/tmp/" base-file-name)) | |
(shell-command (concat "chmod u+w " scm-file-name)) | |
(shell-command (concat "bzr cat " base-file-name " > " scm-file-name)) | |
(shell-command (concat "chmod u-w " scm-file-name)) | |
(require 'ediff) | |
(setq ediff-split-window-function 'split-window-horizontally) | |
(ediff-files scm-file-name buffer-file-name) | |
) | |
(global-set-key [f1] (lambda () (interactive) (manual-entry (current-word)))) | |
;;(global-set-key [f2] 'kill-nulls) | |
;;(global-set-key [f2] 'fill-paragraph) | |
(global-set-key [f2] 'indent-region) | |
(global-set-key [f3] 'compare-windows) | |
;;(global-set-key [f4] 'just-one-space) | |
;;(global-set-key [f4] 'mkitem-smart) | |
(global-set-key [f4] 'bzr-cmp) | |
(global-set-key [f5] 'call-last-kbd-macro) | |
(global-set-key [f6] 'shell) | |
;;(global-set-key [f7] 'rename-buffer) | |
(global-set-key [f7] 'bzr-cmp) | |
;;(global-set-key [f8] 'gdb) | |
(global-set-key [f8] 'gud-gdb) | |
(global-set-key [f9] 'docompile) | |
(global-set-key [f10] 'next-error) | |
(global-set-key [f11] 'jdb) | |
(global-set-key [f12] 'next-error) | |
;; don't use f11 & 12 for the sun | |
(defun cleangdb () | |
(interactive) | |
(save-excursion | |
(let ((bufs (buffer-list)) | |
(gdb-bufs nil)) | |
(while bufs | |
(let ((name (buffer-name (car bufs)))) | |
(cond ((and (>= (length name) 5) | |
(or (string-equal (substring name 0 5) "*gdb-") | |
(string-equal (substring name 0 5) "*gud-"))) | |
(setq gdb-bufs (cons (car bufs) nil))))) | |
(setq bufs (cdr bufs))) | |
(while gdb-bufs | |
(kill-buffer (car gdb-bufs)) | |
(setq gdb-bufs (cdr gdb-bufs)))))) | |
(setq compile-command "make ") | |
(defun docompile () | |
(interactive) | |
(compile compile-command)) | |
(define-key esc-map "m" 'compile) | |
(put 'eval-expression 'disabled nil) | |
(setq backup-directory-alist `(("." . "~/.saves"))) | |
(setq backup-by-copying-when-linked t) | |
(defun gid (command) | |
"Run gid, with user-specified args, and collect output in a buffer. | |
While grep runs asynchronously, you can use the \\[next-error] command | |
to find the text that grep hits refer to." | |
(interactive "sRun gid (with args): ") | |
(require 'compile) | |
(cond ((eq (read emacs-version) 18) | |
(compile1 (concat "gid " command) "No more gid hits" "gid")) | |
(t | |
(compile-internal (concat "gid " command) "No more gid hits")))) | |
(defun nice-date () | |
(let ((ctime (current-time-string))) | |
(let ((short-mon (substring ctime 4 7)) | |
(date (substring ctime 8 10)) | |
(year (substring ctime 20 24))) | |
(if (= (aref date 0) ? ) | |
(setq date (substring date 1 2))) | |
(concat (cdr (assoc short-mon '(("Jan" . "January") | |
("Feb" . "February") | |
("Mar" . "March") | |
("Apr" . "April") | |
("May" . "May") | |
("Jun" . "June") | |
("Jul" . "July") | |
("Aug" . "August") | |
("Sep" . "September") | |
("Oct" . "October") | |
("Nov" . "November") | |
("Dec" . "December")))) | |
" " | |
date | |
", " | |
year)))) | |
(defun dos-cleanup () | |
(interactive) | |
(setq buffer-read-only t) | |
(setq selective-display t) | |
(setq selective-display-ellipses nil)) | |
(defun monthnum (monthname) | |
(cdr (assoc monthname '(("Jan" . 1) | |
("Feb" . 2) | |
("Mar" . 3) | |
("Apr" . 4) | |
("May" . 5) | |
("Jun" . 6) | |
("Jul" . 7) | |
("Aug" . 8) | |
("Sep" . 9) | |
("Oct" . 10) | |
("Nov" . 11) | |
("Dec" . 12))))) | |
(defun insert-date () | |
(interactive) | |
(insert (current-time-string)) | |
(insert "\n")) | |
(defun insert-short-date () | |
(interactive) | |
(insert "(") | |
(let ((ctime (current-time-string))) | |
(let ((short-mon (substring ctime 4 7)) | |
(date (substring ctime 8 10))) | |
(insert (format "%s" date)) | |
(insert "/") | |
(insert (format "%02d" (cdr (assoc short-mon '(("Jan" . 01) | |
("Feb" . 02) | |
("Mar" . 03) | |
("Apr" . 04) | |
("May" . 05) | |
("Jun" . 06) | |
("Jul" . 07) | |
("Aug" . 08) | |
("Sep" . 09) | |
("Oct" . 10) | |
("Nov" . 11) | |
("Dec" . 12)))))) | |
(insert "/")) | |
(let ((short-yr (substring ctime 22 24))) | |
(insert (format "%s" short-yr))) | |
(insert ") ")) | |
) | |
(if (= emacs-major-version 19) | |
(server-start)) | |
(defun kill-nulls () | |
(interactive) | |
(save-excursion | |
(let ((b (get-buffer "*compilation*"))) | |
(cond (b | |
(set-buffer b) | |
(goto-char (point-min)) | |
(while (search-forward " " nil t) | |
(replace-match "" nil t))))) | |
(let ((b (get-buffer "*grep*"))) | |
(cond (b | |
(set-buffer b) | |
(goto-char (point-min)) | |
(while (search-forward " " nil t) | |
(replace-match "" nil t))))))) | |
(defun todo-mode () | |
"Major mode for editing TODO list." | |
(interactive) | |
(kill-all-local-variables) | |
(use-local-map todo-mode-map) | |
(setq mode-name "TODO") | |
(setq major-mode 'todo-mode)) | |
(defun todo-save () | |
(interactive) | |
(save-buffer) | |
(save-window-excursion | |
(shell-command "rcp TODO fs:.plan &"))) | |
(defun xmkitem () | |
(interactive) | |
(let ((ctime (current-time-string))) | |
(let ((short-mon (substring ctime 4 7)) | |
(date (substring ctime 8 10)) | |
(year (substring ctime 20 24))) | |
(if (= (aref date 0) ? ) | |
(setq date (substring date 1 2))) | |
(setq dt (ctime)))) | |
(let (val) | |
(save-excursion | |
(goto-char (point-min)) | |
(re-search-forward "nextseq: \\([0-9]*\\)") | |
(setq val (string-to-number (match-string 1))) | |
(goto-char (match-beginning 1)) | |
(kill-line) | |
(insert (number-to-string (+ val 1)))) | |
(insert (number-to-string val) " "))) | |
(defun mkitem-smart () | |
(interactive) | |
(let ((highest-val 0) | |
val) | |
(save-excursion | |
(goto-char (point-min)) | |
(re-search-forward "nextseq: \\([0-9]*\\)") | |
(setq val (string-to-number (match-string 1))) | |
(goto-char (match-beginning 1)) | |
(kill-line) | |
(insert (format "%02d" (+ val 1)))) | |
(insert (format "%02d" val) " ")) | |
(insert-short-date) | |
) | |
(defun mkf () | |
(interactive) | |
(let ((short-mon "")) | |
(let ((ctime (current-time-string))) | |
(let ((short-mon (substring ctime 4 7)) | |
(date (substring ctime 8 10)) | |
(year (substring ctime 20 24))) | |
(setq foo (list '(short-mon "/" date))) | |
(insert (foo)))) | |
)) | |
(defun mkitem () | |
(interactive) | |
(let ((highest-val 0) | |
val) | |
(save-excursion | |
(goto-char (point-min)) | |
(while (re-search-forward "^\\([1-9][0-9]*\\)" (point-max) t) | |
(setq val (string-to-number (match-string 1))) | |
(if (> val highest-val) | |
(setq highest-val val)))) | |
(insert (number-to-string (+ highest-val 1)) " "))) | |
(setq calc-display-trail nil) | |
;;; Commands added by calc-private-autoloads on Thu Nov 8 16:45:40 2001. | |
;;(autoload 'calc-dispatch "calc" "Calculator Options" t) | |
;;(autoload 'full-calc "calc" "Full-screen Calculator" t) | |
;;(autoload 'full-calc-keypad "calc" "Full-screen X Calculator" t) | |
;;(autoload 'calc-eval "calc" "Use Calculator from Lisp") | |
;;(autoload 'defmath "calc" nil t t) | |
;;(autoload 'calc "calc" "Calculator Mode" t) | |
;;(autoload 'quick-calc "calc" "Quick Calculator" t) | |
;;(autoload 'calc-keypad "calc" "X windows Calculator" t) | |
;;(autoload 'calc-embedded "calc" "Use Calc inside any buffer" t) | |
;;(autoload 'calc-embedded-activate "calc" "Activate =>'s in buffer" t) | |
;;(autoload 'calc-grab-region "calc" "Grab region of Calc data" t) | |
;;(autoload 'calc-grab-rectangle "calc" "Grab rectangle of data" t) | |
;;(setq load-path (nconc load-path (list "~/elisp/calc-2.02f"))) | |
;;(global-set-key "\e#" 'calc-dispatch) | |
;;; End of Calc autoloads. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also grab smarttabs.el from https://github.com/jcsalomon/smarttabs