;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; look up this file for useful utilities and syntax: ;(load-file ".Emacs/statdept.el") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; had to hard-code the path for the ESS macros: ;(load-file "e:/emacs/ess-5.1.20/lisp/ess-site.el") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; emacs/w3 browser: ;(setq load-path (cons "e:/emacs/w3-4.0pre.47/lisp" load-path)) ;(require 'w3-auto) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; html mode inherited from sgml mode, NOT html-helper-mode ;(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; from "Gnu Emacs" Pocket Reference: show column of cursor position (setq column-number-mode t) (setq track-eol t) (setq dired-listing-switches "-la") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; html helper mode ;(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; use shell-script-mode for W2K .bat files: (setq auto-mode-alist (cons '("\\.bat$" . shell-script-mode) auto-mode-alist)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; python mode ;;; file associations for ".py" files (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python -i" . python-mode) interpreter-mode-alist)) ;;; autoloading (autoload 'python-mode "python-mode" "Python editing mode." t) ;;; add these lines if you like color-based syntax highlighting (global-font-lock-mode t) (setq font-lock-maximum-decoration t) ; new from www.faqts.com/knowledge_base/view.phtml/aid/5379/fid/245 ;(defun my-python-mode-hook () ; (setq-default indent-tabs-mode nil) ; ) ;(add-hook 'python-mode-hook 'my-python-mode-hook) ; ;(global-font-lock-mode t) ;(setq font-lock-maximum-decoration t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ^h for delete: (defun swap-ctl-h-and-del () "Swap the C-h and C-? keys." (interactive) (setq gaga (make-string 128 0)) (let ((i 0)) (while (< i 128) (aset gaga i i) (setq i (1+ i)))) (aset gaga ?\C-? ?\C-h) (aset gaga ?\C-h ?\C-?) (setq keyboard-translate-table gaga) ) (swap-ctl-h-and-del) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; general initialization from statdept.el: (setq backup-by-copying t default-major-mode 'text-mode inhibit-startup-message t track-eol t ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; @@ text-mode: don't like autofill (setq want-auto-fill-in-text-mode 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; when forming a region, highlight it "midnightblue" (assume reverse video) (setq transient-mark-mode t) (set-face-background 'region "midnightblue") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; useful global key bindings ;;; move to previous window: (global-set-key [M-up] 'previous-multiframe-window) ;;; move to next window: (global-set-key [M-down] 'next-multiframe-window) ;;; current line to top of buffer: ;(global-set-key "\M-t" "\C-u0\C-l") ;;; center next window at bottom of buffer: (global-set-key "\M-s" "\C-xo\M->\C-l\C-xo") ;;; eval current R variable (should really be local-set-key, ;;; but I don't know how to specify R mode): (global-set-key "\M-t" "\C-\M-f\C-\ \C-\M-b\C-c\C-r") ;;;;;; Hand-made execution support for interpreted languages: Shell, Python, R ;;; copy the current line to the other window, for evaluation, and return to next line: (global-set-key "\C-xc" "\C-a\C- \C-e\M-w\C-a\C-n\C-xo\M->\C-y\C-m\C-xo") ;;; Does NOT work when the pointer is at the end of the file because then \C-n will bomb. ;;; Here is a version that also copies the line but stays on the same line: (global-set-key "\C-xv" "\C-a\C- \C-e\M-w\C-a\C-xo\M->\C-y\C-m\C-xo") ;;; The Python interpreter sometimes needs a blank line and to end a block: (global-set-key "\C-x\C-m" "\C-xo\M->\C-m\C-xo") ;;; bind F7 to ispell on region: (global-set-key [f7] (lambda () (interactive) (setq m (mark)) (setq p (point-marker)) (if (< m p) (ispell-region m p) (ispell-region p m)))) ;;; bind F8 to ispell on word: (global-set-key [f8] (lambda () (interactive) (ispell-complete-word))) ;;; bind F9 to ispell on buffer: (global-set-key [f9] 'ispell-buffer) ;;; bind F10 to man of topic at cursor location: (global-set-key [(f10)] (lambda () (interactive) (manual-entry (current-word)))) ;;; shrink current window by one line if there's more than one window: (global-set-key "\M-o" (lambda () (interactive) (shrink-window 1))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; colors and fonts (set-cursor-color "yellow") (set-default-font "-*-helvetica-bold-r-*-*-16-*-*-*-*-*-*") ;;; use this for teaching: ;(set-default-font "-*-helvetica-bold-r-*-*-24-*-*-*-*-*-*") ; colors seem messed up: green gives purple, ;(set-mouse-color "red") ;;;; this is now in the files .emacsnn where nn is a font size (13, 18, 24) ;(set-default-font "-misc-fixed-*-*-*-*-13-*-*-*-*-*-*") ;(if (equal x-display-name "castle5082.research.att.com:0.0") ; (set-default-font "-misc-fixed-*-*-*-*-13-*-*-*-*-*-*") ; (set-default-font "-*-courier-bold-r-*-*-12-*-*-*-*-*-*") ;) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; scroll to keep cursor in window (setq scroll-conservatively 1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; (setq hilit-mode-enable-list '(not comint-mode)) ; important for tex ; (hilit-set-mode-patterns ; 'text-mode ; '( ; ("[0-9][0-9]*/[0-9][0-9]*/[0-9][0-9]" nil keyword) ; dates ; ("[0-9][0-9]*/[0-9][0-9]*" nil keyword) ; dates ; ("^[ ]*[A-Z][a-z]*:" nil label) ; headings ; ("^[ ]*[A-Z][A-Z]*:" nil label) ; headings ; ("^[ ]*From " nil label) ; headings ; ("\".*\"" nil keyword) ; headings ; )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Local Variables: ;;; mode: emacs-lisp ;;; mode: outline-minor ;;; outline-regexp: ";;; @+\\|(......" ;;; End: ; useful: ; (list-colors-display) ; x-colors ; (set-background-color "black") ; (set-foreground-color "white") ; (set-mouse-color "yellow") ; (set-cursor-color "yellow") ;;; syntax coloring: comments orange, strings red, function names green (in R, e.g.) ; from Help --> customize --> specific face --> comment face (custom-set-variables) (custom-set-faces '(font-lock-comment-face ((((class color) (background dark)) (:foreground "orange")))) '(font-lock-string-face ((((class color) (background dark)) (:foreground "red")))) '(font-lock-function-name-face ((((class color) (background dark)) (:foreground "green"))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Cygwin/bash-related settings: ;; NT-emacs assumes a Windows command shell, which you change here to bash: (setq process-coding-system-alist '(("bash" . undecided-unix))) (setq shell-file-name "bash") (setq explicit-shell-file-name shell-file-name) (setenv "SHELL" shell-file-name) ;; This removes unsightly ^M characters that would otherwise ;; appear in the output of java applications. (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m) ;; This assumes that Cygwin is installed in C:\cygwin (the default): (setq exec-path (cons "C:/cygwin/bin" exec-path)) ;; Prefer having all variables set, including those set by /etc/profile ;; and descendents, hence need a login shell with "--login": (setq explicit-bash-args (list "--login" "-i")) ;; We'd rather not duplicate the work of /etc/profile, ;; but "shell-command-on-region" needs this, ;; because it runs in a non-login shell that does not ;; call "/etc/profile" (creating an unfortunate duplication): (setenv "PATH" (concat "C:\\cygwin\\usr\\bin;" (getenv "PATH"))) (setenv "PATH" (concat "C:\\cygwin\\usr\\local\\bin;" (getenv "PATH"))) ;; The home directory is c:/ and not c:/cygwin/home/yourname, ;; so it is not found by cygwin. (setenv "HOME" "c:/") ;; Note: I pared the W2K path down to the defaults and added ;; to the bash/cygwin PATH in .bashrc instead. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;