;;; Linux .emacs      version 1.3     -*- emacs-lisp -*-
;;;
;;; written by:     Daniel Quinlan <quinlan@bucknell.edu> on 93/09/22
;;; last modified:  93/12/05 by Daniel Quinlan
;;;
;;; ** To learn how to use GNU Emacs better do the Emacs tutorial **
;;;
;;; You can start the Emacs tutorial in Emacs by typing "C-h t"
;;; (that means: hit "h" while pressing CONTROL, then hit "t" alone)
;;;
;;; If you need help with the Help system, type "C-h ?"

;;; --------------------------------------------------------------------
;;; variables and properties
;;; these are general settings for Emacs
;;; --------------------------------------------------------------------

(put 'eval-expression 'disabled nil)    ; enable eval-expression
(put 'narrow-to-region 'disabled nil)   ; enable narrow-to-region

(setq inhibit-startup-message t)        ; inhibit that nasty startup message
(setq make-backup-files nil)            ; don't backup 1st time a file is saved
(setq require-final-newline t)          ; silently ensure a final \n in files
(setq scroll-step 1)                    ; scroll one line at a time, always

(setq display-time-day-and-date t)      ; display time and date in status bar
(display-time)                          ; turn on the time display

;; some simple global key-bindings
(global-set-key "\C-x?" 'what-line)
(global-set-key "\C-x\C-g" 'goto-line)
(global-set-key "\C-x\C-r" 'rmail)
(global-set-key "\M-s" 'center-line)

;;; --------------------------------------------------------------------
;;; autoloads
;;; these features are automatically loaded when needed
;;; --------------------------------------------------------------------

;; a sample:
;; (autoload 'foo "foo" t)

;;; --------------------------------------------------------------------
;;; mode-hooks
;;; these are settings for editing modes
;;; --------------------------------------------------------------------

(setq c-mode-hook
      '(lambda()
         (setq c-argdecl-indent 0
               c-auto-newline nil
               c-brace-imaginary-offset 0
               c-brace-offset -4
               c-continued-statement-offset 4
               c-indent-level 4
               c-label-offset -4
               comment-column 40)))
(setq c++-mode-hook
      '(lambda()
         (setq c-indent-level 4
               c-continued-statement-offset 4
               c-brace-offset -4
               c-brace-imaginary-offset 0
               c-argdecl-indent 0
               c-label-offset -4
               c-indent-level 4
               comment-column 40
               c++-empty-arglist-indent 4
               c++-friend-offset 0)))
(setq text-mode-hook
      '(lambda()
         (auto-fill-mode 1)))

;;; --------------------------------------------------------------------
;;; Rmail setup
;;; read electronic mail
;;;
;;; to start: "C-x C-r" or "M-x rmail"
;;; --------------------------------------------------------------------

;; you need to have your MAIL shell environment variable set
(setq rmail-primary-inbox-list (cons (getenv "MAIL") nil))

;; the more ignored headers, the merrier
(setq rmail-ignored-headers
      "^[a-z-]*message-id:\\|^address:\\|^apparently-to:\\|^command:\\|^comment.*:\\|^content-.*:\\|^conversion:\\|^date-received:\\|^distribution:\\|^encoding:\\|^errors-to:\\|^fax:\\|^geis-id:\\|^illegal-object:\\|^in-reply-to:\\|^lines:\\|^mailer:\\|^mail-.*:\\|^message-id:\\|^mime-.*\\|^mmdf-.*:\\|^newsgroups:\\|^organi[sz]ation:\\|^origin.*:\\|^path:\\|^phone:\\|^pmdf-warning:\\|^posted-date:\\|^posting-version:\\|^precedence:\\|^received:\\|^references:\\|^relay-version:\\|^reply-to:\\|^resent-.*:\\|^return-.*:\\|^sender:\\|^source-info:\\|^stanford-phone:\\|^status:\\|^summary-line:\\|^version:\\|^via:\\|^x400-.*\\|^x-.*:")

;;; --------------------------------------------------------------------
;;; Gnus setup
;;; read Usenet (network) news
;;;
;;; to start:
;;; M-x "gnus"                  read network news
;;; M-x "gnus-post-news"        begin editing an article to be posted
;;; --------------------------------------------------------------------

;; again, the more ignored headers, the merrier
(setq gnus-ignored-headers
      "^apparently-to:\\|^approved:\\|^article-i.d.:\\|^checksum:\\|^command:\\|^comments:\\|^content-.*:\\|^date-received:\\|^disclaimer.*:\\|^distribution:\\|^email-archive:\\|^errors-to:\\|^expires:\\|^illegal-object:\\|^in-reply-to:\\|^lines:\\|^mail-.*:\\|^maint-path:\\|^message-id:\\|^mime-.*:\\|^mmdf-warning:\\|^news-software:\\|^nf-.*:\\|^nntp-.*:\\|^original_.*:\\|^originator:\\|^path:\\|^phone:\\|^pmdf-warning:\\|^posted-date:\\|^posting-version:\\|^precedence:\\|^received:\\|^references:\\|^relay-version:\\|^reply-to:\\|^resent-.*:\\|^return-.*:\\|^sender.*:\\|^source-info:\\|^stanford-phone:\\|^status:\\|^supersedes:\\|^uusplit-.*:\\|^via:\\|^x-.*:\\|^xdisclaimer:\\|^xref:")

;;; --------------------------------------------------------------------
;;; trim whitespace (a simple favorite of mine...)
;;; delete extra spaces at the end of lines or at the end of the file
;;;
;;; From: Daniel Quinlan <quinlan@bucknell.edu>
;;;
;;; to invoke: "M-x trim"
;;; --------------------------------------------------------------------

(defun trim ()
  "Delete trailing whitespace in buffer"
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (replace-regexp "[ \t]+$" "")
    (goto-char (point-max))
    (skip-chars-backward "\n")
    (if (not (eobp))
	(delete-region (1+ (point)) (point-max)))))

;;; --------------------------------------------------------------------
;;; optional settings
;;; --------------------------------------------------------------------

;; to save outgoing mail in ~/.record
;; 1. uncomment the "setq" line
;; 2. restart Emacs
;;
;;(setq mail-archive-file-name "~/.record")

;;; --------------------------------------------------------------------
