;;; Copyright (c) 2004-2007 bivio Software, Inc. All rights reserved. ;;; ;;; Visit http://www.bivio.biz for more info. ;;; ;;; This library is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU Lesser General Public License as ;;; published by the Free Software Foundation; either version 2.1 of the ;;; License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; If not, you may get a copy from: ;;; http://www.opensource.org/licenses/lgpl-license.html ;;; ;;; $Id: b-site-start.el,v 1.42 2011/09/22 16:07:50 nagler Exp $ ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; You will need to define a few variables after this file is ;;; loaded. Search for the word "YOUR" in all upper-case. ;;; (provide 'b-site-start) (load-library "b-perl") (load-library "b-hours") (require 'sgml-mode) (require 'compile) (require 'cc-mode) (require 'comint) (global-font-lock-mode t) (setq next-line-add-newlines nil case-replace t case-fold-search t visible-bell t highlight-nonselected-windows nil term-term-name "eterm" ring-bell-function 'ignore truncate-partial-width-windows nil completion-ignore-case t read-file-name-completion-ignore-case t read-buffer-completion-ignore-case t large-file-warning-threshold 100000000) (unless window-system (progn (if (string-match "^21" emacs-version) (set-keyboard-coding-system nil)) (setq visible-bell nil))) ;;; This show you what you've selected with the mouse (transient-mark-mode t) ;; accelerate scrolling when the mouse gets dragged beyond the edge of a window (if (string-equal system-type "darwin") (progn (setq mouse-scroll-delay 0.1) (if (functionp 'server-force-delete) (server-force-delete)) (server-start) (global-set-key [?\A-S] 'write-file) (global-set-key [?\A-a] 'mark-whole-buffer) (global-set-key [?\A-c] 'clipboard-kill-ring-save) (global-set-key [?\A-f] 'isearch-forward) (global-set-key [?\A-l] 'goto-line) (global-set-key [?\A-n] 'new-frame) (global-set-key [?\A-o] 'find-file) (global-set-key [?\A-q] 'save-buffers-kill-emacs) (global-set-key [?\A-s] 'save-buffer) (global-set-key [?\A-v] 'clipboard-yank) (global-set-key [?\A-x] 'clipboard-kill-region) (global-set-key [?\A-z] 'undo)) (if (string-equal system-type "windows-nt") (progn (setq x-select-enable-clipboard t) (if (load "gnuserv" 'noerror 'nomessage) (progn (gnuserv-start) (setq gnuserv-frame (selected-frame))) )) (progn (server-start) ;; Setting this to true does not allow pasting between emacs and ;; normal windows. (setq x-select-enable-clipboard nil)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; abbrevs.el (load if exists) ;;; (condition-case nil (quietly-read-abbrev-file) (error nil)) ; Bind some keys so people know they are there... (define-key ctl-x-map "ae" 'edit-abbrevs) ; We want to actually write the file each time. It is a cleaner model ; for the user. (define-key edit-abbrevs-map "\C-c\C-c" 'save-abbrevs-redefine) (define-key edit-abbrevs-map "\C-x\C-s" 'save-abbrevs-redefine) (defun save-abbrevs-redefine () "Redefine abbrevs according to current buffer contents and save." (interactive) (edit-abbrevs-redefine) (write-abbrev-file abbrev-file-name) (setq abbrevs-changed nil)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; compile.el fixes ;;; (eval-after-load "compile" '(setq compilation-error-regexp-alist (append '((".*at \\([^ ]+\\) line \\([0-9]+\\)\\.?\n" 1 2)) ; Support perl compilation-error-regexp-alist))) (add-hook 'mail-setup-hook 'mail-abbrevs-setup) (setq mail-self-blind t) (put 'eval-expression 'disabled nil) (put 'narrow-to-region 'disabled nil) (setq visible-bell t) (setq indent-line-function 'indent-relative-maybe) ;; some file name extensions (load "sgml-mode") ;; Delete unwanted auto-modes (setq interpreter-mode-alist nil) (mapcar '(lambda (mode) (let ((x)) ; Delete all occurances (while (setq x (rassoc mode auto-mode-alist)) (setq auto-mode-alist (delq x auto-mode-alist))))) '(tcl-mode sh-mode nroff-mode)) (add-hook 'text-mode-hook '(lambda () (abbrev-mode t) (define-key text-mode-map "\C-c|" (lambda () "insert change bar at end of line" (interactive) (end-of-line) (if (< (current-column) fill-column) (move-to-column fill-column t) (insert " ")) (insert "|") (forward-line))) (turn-on-auto-fill))) (setq dabbrev-case-fold-search t) (setq dabbrev-case-replace nil) (setq dabbrev-abbrev-char-regexp "\\sw\\|\\s_") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ;;;; C ;;;; (add-hook 'java-mode-hook '(lambda () (c-set-style "RGI") (make-local-variable 'compile-command) (setq compile-command (concat (if (getenv "JAVAC") (getenv "JAVAC") "javac") " " (if (getenv "JAVAC_FLAGS") (getenv "JAVAC_FLAGS") "-g") " " (file-name-nondirectory buffer-file-name))) (cond (window-system (require 'andersl-java-font-lock) (turn-on-font-lock))))) (setq font-lock-maximum-decoration t) (add-hook 'c-mode-common-hook '(lambda () (setq fill-column 79) (setq c-tab-always-indent nil) (setq c-echo-syntactic-information-p t) (modify-syntax-entry ?_ "w" c-mode-syntax-table) (c-toggle-auto-state +1) (c-toggle-hungry-state -1) (auto-fill-mode +1) (abbrev-mode t) )) (modify-syntax-entry ?_ "w" c-mode-syntax-table) (modify-syntax-entry ?$ "w" java-mode-syntax-table) (define-key c-mode-map "\C-c\C-c" 'next-error) (define-key c-mode-map "\C-c\C-m" 'compile) (define-key c-mode-map "\C-c\C-f" 'auto-fill-mode) (define-key c-mode-map "\C-m" 'newline-and-indent) (define-key c-mode-base-map "\C-c;" 'c-right-justify-comment) (define-key c-mode-base-map "\C-c," 'c-align-decls) (define-key c-mode-base-map "\C-c\C-m" 'compile) (define-key c-mode-base-map "\C-c\C-m" 'compile) (define-key c-mode-base-map "\C-c\C-e" 'next-error) (define-key java-mode-map "\C-c<" (lambda () "insert <" (interactive) (insert "<"))) (define-key java-mode-map "\C-c>" (lambda () "insert >" (interactive) (insert ">"))) (define-key java-mode-map "\C-c " (lambda () "insert  " (interactive) (insert " "))) (define-key java-mode-map "\C-c\n" (lambda () "insert
" (interactive) (insert "
") (newline-and-indent))) (define-key java-mode-map "\C-ct" (lambda () "insert " (interactive) (sgml-tag "tt"))) (define-key java-mode-map "\C-cp" (lambda () "insert

" (interactive) (insert "

") (newline-and-indent) (newline-and-indent))) (define-key java-mode-map "\C-cs" (lambda () "insert " (interactive) (sgml-tag "strong"))) (define-key java-mode-map "\C-ci" (lambda () "insert " (interactive) (sgml-tag "em"))) (define-key java-mode-map "\C-cx" (lambda () "insert

" (interactive)
	(newline-and-indent)
	(insert "
")
	(newline-and-indent)
	(insert "
") (forward-line -1) (end-of-line) (newline-and-indent))) (define-key java-mode-map "\C-ch" (lambda () "insert

" (interactive) (newline-and-indent) (insert "

") (newline-and-indent) (insert "

") (forward-line -1) (end-of-line) (newline-and-indent))) (define-key java-mode-map "\C-c/" (lambda () "insert a javadoc comment" (interactive) (previous-line 1) (newline-and-indent) (insert "**/"); insert end first, so indentation aligns correctly (previous-line 1) (newline-and-indent) (insert "/**") (end-of-line) (newline-and-indent))) (define-key java-mode-map "\C-cl" (lambda (label) "insert {@link

 tag"
	(interactive "p") (sgml-tag "pre")))
    (define-key html-mode-map "\C-ct"
      (lambda (&optional arg) "inserts  tag"
	(interactive "p") (sgml-tag "table")))))
(if (and (boundp 'html-mode-map) (keymapp html-mode-map))
    (eval my-html-hook)
  (eval-after-load
      "html-mode"
    my-html-hook))

(autoload 'sqlplus "sql-mode" 
  "Run an interactive SQL*plus session in a separate buffer." t)
(setq sqlplus-mode-hook
      '(lambda ()
	 (turn-on-font-lock)
	 (define-key sqlplus-mode-map "\M-p" 'sqlplus-previous-command)
	 (define-key sqlplus-mode-map "\M-n" 'sqlplus-forward-command)))
(autoload 'sql-mode "sql-mode"
  "Major mode for editing SQL*plus batch files." t)
(setq sql-mode-hook
      '(lambda ()
	 (turn-on-font-lock)))
(autoload 'pls-mode  "pls-mode" "PL/SQL Editing Mode" t)
(autoload 'diana-mode  "pls-mode" "DIANA for PL/SQL Browsing Mode" t)
(if (boundp 'magic-mode-alist)
    (setq magic-mode-alist
	  (append '(("@h[1-4]" . text-mode))
		  magic-mode-alist)))
(setq auto-mode-alist
      (append '(("\\.pls$"  . pls-mode)
		("\\.sql$"  . pls-mode)
		; File begins with single letter followed by letters and
		; dashes is a cperl command.  All lower case.
		("/perl/.*/[a-z][a-z]?[a-z]?-[a-z0-9-]+$"  . cperl-mode)
		("\\.\\(bview\\|bconf\\|btest\\|bunit\\|t\\)$"  . cperl-mode)
                ("\\.\\([pP]\\([Llm]\\|erl\\)\\|al\\)\\'" . cperl-mode)
		("\\.pld$"  . diana-mode)
		)
	      auto-mode-alist))
(setq pls-mode-hook
      '(lambda ()
	 (turn-on-font-lock)
	 (define-key pls-mode-map "\C-c\C-m" 'sql-send-buffer)
	 (define-key pls-mode-map "\C-c\C-j" 'sql-send-region)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; Keys
;;;;

;;;; Ordinary keys
;;; Adds a new top menu to the menu bar
(define-key global-map "\177" 'backward-delete-char-untabify)

;;;; Control keys
(define-key text-mode-map "\C-i" 'shift-right)
(define-key global-map "\C-m" 'newline-and-indent)
(define-key global-map "\C-r" 'isearch-backward-regexp)
(define-key global-map "\C-s" 'isearch-forward-regexp)
(define-key global-map "\C-z" 'scroll-one-line-up)
(define-key global-map "\C-_" 'advertised-undo)

;;;; Meta keys
(define-key global-map "\M-c" 'backward-capitalize-word)
(define-key global-map "\M-h" 'backward-kill-word)
(define-key global-map "\M-i" 'shift-left)
(define-key global-map "\M-l" 'backward-downcase-word)
(define-key global-map "\M-p" 'mark-paragraph)
(define-key global-map "\M-u" 'backward-upcase-word)
(define-key global-map "\M-z" 'scroll-one-line-down)
(define-key global-map "\M-'" 'dabbrev-expand)
(define-key global-map "\M-C-'" 'dabbrev-completion)
(define-key global-map "\M-/" 'abbrev-prefix-mark)
(define-key global-map "\M-%" 'query-replace-regexp)

;;;; Control-x keys
(define-key ctl-x-map "l" 'goto-line)
(define-key ctl-x-map "n" 'gosmacs-next-window)
(define-key ctl-x-map "p" 'gosmacs-previous-window)

;;;; Control-x Control keys
(define-key ctl-x-map "\C-d" 'delete-window)
(define-key ctl-x-map "c" 'center-line)
(define-key ctl-x-map "\C-j" 'join-line)
(define-key ctl-x-map "\C-l" 'sort-lines)
(define-key ctl-x-map "\C-m" 'shell)
(define-key ctl-x-map "\C-n" 'insert-buffer)
(define-key ctl-x-map "\C-u" nil); DELETE
(define-key ctl-x-map "\C-z" 'shrink-window)

(put 'downcase-region 'disabled nil)