|
Here are the .emacs, .login-local, and .cshrc-local files the CSC171 students had. If you like, copy them into your directory (save all your . files first - if you need help see me!!!) and you will then get compilation in emacs and other nice features.
;;;
;;; .emacs for new users : Copy this file to your home directory
;;; with the name ".emacs". You can use the command
;;; % cp dot-emacs ~/.emacs
;;; to do this.
;;;
;;; File created using George Ferguson's and Nat Martin's .emacs files,
;;; with some modifications.
;;;
;;;
;;; We need to set variables to hold the pathnames of our home directory
;;; and personal emacs directory, then set load-path so emacs knows where
;;; to find library (emacs-lisp) files. The default is the system directory,
;;; in our case "/usr/grads/lib/emacs/VERSION/lisp", and the local directory,
;;; in our case "/usr/grads/lib/emacs/site-lisp".
;;; The code code below also adds a personal library directory,
;;; "$HOME/lib/emacs", to your load-path. If you find useful Emacs stuff,
;;; that's where to put it so Emacs can "load" or "autoload" it.
;;;
(defvar homedir (getenv "HOME") "${HOME}")
(defvar emacslib (concat homedir "/lib/emacs/")
"Pathname of my private library")
(setq load-path (cons emacslib load-path))
;;;
;;; Personal key (re)bindings. Feel free to add your own or delete these
;;; to go back to the defaults.
;;;
(global-set-key "\M-h" help-map)
(define-key help-map "\M-h" 'help-for-help)
;;; set goto-line
(global-set-key "\C-g" 'goto-line)
;;; Then we can use C-h for backspace
(define-key global-map "\C-h" 'delete-backward-char)
;;; Make M-/ flash the matching open paren (sort of like vi)
(defun blink-paren ()
"Move cursor momentarily to the beginning of the sexp before point."
(interactive) (blink-matching-open))
(define-key global-map "\M-/" 'blink-paren)
;;; Make M-= print what line instead of info about the region
(define-key global-map "\M-=" 'what-line)
;; Make M-% with a prefix arg do query-replace-regexp and give up on
;; using the prefix arg to specify word-only matches.
(defun gf-query-replace (&optional arg)
"With prefix argument, do query-replace-regexp, else do query-replace."
(interactive "P")
(setq current-prefix-arg nil) ; so read-args doesn't get anything...
(call-interactively (if arg 'query-replace-regexp 'query-replace)))
(define-key esc-map "%" 'gf-query-replace)
;; Make it load the shell
(define-key global-map "\C-x\C-a" 'shell)
;;; Automode a-list: Sets buffer mode automatically based on filename.
;;; This is an association list (ie. a list of conses "(x . y)") where
;;; the car of each cons ("x") is a regular expression and the cdr ("y")
;;; is the name of a function that will set the mode of a buffer. Each
;;; time a file is visited in a buffer, the filename is matched against
;;; each regexp in turn. At the first match, the corresponding function
;;; is called to set the mode. If no regexp matches, then the buffer is
;;; left in "Fundamental" mode.
(setq auto-mode-alist
(append
(list
(cons "\\.h$" 'c++-mode)
(cons "\\.c$" 'c++-mode)
(cons "[iI]makefile$" 'imakefile-mode)
)
auto-mode-alist)
)
(setq default-major-mode 'text-mode)
;;;
;;; Miscellaneous customizations. You can get information on most of
;;; these variables by doing "M-h v" and then typing the variable's
;;; name followed by return (use C-h if you didn't change the help
;;; bindings as described above).
;;;
;; Always append a newline in case I forget, because some programs get
;; very upset when there isn't one.
(setq require-final-newline t)
;; Shut up about this
(put 'eval-expression 'disabled nil)
;; Use smooth scrolling with C-n and C-p.
(setq scroll-step 1)
;; Show the line number number
(line-number-mode 1)
;; Split screens use continuation lines also
(setq truncate-partial-width-windows nil)
;;; Set the speed up to which we will use the "slow mode" for incremental
;;; searching. This really saves redrawing on slow terminals.
(setq search-slow-speed 2400)
;;; Useful since termcap has a fixed size for vt100
(defun set-size (rows cols)
"Set size of current frame to ROWSxCOLS."
(interactive "nRows: \nnColumns: ")
(set-frame-size (selected-frame) cols rows))
;; Stop filling $HOME with files .saves-PID-HOSTNAME
(setq auto-save-list-file-name nil)
(setq auto-save-list-file-prefix nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Mode-specific customizations:
;;;
;;; Text customizations:
;;;
(defun save-buffer-and-server-edit ()
"Saves the current buffer then ends the server request. This is equivalent
to doing \"\\[save-buffer]\" followed by \"\\[server-edit]\"."
(interactive)
(save-buffer)
(server-edit))
(defun text-mode-initializations ()
"Initializations for text-mode."
(auto-fill-mode 1)
(setq sentence-end-double-space nil)
(define-key text-mode-map "\C-c\C-s" 'save-buffer-and-server-edit))
(add-hook 'text-mode-hook 'text-mode-initializations)
;; Whenever we're in text mode, automatically break lines at right margin.
;;(setq text-mode-hook 'turn-on-auto-fill)
;;;
;;; C mode customizations
;;;
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
(setq c-argdecl-indent 0)
(setq c-label-offset -2)
(defun c-insert-separator ()
"Insert a C comment code separator line."
(interactive)
(insert "/*\t-\t-\t-\t-\t-\t-\t-\t-\t*/\n"))
(defun c-goto-gdb ()
"Start gdb or switch to its buffer if already started.
Note: This functions switches to the first buffer named `*gud-...'."
(interactive)
(let* ((blist (buffer-list))
(found nil))
(while (and blist (not found))
(if (string-match "^\\*gud-" (buffer-name (car blist)))
(setq found (car blist))
(setq blist (cdr blist))))
(if found
(switch-to-buffer-other-window found)
(call-interactively 'gdb))))
(defun c++-insert-header-defines ()
(interactive)
(let ((tag (concat "_" (substring filename 0 -2) "_h")))
(insert (format "\n#ifndef %s\n#define %s\n\n\n\n#endif"
tag tag))
(forward-line -2)))
(defun id-and-date ()
"Returns user name, id, and date as a string."
(let* ((now (current-time-string))
(mon (substring now 4 7))
(day (substring now 8 10))
(year (substring now -4)))
(format "%s, %s@%s, %s %3s %4s"
(user-full-name) (user-login-name)
"cs.rochester.edu" day mon year)))
(defun c-mode-initializations ()
"Initializations for C and C++ modes."
;; Keybindings
(let ((keymap (current-local-map)))
(define-key keymap "\eq" nil) ; don't reformat paragraph!
(define-key keymap "\C-c_" 'c-insert-separator)
(define-key keymap "\C-c\C-c" 'compile)
(define-key keymap "\C-cg" 'c-goto-gdb))
;; Local variables
(setq compile-command "g++")
(setq compilation-read-command t)
(setq compilation-ask-about-save t)
;; This could be on find-file-hooks, but is ok here
(if (eq (buffer-size) 0)
(let ((filename (file-name-nondirectory (buffer-file-name))))
(insert (format "//\n// %s\n//\n// %s\n// %s\n//\n"
filename (id-and-date) "Time-stamp: <>" ))
(goto-char (point-max))
(if (string-match "\\.h$" filename)
(c++-insert-header-defines)))))
(add-hook 'c-mode-hook 'c-mode-initializations)
(add-hook 'c++-mode-hook 'c-mode-initializations)
;;; Debugging customizations
;;;
(defun debug-on-error ()
"Toggles the state of the DEBUG-ON-ERROR variable."
(interactive)
(setq debug-on-error (not debug-on-error))
(if debug-on-error
(message "Debugging enabled")
(message "Debugging disabled"))
)
;;;
;;; Autoload modules: Emacs allows you to delay the definition of functions
;;; by specifying that a file should be "autoloaded" when that function is
;;; first called. If the function is never called, then you save time and
;;; memory. Many of the functions are also bound to keys, and will be
;;; autoloaded when the key sequence is first encountered.
;;;
;;;
;;; time-stamp: Useful for timestamping files when you save them
;;;
(autoload 'time-stamp "time-stamp" "Update the time stamp in a buffer." t)
(if (not (memq 'time-stamp write-file-hooks))
(setq write-file-hooks
(cons 'time-stamp write-file-hooks)))
;; When in X, use whizzy font stuff
(cond
((eq window-system 'x)
;; Load the font-lock stuff
(require 'font-lock)
;; Arrange for many major modes to fontified
(mapcar '(lambda (mode)
(let ((hook (intern (concat (symbol-name mode) "-hook"))))
(add-hook hook 'turn-on-font-lock)))
'(c-mode c++-mode emacs-lisp-mode lisp-interaction-mode lisp-mode
latex-mode tex-mode slitex-mode
fi:lisp-mode fi:common-lisp-mode fi:inferior-lisp-mode))
))
;;; function for inhibiting creation of backup files; must be called when
;;; Emacs is invoked
;;;
(defun set-no-backup ()
(setq backup-inhibited t)
)
# # .login-local for CSC 171 users # # Nat Martin, martin@cs.rochester.edu, 23 Aug 1990. # mostly simplified from George Fergusons .login # # Note that $TERM and $HOME are set for us, and $TTY is set in # the .cshrc. Almost everything is this file is optional, except # setting the MANPATH and probably the tset command. # # We don't set the PATH here since .login isn't read for rshells! # # # Use less instead of more # setenv LESS 'M C h20' setenv PAGER 'less -s' # # Use jove as default editor # setenv EDITOR jove setenv VISUAL jove setenv ARCH `arch` # For TeX, LaTeX, etc. (the trailing colon means "append default path") # Uncomment and adjust these if you have personal TeX macros or fonts #setenv TEXINPUTS "$HOME/lib/tex/:" #setenv TEXFONTS "$HOME/lib/tex/:" # Don't leave big core files lying around. Use "unlimit" to turn this off. limit coredumpsize 1M # # This label is reached if we press ctrl-C at any point in the login process, # in particular during the sleeps above or if we don't take the # conditional above at all (ie., we are simply logging in, for example # rlogin). # clear date
# # .cshrc-local for new users # # Nat Martin, martin@cs.rochester.edu, 23 Jan 1997. # # If this shell is not interactive then we don't need the rest of this stuff if (! $?prompt) exit 0 # Auto completion for tcsh set autolist # Set these here since .cshrc is read before .login, but only .cshrc # is read for windows on the local machine. These are used in the prompt # below. If you don't like the fancy prompt, you can get rid of these. setenv HOSTNAME `hostname` setenv HOST `echo $HOSTNAME | cut -d. -f1` setenv TTY `tty` # # Aliases. (nmg) # alias t less alias ls ls -F alias rn trn alias md mkdir # let me quit if terminal gets locked in all caps mode alias EXIT exit |