; rename this file _emacs in your .../emacs-19.19 directory
; the underscore is vital

(emacs-pc-enable-mouse)
(setq
      default-major-mode 'indented-text-mode
      inhibit-startup-message t
      remind-me-of-emacs-help-key nil
) ; setq

(define-key global-map [(S-mouse-1)] 'mouse-yank-at-click)
(define-key global-map "\e#"     'query-replace-regexp)
(define-key global-map "\C-x\C-j" 'goto-line)
(define-key global-map "[" 'beginning-of-buffer) 
(define-key global-map [(C-next)] 'end-of-buffer)
(define-key global-map [(C-home)] "\e0\er")
(define-key global-map [(C-end)] "\e-1\er")
(define-key global-map [(C-left)] 'backward-word)
(define-key global-map [(C-right)] 'forward-word)
(define-key global-map [(f9)] 'back-toggle-case)
(define-key global-map [(f10)] 'toggle-pc-line-mode)
(define-key help-map "a" 'apropos)

; to make new-pascal-mode happen automatically you have to
; put it in the lisp code directory of your oemacs
; and make these modifications
(setq auto-mode-alist
      (cons '("\\.p$" . new-pascal-mode)
            (cons '("\\.pas" . new-pascal-mode)
                  (cons '("_emacs$" . emacs-lisp-mode)
                        (cons '("\\.ms$" . nroff-mode)
                              auto-mode-alist)))))

; you need to change the path in the following string to reflect
; where you put new pascal mode.  Then remove the ';' comment
; characters from the following two lines
;(autoload 'new-pascal-mode "j:/emacs/lisp/modes/newerpas.el"
;          "major mode for editing pascal files" t)



(setq awk-mode-hook
      '(lambda nil
         (setq indent-line-function 'c-indent-command)))

; the following handy function is attached to f9 above
(defun back-toggle-case ()
  "toggle case of preceding word from lc to uc to capitalized"
  (interactive)
  (let ((case-fold-search nil))
    (backward-word 1)
    (cond ((looking-at "\\b[A-Z]\\(\\b\\|[a-z]\\)")(downcase-word 1))
          ((looking-at "\\b[A-Z][A-Z]")(capitalize-word 1))
          (t (upcase-word 1)))))


; this is where you change colors
; this is set up for black on white background
; with inverted modeline

(defun after-term-setup ()
  (progn
    (cond
     ( (eq window-system 'pc)
       (progn
         ;;
         ;; Set PC text display colors
         ;;
         (set-face-foreground 'default "black")
         (set-face-background 'default "white")
         (invert-face (internal-get-face 'modeline nil))
         ))
     ( (eq window-system 'x)
       (progn
         ;;
         ;; Set X11 (DESQview/X) keybindings
         ;;
         (global-set-key [home] 'beginning-of-line)
         (global-set-key [end] 'end-of-line)
         (global-set-key [C-home] 'beginning-of-buffer)
         (global-set-key [C-end] 'end-of-buffer)
         ;;
         ;; Set X11 default foreground and background colors
         ;;
         (set-face-foreground 'default "gray60")
         (set-face-background 'default "blue")
         ;;
         ;; Turn off the scroll bar display
         ;;
         (scroll-bar-mode -1)
         ;;
         ;; Turn off the menu bar display
         ;;
         (menu-bar-mode -1)
         ))
     )
    ))

(setq term-setup-hook 'after-term-setup)


; the following lets you change the number of lines on the screen
; among 25 43 and 50.  It is attached to f10 above

(defvar pc-line-mode 0 "lines on the current screen")

(defun toggle-pc-line-mode()
  "rotate among 25 43 and 50 lines on the screen"
  (interactive)
  (cond ((= pc-line-mode 25)
         (setq pc-line-mode 43)
         (emacs-pc-43-line-mode))
        ((= pc-line-mode 43)
         (setq pc-line-mode 50)
         (emacs-pc-50-line-mode))
        (t (setq pc-line-mode 25)
           (emacs-pc-25-line-mode))))

;; yank-pop (ESC-y) is broken in this edition of oemacs
;; the following defun makes it work properly

(defun current-kill (n &optional do-not-move)
  "Rotate the yanking point by N places, and then return that kill.
If optional arg DO-NOT-MOVE is non-nil, then don't actually move the 
yanking point; just return the Nth kill forward."

  (or kill-ring (error "Kill ring is empty"))
  (let ((ARGth-kill-element
         (nthcdr (mod (- n (length kill-ring-yank-pointer))
                      (length kill-ring))
                 kill-ring)))
    (or do-not-move
        (setq kill-ring-yank-pointer ARGth-kill-element))
    (car ARGth-kill-element)))

