;;; -*- mode: emacs-lisp; outline-layout: (1 :) -*- (custom-set-variables ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(auto-compression-mode t nil (jka-compr)) '(case-fold-search t) '(current-language-environment "English") '(global-font-lock-mode t nil (font-lock)) '(menu-bar-mode t) '(mouse-wheel-mode t nil (mwheel)) '(mouse-yank-at-point t) '(scroll-bar-mode (quote right)) '(show-paren-mode t nil (paren)) '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify))) '(tool-bar-mode nil nil (tool-bar)) '(transient-mark-mode t)) (custom-set-faces ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(mouse ((t (:background "white"))))) ;;;;;;;;;;;;;;;;; ; necessary support function for buffer burial (defun crs-delete-these (delete-these from-this-list) "Delete DELETE-THESE FROM-THIS-LIST." (cond ((car delete-these) (if (member (car delete-these) from-this-list) (crs-delete-these (cdr delete-these) (delete (car delete-these) from-this-list)) (crs-delete-these (cdr delete-these) from-this-list))) (t from-this-list))) ; this is the list of buffers I never want to see (defvar crs-hated-buffers '("KILL" "*Compile-Log*")) ; might as well use this for both (setq iswitchb-buffer-ignore (append '("^ " "*Buffer") crs-hated-buffers)) (defun crs-hated-buffers () "List of buffers I never want to see, converted from names to buffers." (delete nil (append (mapcar 'get-buffer crs-hated-buffers) (mapcar (lambda (this-buffer) (if (string-match "^ " (buffer-name this-buffer)) this-buffer)) (buffer-list))))) ; I'm sick of switching buffers only to find KILL right in front of me (defun crs-bury-buffer (&optional n) (interactive) (unless n (setq n 1)) (let ((my-buffer-list (crs-delete-these (crs-hated-buffers) (buffer-list (selected-frame))))) (switch-to-buffer (if (< n 0) (nth (+ (length my-buffer-list) n) my-buffer-list) (bury-buffer) (nth n my-buffer-list))))) (global-set-key [(control tab)] 'crs-bury-buffer) (global-set-key [(control meta tab)] (lambda () (interactive) (crs-bury-buffer -1))) ;; new kill key (defun diff-buffer-with-associated-file () "View the differences between BUFFER and its associated file. This requires the external program \"diff\" to be in your `exec-path'." (interactive) (let ((buf-filename buffer-file-name) (buffer (current-buffer))) (unless buf-filename (error "Buffer %s has no associated file" buffer)) (let ((diff-buf (get-buffer-create (concat "*Assoc file diff: " (buffer-name) "*")))) (with-current-buffer diff-buf (setq buffer-read-only nil) (erase-buffer)) (let ((tempfile (make-temp-file "buffer-to-file-diff-"))) (unwind-protect (progn (with-current-buffer buffer (write-region (point-min) (point-max) tempfile nil 'nomessage)) (if (zerop (apply #'call-process "diff" nil diff-buf nil (append (when (and (boundp 'ediff-custom-diff-options) (stringp ediff-custom-diff-options)) (list ediff-custom-diff-options)) (list buf-filename tempfile)))) (message "No differences found") (progn (with-current-buffer diff-buf (goto-char (point-min)) (if (fboundp 'diff-mode) (diff-mode) (fundamental-mode))) (display-buffer diff-buf)))) (when (file-exists-p tempfile) (delete-file tempfile))))) nil)) ;; tidy up diffs when closing the file (defun kill-associated-diff-buf () (let ((buf (get-buffer (concat "*Assoc file diff: " (buffer-name) "*")))) (when (bufferp buf) (kill-buffer buf)))) (add-hook 'kill-buffer-hook 'kill-associated-diff-buf) (global-set-key (kbd "C-c d") 'diff-buffer-with-associated-file) (defun de-context-kill (arg) "Kill buffer, taking gnuclient into account." (interactive "p") (when (and (buffer-modified-p) (not (string-match "\\*.*\\*" (buffer-name))) (= 1 arg)) (diff-buffer-with-associated-file) (error "Buffer has unsaved changes")) (if (and (boundp 'gnuserv-minor-mode) gnuserv-minor-mode) (gnuserv-edit) (set-buffer-modified-p nil) (kill-buffer (current-buffer)))) (global-set-key (kbd "C-x k") 'de-context-kill) ;; tab attempt to complete variable names ;;;;;;;;;;;;;;;;;;;;;;;;; (defun indent-or-complete () "Complete if point is at end of a word, otherwise indent line." (interactive) (if (looking-at "\\>") (dabbrev-expand nil) (indent-for-tab-command) )) (add-hook 'c-mode-common-hook (function (lambda () (local-set-key (kbd "") 'indent-or-complete) ))) ; jump key (defun my-jump () "Jump to the thing at point. If a filename, open it." (interactive) (let ((thing (thing-at-point 'filename))) (if thing (if (file-readable-p thing) (find-file thing) (if (file-exists-p thing) (error "File is not readable") (error "File does not exist"))) (setq thing (thing-at-point 'url)) (if thing (browse-url thing) (error "Nothing to jump to at point"))))) ; disk key (autoload 'disk "disk" "Save, revert, or find file." t) ; match parens with % key, like in vi (defun match-paren (arg) "Go to the matching paren if on a paren; otherwise insert %." (interactive "p") (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) ((looking-at "\\s\)") (forward-char 1) (backward-list 1)) (t (self-insert-command (or arg 1))))) (global-set-key "%" 'match-paren) ;; Misc options ;;;;;;;;;;;;;;;;;;;;; ;; use the correct elisp directory (add-to-list 'load-path "~/.elisp") (setq make-backup-files nil) (setq auto-save-default nil) (setq initial-scratch-message nil) (setq auto-image-file-mode t) (setq line-number-mode t) (setq column-number-mode t) ;(setq x-pointer-shape x-pointer-top-left-arrow) ;(set-mouse-color "black") (setq user-full-name "Nicholas Kain") (setq user-initials "njk") (setq user-mail-address "nicholas@kain.us") ;; buffer name completion (iswitchb-mode 1) (setq iswitchb-buffer-ignore '("^ " "*Buffer")) ;; use pc selection (if (fboundp 'pc-selection-mode) (pc-selection-mode) (require 'pc-select)) (require 'color-theme) (setq scroll-step 1) (hscroll-mode) (setq default-indicate-empty-lines t) (setq default-truncate-lines t) ;; fix appearance in x11 (color-theme-niklata) (set-face-font 'default "-nk-phreak-medium-r-normal--13-130-75-75-c-70-iso8859-1") ;; use abbrev mode in text-derived modes (add-hook 'text-mode-hook (lambda () (abbrev-mode 1))) ;; keybinds (global-set-key (kbd "") 'hippie-expand); complete (global-set-key (kbd "") 'comment-region); comment (global-set-key (kbd "") 'eval-last-sexp); eval (global-set-key (kbd "") 'set-mark-command); mark (global-set-key (kbd "") 'kill-ring-save); copy (global-set-key (kbd "") 'yank); paste (global-set-key (kbd "") 'kill-region); delete (global-set-key (kbd "") 'disk); save (global-set-key (kbd "") 'crs-bury-buffer); switch buffer (global-set-key [(control f10)] 'iswitchb-buffer); switch buffer (global-set-key (kbd "") 'dired); switch file (global-set-key (kbd "") 'de-context-kill); kill buffer (global-set-key (kbd "") 'my-jump) ;; start emacsserver (server-start) ;; ocaml tuareg bindings (setq auto-mode-alist (cons '("\\.ml\\w?" . tuareg-mode) auto-mode-alist)) (autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t) (autoload 'camldebug "camldebug" "Run the Caml debugger" t) (if (and (boundp 'window-system) window-system) (require 'font-lock)) ;; x-symbol ;(defvar x-symbol-root-directory (expand-file-name "~/.elisp/x-symbol")) ;(defvar x-symbol-lisp-directory ; (expand-file-name "lisp/x-symbol" x-symbol-root-directory)) ;(setq load-path (cons x-symbol-lisp-directory load-path)) ;(setq x-symbol-data-directory ; (expand-file-name "etc/x-symbol" x-symbol-root-directory)) ;(load (expand-file-name "auto-autoloads" x-symbol-lisp-directory)) ;(x-symbol-initialize) ;; cperl mode (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode)) ; use aspell (setq-default ispell-program-name "aspell")