; $Id: .emacs,v 1.24 2001/03/18 04:31:50 jzawodn Exp $ ;(setq debug-on-error t) ;; *************************************************************** ;; General display customization ;; *************************************************************** (setq inhibit-startup-message t) ;(require 'paren) ;(show-paren-mode 1) (setq-default transient-mark-mode t) ;; Printing shit (setq ps-font-size 10) ;; *************************************************************** ;; jdz-get-hostname ;; *************************************************************** ; My second lisp function (defun jdz-get-hostname (&optional long-p) "Get the current hostname by calling 'hostname'" (interactive "*P") (let ((jdz-hostname-buffer (generate-new-buffer " get-hostname")) (hostname "unknown")) (unwind-protect (save-excursion (set-buffer jdz-hostname-buffer) (apply 'call-process (list "hostname" nil t nil)) (skip-chars-backward "\n\t ") (setq hostname (buffer-substring (point-min) (point)))) (kill-buffer jdz-hostname-buffer)) (if (interactive-p) (insert hostname)) hostname)) (setq jdz-hostname (jdz-get-hostname)) (message "jdz-hostname is...") (message jdz-hostname) ;; *************************************************************** ;; Grumbe, grumble, grumble... ;; *************************************************************** ;; Translate `C-h' to DEL. (keyboard-translate ?\C-h ?\C-?) ;; Translate DEL to `C-h'. (keyboard-translate ?\C-? ?\C-h) ;; *************************************************************** ;; My frame setup... ;; *************************************************************** (setq default-frame-alist '((cursor-color . "yellow") (cursor-type . box) (foreground-color . "white") (background-color . "black") )) ;(setq initial-frame-alist '((top . 20) (left . 20) (width . 80) (height . 30))) ;; New GNUS (setq load-path (cons (expand-file-name "~/lisp") load-path)) (setq load-path (cons (expand-file-name "~/lisp/gnus") load-path)) ;; *************************************************************** ;; Font Locking Setup ;; *************************************************************** (setq font-lock-face-attributes '((font-lock-emphasized-face "Pink" nil nil nil nil) (font-lock-comment-face "CornflowerBlue" nil nil nil nil) (font-lock-other-emphasized-face "Orchid" nil nil nil nil))) (cond ((fboundp 'global-font-lock-mode) ;; Turn on font-lock in all modes that support it (global-font-lock-mode t) ;; Maximum colors (setq font-lock-maximum-decoration t) )) (setq font-lock-maximum-size 10000000) ;; *************************************************************** ;; News and mail customizations ;; *************************************************************** (setq gnus-select-method '(nntp "news.stcla1.sfba.home.com")) ;(setq smtpmail-default-smtp-server "localhost") ; (message "smtpmail-default-smtp-server is...") ; (message smtpmail-default-smtp-server) ; (if (equal jdz-hostname "peach.z.org") ; (progn ; (message "Using ThirdPlanet.Net setup...") ; (message "Setting news server.") ; (setq gnus-select-method '(nntp "news.thirdplanet.net")) ; (message "Setting mail server.") ; ;(setq smtpmail-default-smtp-server "mail.bright.net") ; (setq smtpmail-default-smtp-server "woodyjr.wcnet.org") ; ;(setq smtpmail-default-smtp-server "mail.thirdplanet.net") ; ;(setq smtpmail-default-smtp-server "woodyjr.wcnet.org") ; ;(setq smtpmail-default-smtp-server "peach.z.org") ; (message "ThirdPlanet.net setup done.")) ; (message "Skipping Bright.Net setup...")) ; (if (equal jdz-hostname "woody.wcnet.org") ; (progn ; (message "Using WCNet setup...") ; (setq gnus-select-method '(nntp "news.wcnet.org")) ; (setq smtpmail-default-smtp-server "mail.wcnet.org") ; (message "WCNet setup done.")) ; (message "Skipping WCNet setup...")) ; (if (equal jdz-hostname "titan.labs.bgsu.edu") ; (progn ; (message "Using BGSU setup...") ; (setq gnus-select-method '(nntp "news.bgsu.edu")) ; (setq smtpmail-default-smtp-server "mail.bgsu.edu") ; (message "BGSU setup done.")) ; (message "Skipping BGSU setup...")) ; (if (equal jdz-hostname "peach.z.org") ; (message "Yes! Right.") ; (message "Nope! Wrong.")) ; (if (equal jdz-hostname "peach.z.orga") ; (message "Nope! Wrong.") ; (message "Yes! Right.")) ; ;(setq gnus-select-method '(nntp "news.bright.net")) ; ;(setq smtpmail-default-smtp-server "mail.bright.net") ; (message "smtpmail-default-smtp-server is...") ; (message smtpmail-default-smtp-server) ; (setq user-full-name "Jeremy D. Zawodny") ; (setq mail-host-address "wcnet.org") ; (setq user-mail-address "jzawodn@wcnet.org") ; ;;(setq user-mail-address "jzawodn@cs.bgsu.edu") ; (setq smtpmail-local-domain nil) ; (setq send-mail-function 'smtpmail-send-it) ; (load-library "smtpmail") ; See ~/.gnus for more info... ;; *************************************************************** ;; Scrolling Setup ;; *************************************************************** (setq scroll-step 4) ;; *************************************************************** ;; Basic Modes and Editing ;; *************************************************************** (setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'turn-on-auto-fill) (add-hook 'mail-mode-hook 'turn-on-auto-fill) (setq auto-mode-alist (cons '("Wishlist" . text-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("mutt-*" . mail-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("cvs*" . text-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.c$" . c-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.cc$" . c-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.h$" . c-mode) auto-mode-alist)) ;; *************************************************************** ;; HTML Helper Mode ;; *************************************************************** (setq html-helper-never-indent t) (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t) (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.shtml$" . html-helper-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.htm$" . html-helper-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.asp$" . html-helper-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.php$" . html-helper-mode) auto-mode-alist)) ;; sh mode for conf files (setq auto-mode-alist (cons '("\\.conf$" . sh-mode) auto-mode-alist)) ;; CSS (autoload 'css-mode "css-mode") (setq auto-mode-alist (cons '("\\.css\\'" . css-mode) auto-mode-alist)) ;; *************************************************************** ;; Tab setup ;; *************************************************************** (setq-default tab-width 8 standard-indent 8 indent-tabs-mode nil) ;; *************************************************************** ;; Ilya's choose-color stuff... ;; *************************************************************** (defvar choose-color-faces-done nil) (if (and (boundp 'emacs-major-version) (> emacs-major-version 19)) (progn (require 'faces) ; May load us... (if choose-color-faces-done nil (fset 'choose-color-internal-set-face-1 (symbol-function 'internal-set-face-1)) (defun internal-set-face-1 (face name value index frame) "Substitute to `internal-set-face-1' from faces.el. Uses `choose-color'." (choose-color-internal-set-face-1 face name (choose-color value) index frame)) (setq choose-color-faces-done t)))) (autoload 'choose-color "choose-color" "Choose color wisely.") ;; *************************************************************** ;; CPerl-Mode ;; *************************************************************** (autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t) (setq cperl-hairy t) (setq cperl-indent-level 4) (setq auto-mode-alist (append '(("\\.\\([pP][Llm]\\|al\\)$" . perl-mode)) auto-mode-alist )) (setq auto-mode-alist (append '(("\\.\\([pP][oO]\\|[dD]\\)$" . perl-mode)) auto-mode-alist )) (setq interpreter-mode-alist (append interpreter-mode-alist '(("miniperl" . perl-mode)))) ;; *************************************************************** ;; Quip Mode ;; *************************************************************** ; My frist major mode... ;(setq auto-mode-alist (cons '("\\.quotes$" . quip-mode) auto-mode-alist)) ;(load-library "quip") ;; *************************************************************** ;; Finances (Checking) ;; *************************************************************** ; My second major mode... ;(setq auto-mode-alist (cons '("checking\\.txt$" . checking-mode) auto-mode-alist)) ;(load-library "checking") ;; *************************************************************** ;; jdz-get-year-and-month ;; *************************************************************** ; My first lisp function (defun jdz-get-year-and-month (&optional long-p) "Get the current year and month and year (YYYY-MM)" (interactive "*P") (let ((jdz-gyam-buffer (generate-new-buffer " get-year-and-month")) (date-string "unknown")) (unwind-protect (save-excursion (set-buffer jdz-gyam-buffer) (apply 'call-process (append (list "/bin/date" nil t nil) (list "+%Y-%m"))) (skip-chars-backward "\n\t ") (setq date-string (buffer-substring (point-min) (point)))) (kill-buffer jdz-gyam-buffer)) (if (interactive-p) (insert date-string)) date-string)) (defun jdz-cvs-up () "The current file will be cvs updated" (interactive) (shell-command (concat "cvs update " (file-name-nondirectory (buffer-file-name))))) (defun jdz-cvs-log () "The current file will be cvs logged" (interactive) (shell-command (concat "cvs log " (file-name-nondirectory (buffer-file-name))))) (defun jdz-cvs-commit () "The current file will be cvs commited" (interactive) (shell-command (concat "cvs update " (file-name-nondirectory (buffer-file-name))))) (defun jdz-cvs-status () "The current file will be cvs status'd" (interactive) (shell-command (concat "cvs status " (file-name-nondirectory (buffer-file-name))))) (defun jdz-cvs-diff () "The current file will be cvs diff'd" (interactive) (shell-command (concat "cvs diff " (file-name-nondirectory (buffer-file-name))))) (defun jdz-perl-cw () "The current file will be perl -cw'd" (interactive) (shell-command (concat "perl -cw " (file-name-nondirectory (buffer-file-name))))) ;; *************************************************************** ;; Word Count ;; *************************************************************** (defun wc () "Count the words in the current buffer, show the result in the minibuffer" (interactive) ; *** This is the line that you need to add (save-excursion (save-restriction (widen) (goto-char (point-min)) (let ((count 0)) (while (forward-word 1) (setq count(1+ count))) (message "There are %d words in the buffer" count))))) ;; *************************************************************** ;; Functions for FrontPage HTML cleanup... ;; *************************************************************** (defun jdz-test () "Spit out testing message..." (interactive) (message "Testing")) (defun jdz-fp-font-remove () "Remove annoying FrontPage font tags from current buffer." (interactive) (message "Starting search and replacement...") (save-excursion (goto-char (point-min)) (while (re-search-forward "]*>" nil t) (replace-match "" nil nil))) (save-excursion (goto-char (point-min)) (while (re-search-forward "" nil t) (replace-match "" nil nil))) (message "Search and replacement done.")) (global-set-key "\C-cg" 'jdz-fp-font-remove) ;; *************************************************************** ;; Misc useful functions ;; *************************************************************** (defun jdz-to-first-non-space () "Move point to first non-blank character on the current line. Sort of like 'w' does in vi." (interactive) (beginning-of-line 1) (skip-chars-forward " \t")) (global-set-key "\C-cw" 'jdz-to-first-non-space) ;;(global-set-key "\C-A" 'jdz-to-first-non-space) (defun jdz-buffer-switch () "Switches buffers." (interactive) (switch-to-buffer (other-buffer))) (global-set-key "\C-q" 'jdz-buffer-switch) (defun jdz-frame-switch () "Switches buffers." (interactive) (other-frame 1)) (global-set-key "\C-Q" 'jdz-frame-switch) ;; Lang stuff (set-language-environment "Latin-1") (setq c-indent-level 4) ;; *************************************************************** ;; Linux Hacking ;; *************************************************************** (defun linux-c-mode () "C mode with adjusted defaults for use with the Linux kernel." (interactive) (c-mode) (setq c-indent-level 8) (setq c-brace-imaginary-offset 0) (setq c-brace-offset -8) (setq c-argdecl-indent 8) (setq c-label-offset -8) (setq c-continued-statement-offset 8) (setq indent-tabs-mode nil) (setq tab-width 8)) ; Remember the -*- linux-c -*- bit, too. ;(setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode))) ;; Upload Stuff (defun jdz-wcftp () "PCP file referred to by the current buffer." (interactive) (shell-command (concat "wcftp -p " buffer-file-name))) ;; *************************************************************** ;; Misc Key Mappings ;; *************************************************************** (global-set-key [f1] 'search-forward) (global-set-key [f4] 'goto-line) (global-set-key [f5] 'replace-string) (global-set-key [f6] 'jdz-perl-cw) (global-set-key [f8] 'compile) (global-set-key [f9] 'jdz-wcftp) (global-set-key "\C-j" 'backward-char) (global-set-key "\C-cf" 'font-lock-mode) (global-set-key "\C-ca" 'auto-fill-mode) (global-set-key "\C-cc" 'jdz-cvs-commit) (global-set-key "\C-cd" 'jdz-cvs-diff) (global-set-key "\C-cl" 'jdz-cvs-log) (global-set-key "\C-cs" 'jdz-cvs-status) (global-set-key "\C-cu" 'jdz-cvs-up) ;(global-set-key "\C-s" 'isearch-forward) ;(global-set-key (kbd "RET") 'newline-and-indent) ;; *************************************************************** ;; SQL Stuff ;; *************************************************************** (setq load-path (cons (expand-file-name "~/lisp/sql") load-path)) (autoload 'sql "sql-mode" "Start the interactive SQL interpreter in a new buffer." t) (autoload 'sql-mode "sql-mode" "Mode for editing SQL files and running a SQL interpetror." t) (autoload 'sql-buffer "sql-mode" "Create or move to the sql-mode \"*SQL commands*\" buffer." t) (setq auto-mode-alist (cons '("\\.sql$" . sql-mode) auto-mode-alist)) ;; *************************************************************** ;; Experimental for GNUS signature. ;; *************************************************************** (defun uptime-signature () "Foo" (insert "\n-- \n" (shell-command-to-string "cat $HOME/.signature") (shell-command-to-string "uptime"))) (setq gnus-posting-styles '((".*" (signature uptime-signature)))) ;; *************************************************************** ;; Get Passive FTP connections ;; *************************************************************** (defun ange-ftp-set-passive () "can be run only when proc is dynamicly linked (in ange ftp startup)." (ange-ftp-raw-send-cmd proc "passive")) (add-hook 'ange-ftp-process-startup-hook 'ange-ftp-set-passive) (custom-set-variables) (custom-set-faces) ;; *************************************************************** ;; Remoting... ;; *************************************************************** ;(server-start) (menu-bar-mode 'nil) (c-set-style "ellemtel")