(defun my-shell-mode-hook ()
(setq indent-tabs-mode nil
tab-width 2))
(add-hook 'sh-mode-hook 'my-shell-mode-hook)
(defun my-cperl-hook ()
(setq cperl-indent-level 4)
(setq cperl-continued-statement-offset 4)
(setq cperl-brace-offset -4)
(setq cperl-label-offset -4)
)
(add-hook 'cperl-mode-hook 'my-cperl-hook)
(load "/usr/share/emacs/site-lisp/cedet/common/cedet")
(require 'ecb)
(defun switch-to-eshell ()
"Open a new window with a eshell or jump to an open eshell window.
Takes in account that a possibly running ecb might display the shell
in a compile window."
(interactive)
(let ((shellbuf (get-buffer "*eshell*")))
(if (buffer-live-p shellbuf)
(if (eq (current-buffer) shellbuf)
(delete-window)
(if ecb-compile-window
(switch-to-buffer shellbuf)
(switch-to-buffer-other-window shellbuf))
(end-of-buffer))
(unless ecb-compile-window
(split-window-vertically))
(eshell)
)))
(defun switch-to-shell ()
"Open a new window with a shell or jump to an open shell window.
Takes in account that a possibly running ecb might display the shell
in a compile window."
(interactive)
(let ((shellbuf (get-buffer "*bash*")))
(if (buffer-live-p shellbuf)
(if (eq (current-buffer) shellbuf)
(delete-window)
(if ecb-compile-window
(switch-to-buffer shellbuf)
(switch-to-buffer-other-window shellbuf))
(end-of-buffer))
(unless ecb-compile-window
(split-window-vertically))
(ansi-term "/bin/bash" "bash")
)))
(defun switch-to-compilation ()
"Open or hide the compilation window and put cursor into it."
(interactive)
(if (and ecb-minor-mode ecb-compile-window)
(if (window-live-p ecb-compile-window)
(if (eq (window-buffer ecb-compile-window) (current-buffer))
(ecb-toggle-compile-window-height)
(ecb-goto-window-compilation))
(ecb-toggle-compile-window)
(ecb-goto-window-compilation))
(let ((buf (get-buffer "*compilation*")))
(if (buffer-live-p buf)
(if (eq (current-buffer) buf)
(delete-window)
(switch-to-buffer-other-window buf))
(switch-to-buffer-other-window "*compilation*")))))
(defun ecb-hide-compile-window (buf msg)
"Hide the compilation window and display message"
(save-excursion
(set-buffer buf)
(if (or (string-match ".*exited abnormally.*" msg)
(string-match ".*BUILD FAILED.*" (buffer-string)))
(if jde-compile-jump-to-first-error (next-error))
(if (and ecb-minor-mode ecb-compile-window-height)
(ecb-toggle-compile-window)
(lexical-let ((compile-buffer buf))
(run-at-time "1 sec" nil 'jde-compile-kill-buffer compile-buffer)
(message "No errors.")))
(message "No errors."))))
(defun delete-other-windows-hide-compile-window (&optional window)
"hide ecb compile window also when deleting other windows"
(interactive)
(ecb-goto-window-edit-last)
(delete-other-windows window)
(when (and ecb-minor-mode ecb-compile-window-height)
(ecb-toggle-compile-window -1))
(ecb-goto-window-edit1))
(global-set-key [(insert)] 'ecb-redraw-layout)
(global-set-key [(kp-insert)] 'ecb-redraw-layout)
(global-set-key [(kp-0)] 'ecb-redraw-layout)
(define-key goto-keymap [?s] 'switch-to-eshell)
(define-key goto-keymap [?t] 'switch-to-shell)
(define-key goto-keymap [?c] 'switch-to-compilation)
(define-key goto-keymap [?d] 'ecb-minor-mode)
(define-key ecb-mode-map [(control c) ?1] 'ecb-goto-window-edit1)
(define-key ecb-mode-map [(control c) ?2] 'ecb-goto-window-edit2)
(defun ecb-dir-popup-ant (node target)
"Run ant in directory with target"
(require 'jde-ant)
(let* ((dir (tree-node-get-data node))
(project-file (jde-ant-find-build-file
(if (file-directory-p dir) dir
(file-name-directory dir)))))
(jde-ant-build project-file target)))
(tree-buffer-defpopup-command ecb-dir-popup-ant-build
"Build project in directory"
(ecb-dir-popup-ant node "build"))
(tree-buffer-defpopup-command ecb-dir-popup-ant-rebuild
"Build project in directory"
(ecb-dir-popup-ant node "clean build"))
(tree-buffer-defpopup-command ecb-dir-popup-ant-clean
"Clean project in directory"
(ecb-dir-popup-ant node "clean"))
(tree-buffer-defpopup-command ecb-dir-popup-ant-test
"Test project in directory"
(ecb-dir-popup-ant node "test"))
(tree-buffer-defpopup-command ecb-dir-popup-ant-site
"Build site for project in directory"
(ecb-dir-popup-ant node "site"))
(tree-buffer-defpopup-command ecb-dir-popup-ant-javadoc
"Build javadoc for project in directory"
(ecb-dir-popup-ant node "javadoc"))
(tree-buffer-defpopup-command ecb-dir-popup-cvs-status-local
"Check status of directory \(and below) in pcl-cvs mode."
(ecb-dir-run-cvs-op node 'cvs-status '("-l -v")))
(tree-buffer-defpopup-command ecb-dir-popup-svn-status
"Check status of directory \(and below) in psvn mode."
(let ((dir (tree-node->data node)))
(svn-status dir)))
(setq ecb-directories-menu-user-extension-function
(lambda ()
'(("Ant/Maven"
(ecb-dir-popup-ant-build "Build")
(ecb-dir-popup-ant-rebuild "Rebuild")
(ecb-dir-popup-ant-build-tests "Build Tests")
(ecb-dir-popup-ant-clean "Clean")
(ecb-dir-popup-ant-test "Run All Tests")
(ecb-dir-popup-ant-site "Build Site")
(ecb-dir-popup-ant-javadoc "Build Javadoc"))
("CVS"
(ecb-dir-popup-cvs-status-local "Directory Status")
(ecb-dir-popup-cvs-status "Subtree Status")
(ecb-dir-popup-cvs-examine "Examine Subtree")
(ecb-dir-popup-cvs-update "Update Subtree"))
("SVN"
(ecb-dir-popup-svn-status "Subtree Status")))))
(tree-buffer-defpopup-command ecb-file-popup-create-interface
"Generate a interface source file"
(let ((node-data=file (tree-node-get-data node)))
(jde-gen-interface-buffer)))
(tree-buffer-defpopup-command ecb-file-popup-ant-test
"Test single file"
(let* ((class-name (file-name-sans-extension (file-name-nondirectory (tree-node-get-data node))))
(test-name (concat class-name (if (not (string-match "Test" class-name)) "Test"))))
(ecb-dir-popup-ant node
(concat "-Dtestmatch='" test-name "' test:match"))))
(defun ecb-file-popup-function ()
"Return a pop menu list for the ecb sources window"
'((ecb-file-popup-ant-test "Run Test")
("---")))
(require 'compile)
(setq-default compile-command "make ")
(setq compile-auto-highlight t)
(setq compilation-scroll-output t)
(setq compilation-window-height 8)
(global-set-key [(f10)] 'next-error) (global-set-key [(control f10)] 'previous-error)
(defun my-compilation-mode-hook ()
"Function to run when entering compilation mode"
(setq buffer-read-only nil)
(setq truncate-partial-width-windows nil
truncate-lines nil))
(add-hook 'compilation-mode-hook 'my-compilation-mode-hook)
(global-set-key [(control x) (control a)]
(lambda ()
(interactive)
(add-change-log-entry nil (expand-file-name "ChangeLog") t nil)))
(eval-after-load "add-log"
'(define-key change-log-mode-map[(control c)(control c)]
(lambda ()
(interactive)
(save-buffer)
(kill-buffer-and-window))))
(require 'ascii-table nil t)
(defun ole-ascii-table ()
"Display an ASCII table in a small buffer"
(interactive)
(let ((i 32)
(buffer (get-buffer "*ascii-table*")))
(if buffer
nil
(setq buffer (create-file-buffer "*ascii-table*"))
(set-buffer buffer)
(while (< i 128)
(insert (concat " " (char-to-string i)))
(setq i (+ i 1)))
(beginning-of-buffer)
(fill-paragraph t))
(switch-to-buffer-other-window buffer)
(shrink-window-if-larger-than-buffer)))
(setq get-rfc-local-rfc-directory (expand-file-name "~/doc/rfc/")
get-rfc-open-in-new-frame nil)
(autoload 'rfcview-mode "rfcview" nil t)
(setq auto-mode-alist (cons '("/rfc[0-9]+\\.txt" . rfcview-mode)
auto-mode-alist))
(defun rfc (num)
"Show RFC NUM in a buffer."
(interactive "nRFC (0 for index): ")
(let ((url (if (zerop num)
"http://www.ietf.org/iesg/1rfc_index.txt"
(format "http://www.ietf.org/rfc/rfc%i.txt" num)))
(buf (get-buffer-create "*RFC*")))
(with-current-buffer buf
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
(let ((proc (start-process "wget" buf "wget" "-q" "-O" "-" url)))
(set-process-sentinel proc 'rfc-sentinel))
(message "Getting RFC %i..." num)))))
(defun rfc-sentinel (proc event)
"Sentinel for `rfc'."
(with-current-buffer (process-buffer proc)
(goto-char (point-min))
(view-mode 1)
(when (fboundp 'rfcview-mode)
(rfcview-mode)))
(display-buffer (process-buffer proc)))
(add-to-list 'auto-mode-alist '("\\.sql$" . sql-mode))
(setq sql-electric-stuff 'semicolon)