;; My favorite completer package ;;(load "completer") ;;(require 'efs) (partial-completion-mode t) (global-font-lock-mode t) (transient-mark-mode t) (delete-selection-mode t) (setenv "unix" "/ubloewd@dvc772:~") (getenv "unix") (load "filladapt") (load "carbon-buffer") (load "clearcase") (set-background-color "black") (set-foreground-color "white") (set-cursor-color "white") (global-set-key "\C-c\C-l" 'horizontal-recenterer) (defun horizontal-recenterer () (interactive) (let ((hr-last-command last-command)) (setq automatic-hscrolling nil) (scroll-right 8000000) (scroll-left (current-column)) (cond ((eq hr-last-command 'hcenterer2) ; 3 times pressed = right (scroll-right (- (window-width) 1))) ((eq hr-last-command 'hcenterer1) ; 2 times pressed = left (setq this-command 'hcenterer2)) (t (scroll-right (/ (window-width) 2)) ; 1 time pressed = middle (setq automatic-hscrolling t) (setq this-command 'hcenterer1))))) ;; Centering code stolen from somewhere (global-set-key "\C-l" 'centerer) (defun centerer () "Repositions current line: once middle, twice top, thrice bottom" (interactive) (cond ((eq last-command 'centerer2) ; 3 times pressed = bottom (recenter -1)) ((eq last-command 'centerer1) ; 2 times pressed = top (recenter 0) (setq this-command 'centerer2)) (t ; 1 time pressed = middle (recenter) (setq this-command 'centerer1)))) (defun tidy-xml-region (start end) "Use the tidy program (http://tidy.sourceforge.net) to beautify the region." (interactive "r") (let ((error-buff (get-buffer-create "*Tidy Errors*")) (coding-system-for-read 'no-conversion) (coding-system-for-write 'no-conversion)) (with-current-buffer error-buff (erase-buffer)) (shell-command-on-region start end "tidy -xml -i -wrap 85" nil t error-buff))) (defun tidy-xml-buffer () "Use the tidy program (http://tidy.sourceforge.net) to beautify the buffer." (interactive) (tidy-xml-region (point-min) (point-max))) (defun my-desktop-read (filename) "Read the Desktop file and the files it specifies." (interactive "fFilename: ") (let ((desktop-last-buffer nil)) ;; `load-with-code-conversion' calls `eval-buffer' which ;; contains a `save-excursion', so we end up with the same ;; buffer before and after the load. This is a problem ;; when the desktop is read initially when Emacs starts up ;; because, if we still are in *scratch* after running ;; `after-init-hook', the splash screen will be displayed. (load (expand-file-name filename) t t t) (when desktop-last-buffer (switch-to-buffer desktop-last-buffer)) (run-hooks 'desktop-delay-hook) (setq desktop-delay-hook nil) (message "Desktop loaded."))) (defun unix-save () "Save this buffer without DOS line-endings" (interactive) (set-buffer-file-coding-system 'unix nil)) (defun dos-save () "Save this buffer with DOS line-endings" (interactive) (set-buffer-file-coding-system 'dos nil)) (defun indent-buffer () "Indent the current buffer based on its mode" (interactive) (indent-region (point-min) (point-max) nil)) (defun fix-query (start end) "Unescape a RipFire query" (interactive "r") (save-restriction (narrow-to-region start end) (save-excursion (goto-char start) (while (search-forward "<" nil t) (replace-match "<" nil t))) (save-excursion (goto-char start) (while (search-forward ">" nil t) (replace-match ">" nil t))))) (defun perltar () "Take text produced by a perl 'make install' and turn it into a tar command" (interactive) (insert "tar cvf /tmp/perl-modules.tar ") (save-excursion (flush-lines "Files found in")) (save-excursion (flush-lines "Differing version")) (save-excursion (flush-lines "^rm ")) (save-excursion (while (search-forward-regexp "\\(Writing\\)\\|\\(Skipping\\)\\|\\(Installing\\)\\|\\( (unchanged)\\)" nil t) (replace-match "" nil t))) (save-excursion (while (search-forward "\C-j" nil t) (replace-match " " nil t)))) (defun indent-xml (start end) "Turn a one-line XML doc into multi-line" (interactive "r") (save-excursion (goto-char start) (save-restriction (narrow-to-region start end) (save-excursion (while (search-forward-regexp "<[^/]" nil t) (goto-char (match-beginning 0)) (newline-and-indent) (goto-char (match-end 0))))))) (defun indent-sql (start end) "Turn a one-line sql statement into multi-line" (interactive "r") (save-excursion (goto-char start) (save-restriction (narrow-to-region start end) (setq keywords '("insert" "into" "select" "from" "where" "and" "order by")) (while keywords (setq keyword (car keywords)) (setq spaces (make-string (- 8 (length keyword)) 32)) ;; 32 is an ascii space (save-excursion (while (search-forward keyword nil t) (replace-match (concat "\C-j" spaces keyword) nil t))) (setq keywords (cdr keywords))) (font-lock-fontify-region start end)))) (defun grabit (start end) "Grab a region and perform some replacements on it" (interactive "r") (copy-region-as-kill start end) (switch-to-buffer "temp") (erase-buffer) (yank) (goto-char (point-min)) (save-excursion (while (search-forward "\\" nil t) (replace-match "" nil t))) (save-excursion (while (search-forward "pattern" nil t) (replace-match "replacement" nil t))) (save-excursion (while (search-forward "pattern" nil t) (replace-match "replacement" nil t))) (copy-region-as-kill (point-min) (point-max)) (message "Emacs buffer is now loaded in clipboard")) ;; Since Erwin uses "set ts=4" in his .exrc, we'll play along (setq default-tab-width 8) ;; Java Development Environment stuff ;;(add-to-list 'load-path (expand-file-name "/jde/lisp")) ;;(add-to-list 'load-path (expand-file-name "/semantic")) ;;(add-to-list 'load-path (expand-file-name "/speedbar")) ;;(add-to-list 'load-path (expand-file-name "/elib")) ;;(add-to-list 'load-path (expand-file-name "/eieio")) ;;(require 'senator) ;;(require 'jde) ;; start gnuserv (require 'gnuserv) ;; (setenv "GNU_SECURE" "c:/gnu_secure.txt") (gnuserv-start) (setq gnuserv-frame (selected-frame)) (global-set-key '[home] 'beginning-of-buffer) (global-set-key '[end] 'end-of-buffer) (global-set-key "\C-cg" 'goto-line) (global-set-key "\C-cc" 'my-goto-column) (global-set-key "\C-c\C-c" 'compile) (global-set-key "\C-c\C-j" 'my-goto-java-source) (global-set-key "\C-c\C-s" 'my-goto-java-stack-source) ;; tell cperl-mode to treat <% and %> as comment delimiters. This ;; makes ASP PerlScript highlighting reasonable. Thanks, ;; http://www.geocrawler.com/mail/msg.php3?msg_id=3370601&list=182 (setq cperl-mode-hook (lambda nil (modify-syntax-entry ?% ". 14b" cperl-mode-syntax-table) (modify-syntax-entry ?> ". 2b" cperl-mode-syntax-table) (modify-syntax-entry ?< ". 3b" cperl-mode-syntax-table))) (defalias 'perl-mode 'cperl-mode) (add-hook 'sgml-mode-hook (function (lambda () (define-key sgml-mode-map "\C-c\C-b" 'browse-url-of-buffer) (define-key sgml-mode-map "\C-ct" 'tidy-xml-buffer)))) (autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t) (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t) (autoload 'html-mode "xxml" "Major mode to edit HTML files." t) (autoload 'xml-mode "psgml" "Major mode to edit XML files." t) (autoload 'xxml-mode-routine "xxml") (add-hook 'sgml-mode-hook 'xxml-mode-routine) (autoload 'xsl-mode "xslide" "Major mode for XSL stylesheets." t) (add-hook 'ange-ftp-after-parse-ls-hook 'my-ange-ftp-after-parse-ls-hook) ;; NetWare ftp dir lines look like: ;;- [RWCEAFMS] owner 325943 May 07 12:12 NA-EN100057.2002-07-05.11-51a.zip ;; ;; We'll change them to this: ;;-rwxrwxrwx owner 193617 May 07 11:15 NA-EN100076.2002-07-05.10-53a.zip ;; ;; So dired can parse them (defun my-ange-ftp-after-parse-ls-hook () "Make a NetWare ftp directory look a little better" (save-excursion (goto-char (point-min)) (while (search-forward-regexp "^- \\[[A-Z]+\\]" nil t) (replace-match "-rwxrwxrwx" t)))) ;; Turn on font lock when in XSL mode (add-hook 'xsl-mode-hook 'turn-on-font-lock) (add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode)) (add-to-list 'auto-mode-alist '("\\.ctl\\'" . sql-mode)) (add-to-list 'auto-mode-alist '("\\.cfg\\'" . sgml-mode)) (add-to-list 'auto-mode-alist '("\\.xsql\\'" . sgml-mode)) (add-to-list 'auto-mode-alist '("\\.xsl\\'" . xsl-mode)) (add-to-list 'auto-mode-alist '("\\.asp\\'" . cperl-mode)) ;; Use Ghostscript to print (setq ps-lpr-command "c:\\gsv\\gsview\\gsprint.exe") ;(setq ps-lpr-switches '("-query" "-landscape")) (setq ps-lpr-switches '("-query -ghostscript c:\\gs\\gs8.10\\bin\\gswin32.exe")) (setq ps-printer-name t) ;; An indentation base of 3 (c-add-style "my-java-style" '("java" (c-basic-offset . 3))) (defun dupit (dir) "Carbon buffer to the same filename in a different directory" (interactive "DCarbon to directory: ") (setq file (concat dir (file-name-nondirectory(buffer-file-name)))) (message "%s" (concat "Carboning to " file)) (carbon-buffer-to-file file)) ;;import uk.co.datafit.beanstore.bos.base.ISessionEvent; (defun my-goto-java-source () "Goto a java source file based on an import line at point" (interactive) (save-excursion (let ((source (thing-at-point 'filename))) (set-buffer (get-buffer-create "*my-java-temp*")) (erase-buffer) (save-excursion (insert source)) (while (search-forward "." nil t) (replace-match "/" nil t)) (find-file (concat "C:/NG/dev/" (buffer-string) ".java")) (kill-buffer "*my-java-temp*")))) ;; at com.whatever.pos.beanstore.visionCare.EligPlanTreeNode.toString(EligPlanTreeNode.java:116) (defun my-goto-java-stack-source () "Goto a java source file based on the stack trace line at point" (interactive) (let ((oldbuf (current-buffer))) (save-excursion (beginning-of-line) (if (re-search-forward "\\([A-Za-z0-9.]+\\((\\).+:\\([0-9]+\\))\\)" nil t) (let ((source (buffer-substring (match-beginning 1) (match-end 1))) (lineno (buffer-substring (match-beginning 3) (match-end 3))) (parenPos (+ 1 (- (match-beginning 2) (match-beginning 1))))) (set-buffer (get-buffer-create "*my-java-temp*")) (erase-buffer) (save-excursion (insert source)) (save-excursion (while (search-forward "." parenPos t) (replace-match "/" nil t))) (re-search-forward "/[^/]+$" nil t) (replace-match ".java" nil t) (find-file (concat "C:/NG/dev/" (buffer-string))) (kill-buffer "*my-java-temp*") (goto-line (string-to-number lineno))) (error "No java stack trace on current line"))))) ;; Fix the compile command for java mode (add-hook 'java-mode-hook (function (lambda () (define-key java-mode-map "\C-c\C-c" 'compile) (c-set-style "my-java-style") (unless (or (file-exists-p "makefile") (file-exists-p "Makefile")) (make-local-variable 'compile-command) (setq compile-command (concat "sj " (file-name-nondirectory buffer-file-name))))))) (custom-set-variables ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(ange-ftp-dumb-unix-host-regexp "^servername") '(ange-ftp-tmp-name-template "c:/temp/ange-ftp") '(archive-zip-extract (quote ("c:\\ng\\dev\\bin\\unzip.exe" "-qq" "-c"))) '(archive-zip-use-pkzip nil) '(auto-save-interval 3000) '(backup-by-copying t) '(cperl-indent-parens-as-block t) '(desktop-basefilename "emacs.desktop") '(desktop-files-not-to-save "^$") '(enable-local-eval t) '(font-lock-maximum-size nil) '(indent-tabs-mode nil) '(mode-line-inverse-video t) '(perl-indent-level 2) '(xsl-process-browse-output nil) '(xsl-process-find-output t)) (custom-set-faces ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. ) (defun dmapub () "Browse my dmapub homedir." (interactive) (find-file "/bloebaum@dmapub.dma.org:")) (defun home () "Browse my home directory." (interactive) (find-file "/ubloewd@dvc772:bin")) (defun revo () "Browse an FTP depot." (interactive) (find-file "/username@revo:" 1)) (defun my-goto-column (col) "An interactive version of move-to-column." (interactive "nGoto column: ") (move-to-column col)) ;; use aspell instead of ispell (setq-default ispell-program-name "aspell") ;; PSGML stuff (add-to-list 'load-path (expand-file-name "d:/emacs-21.3/site-lisp/psgml-1.2.5")) (setq sgml-validate-command "onsgmls -s %s %s") (setq-default sgml-set-face t) ;; ;; Faces. ;; (make-face 'sgml-comment-face) (make-face 'sgml-doctype-face) (make-face 'sgml-end-tag-face) (make-face 'sgml-entity-face) (make-face 'sgml-ignored-face) (make-face 'sgml-ms-end-face) (make-face 'sgml-ms-start-face) (make-face 'sgml-pi-face) (make-face 'sgml-sgml-face) (make-face 'sgml-short-ref-face) (make-face 'sgml-start-tag-face) (set-face-foreground 'sgml-comment-face "dark turquoise") (set-face-foreground 'sgml-doctype-face "red") (set-face-foreground 'sgml-end-tag-face "blue") (set-face-foreground 'sgml-entity-face "magenta") (set-face-foreground 'sgml-ignored-face "gray40") (set-face-background 'sgml-ignored-face "gray60") (set-face-foreground 'sgml-ms-end-face "green") (set-face-foreground 'sgml-ms-start-face "yellow") (set-face-foreground 'sgml-pi-face "lime green") (set-face-foreground 'sgml-sgml-face "brown") (set-face-foreground 'sgml-short-ref-face "deep sky blue") (set-face-foreground 'sgml-start-tag-face "blue") ; (set-face-foreground 'sgml-comment-face "dark green") ; (set-face-foreground 'sgml-doctype-face "maroon") ; (set-face-foreground 'sgml-end-tag-face "blue2") ; (set-face-foreground 'sgml-entity-face "red2") ; (set-face-foreground 'sgml-ignored-face "maroon") ; (set-face-background 'sgml-ignored-face "gray90") ; (set-face-foreground 'sgml-ms-end-face "maroon") ; (set-face-foreground 'sgml-ms-start-face "maroon") ; (set-face-foreground 'sgml-pi-face "maroon") ; (set-face-foreground 'sgml-sgml-face "maroon") ; (set-face-foreground 'sgml-short-ref-face "goldenrod") ; (set-face-foreground 'sgml-start-tag-face "blue2") (setq-default sgml-markup-faces '((comment . sgml-comment-face) (doctype . sgml-doctype-face) (end-tag . sgml-end-tag-face) (entity . sgml-entity-face) (ignored . sgml-ignored-face) (ms-end . sgml-ms-end-face) (ms-start . sgml-ms-start-face) (pi . sgml-pi-face) (sgml . sgml-sgml-face) (short-ref . sgml-short-ref-face) (start-tag . sgml-start-tag-face))) (desktop-load-default) (setq desktop-locals-to-save (cons 'buffer-carbon-file-names desktop-locals-to-save)) (desktop-read) ;; (require 'session) ;; (add-hook 'after-init-hook 'session-initialize)