;;; To make emacs load this file just once, save it to a location of ;;; your choice. Then start emacs via "emacs -no-init-file", run the ;;; command "M-x load-file", and give emacs the full path name of your ;;; saved file. ;;; ;;; ;;; To make emacs load this file each time it starts, save it as ;;; "_emacs" in your cs1300\emacs\site-lisp directory. In order to do ;;; this, you'll need to rename the current "_emacs" file via these ;;; commands: ;;; ;;; c: ;;; cd c:\cs1300\emacs\site-lisp ;;; move _emacs _emacs.txt ;;; ;;; Then download this file as "emacs.txt" and rename it to "_emacs": ;;; ;;; move emacs.txt _emacs ;;; ;;; Now restart emacs. ;;; ;;; --------------------------------------------------------------- (setq fill-column 80) ;;; Limit text lines to 80 chars (setq line-number-mode t) ;;; Put line number in display (setq column-number-mode t) ;;; Put column number in display (display-time) ;;; Put time in display (global-set-key "\C-cg" 'goto-line) ;;; Bind "C-cg" to goto-line (global-set-key "\C-z" 'shell) ;;; Bind "C-z" to shell (defun yes-or-no-p (prompt) (y-or-n-p prompt)) ;;; allow "y" to mean "yes" (setq insert-default-directory nil) ;;; don't show directory in find-file ;;; --------------------------------------------------------------- ;;; The following lines make emacs use its C++ mode when it loads a file whose ;;; name ends ".cxx", ".h", or ".template". (setq auto-mode-alist (cons '("\\.h$" . c++-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.template$" . c++-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.cxx$" . c++-mode) auto-mode-alist)) ;;; --------------------------------------------------------------- ;;; The following lines are a function to indent an entire buffer. (defun indent-all () "Indent entire buffer." (interactive) (indent-region (point-min) (point-max) nil)) (global-set-key "\M-p" 'indent-all) ;;; Bind M-p to indent-all ;;; --------------------------------------------------------------- ;;; The following lines make the c++-mode behave nicely. (add-hook 'c++-mode-hook '(lambda() (c-set-style "k&r") ;;; Kernihan & Richie's style (setq c-basic-offset 4) ;;; 4 spaces for indentations (c-set-offset 'substatement-open 0) ;;; No indent for open bracket ) ) ;;; --------------------------------------------------------------- ;;; The following lines allow C-j to cause emacs to cycle among its ;;; buffers. (This is a hack, but it seems to work.) (defun jg-last (list) "returns last element of a list" (while (> (length list) 1) (setq list (cdr list))) (car list)) (defun jg-buffer-ring () "switches among buffers on buffer list, killing the following annoying buffers if they are encountered: *Completions* *Deletions* *Buffer List* *Help* *Minibuf-0* *Minibuf-1* *Minibuf-2* *scratch* " (interactive) (setq loop t) (while loop (switch-to-buffer (jg-last (buffer-list))) (if (or (equal (buffer-name) "*Completions*") (equal (buffer-name) " *Deletions*") (equal (buffer-name) "*Messages*") (equal (buffer-name) "*Buffer List*") (equal (buffer-name) "*Help*") (equal (buffer-name) " *Minibuf-0*") (equal (buffer-name) " *Minibuf-1*") (equal (buffer-name) " *Minibuf-2*") ;; length test below prevents infinite loop: I kill buffer ;; *scratch*, emacs restarts it, repeat (and (> (length (buffer-list)) 2) (equal (buffer-name) "*scratch*")) ) (kill-buffer (buffer-name)) (setq loop nil)))) (global-set-key "\C-j" 'jg-buffer-ring) ;;; ---------------------------------------------------------------