;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; MITCH's FUNCTIONS 1/98 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; keyboard template for keybindings ; set-mark-command ; copy-region-as-kill ; clipboard-yank ; ^C-p to print a file (fset 'lookForP [?\C-s ?^P left right]) (put 'eval-expression 'disabled nil) (global-set-key "\C-x\C-c" nil) ;; comment out the easy exit ;(setq view-diary-entries-initially t) ;(calendar) ;(setq mark-diary-entries-in-calendar t) ;(setq appt-message-warning-time 30) (setq exec-path (cons (expand-file-name "~/bin") exec-path)) (setq exec-path (cons (expand-file-name "C:/ispell4.0/exe") exec-path)) ;(setq exec-path (cons (expand-file-name "C:/Progra~1/Netscape/Communicator/Program") exec-path)) (setq load-path (cons (expand-file-name "~/emacs") load-path)) (setq load-path (cons (expand-file-name "~/emacs/vm") load-path)) (setq load-path (cons (expand-file-name "~/emacs/elib") load-path)) (load "SaveBuffers") (load "ange-ftp") (load "addr-mode") (load "simple-html-mode") (load "ispell4") (load "local") (load "mymenus") (setq visible-bell t) (autoload 'ispell "ispell" "Run ispell over buffer" t) (autoload 'ispell-region "ispell" "Run ispell over region" t) (autoload 'ispell-word "ispell" "Check word under cursor" t) (add-hook 'mail-setup-hook 'mail-abbrevs-setup) (add-hook 'mail-setup-hook 'my-setup-mailabbrev) (defun my-setup-mailabbrev () (substitute-key-definition 'next-line 'mail-abbrev-next-line mail-mode-map global-map) (substitute-key-definition 'end-of-buffer 'mail-abbrev-end-of-buffer mail-mode-map global-map)) (setq ange-ftp-tmp-name-template (concat (expand-file-name (getenv "TEMP")) "/ange-ftp")) (setq ange-ftp-gateway-tmp-name-template (concat (expand-file-name (getenv "TEMP")) "/ange-ftp")) (setq ange-ftp-ftp-program-name "c:/fincher/bin/ftp.exe") ;(require 'easymenu) ;(easy-menu-define ; sgml-dtd-menu global-map "DTD menu" ; '("DTD") ; ["Next trouble spot" bubble-line-up t] ; ["Next data field" bubble-line-up t] ;) ;; ===================== The Mouse Key Family ===================== (global-set-key [S-down-mouse-1] 'kill-a-line ) (global-set-key [C-down-mouse-1] 'killaword) (global-set-key [S-down-mouse-3] 'bubble-line-up) (global-set-key [mouse-2] 'undo) (global-set-key [mouse-3] 'mouse-yank-at-click) (define-key global-map [C-S-down-mouse-3] 'line-to-top) (require 'paren) ;; ===================== The Right Keypad Family ===================== (global-set-key [insert] 'switch-to-other-buffer) ; Insert ;(global-set-key [f21] 'delete-char) ;; ===================== The F Key Family ===================== (global-set-key [f1] 'goto-line) ;; DONT RESET F2 ON NT ;(global-set-key [f2] 'menu-bar-kill-ring-save) ;(global-set-key [C-f2] '(lambda () (interactive)(insert "\n"))) ; C-F2 (global-set-key [f3] 'query-replace) (global-set-key [(shift f3)] 'query-replace-regexp) (global-set-key [f4] 'eval-region) (global-set-key [f5] 'start-kbd-macro) (global-set-key [f6] 'end-kbd-macro) (global-set-key [f7] 'call-last-kbd-macro) (global-set-key [(shift f7)] 'bookmark-jump) (global-set-key [f8] 'copy-region-as-kill) (global-set-key [f9] 'clipboard-yank) (global-set-key [f10] 'query-replace-regexp) (global-set-key [(shift f5)] 'bookmark-set) (global-set-key [f12] '(lambda () (interactive) (font-lock-fontify-buffer))) (global-set-key [(shift f12)] 'my-c++-indent-defun) (define-key global-map [f13] '(lambda () (interactive) (save-some-buffers t))) ;; ===================== The Meta (Esc) Key Family ===================== (define-key esc-map "$" 'ispell-word) (define-key global-map "\M-e" '(lambda () (interactive) (find-file "~/.emacs"))) (define-key global-map "\M-1" 'delete-other-windows) ; (define-key global-map "\M-2" 'split-window-vertically); (define-key global-map "\M-3" 'switch-to-third-buffer); (define-key global-map "\M-4" 'ispell-buffer); (define-key global-map "\M-5" 'split-window-horizontally); (define-key global-map "\M-8" 'showall); (define-key global-map "\M-a" '(lambda () (interactive) (find-file "~/.pers/addr"))) (define-key global-map "\M-b" 'bury-buffer) ; (define-key global-map "\M-d" 'insert-date-stamp) ; (define-key global-map "\M-e" '(lambda () (interactive) (find-file "~/.emacs"))) (define-key global-map "\M-f" 'find-file) ; (define-key global-map "\M-g" 'goto-line) ; (define-key global-map "\M-h" '(lambda () (interactive) (find-file "~/.pers/house"))) (define-key global-map "\M-i" 'insert-file) ; (define-key global-map "\M-j" 'jump-back) (define-key global-map "\M-k" 'kill-buffer-now) ; (define-key global-map "\M-l" 'editlog) (define-key global-map "\M-\C-l" 'editweeklylog) (define-key global-map "\M-\C-p" 'insert-println2) (define-key global-map "\M-n" '(lambda () (interactive) (find-file "/mfincher@fincher.org:/home/mfincher/public_html/news/news01998d.shtml"))) (define-key global-map "\M-m" '(lambda () (interactive) (find-file "~/emacs/mymenus.el"))) (define-key global-map "\M-p" 'insert-println) (define-key global-map "\M-r" 'revert-buffer-now) ; (define-key global-map "\M-s" 'shell) ; (define-key global-map "\M-t" 'insert-time-stamp) ; (define-key global-map "\M-u" 'undo) ; ;; ===================== The Ctl Key Family ===================== (define-key global-map "\C-q" 'reload-emacs-file) ; (define-key global-map "\C-w" 'insert-quote-heading) ; (define-key global-map "\C-R" 'replace-string) ; (define-key global-map "\C-R" 'replace-string) ; (define-key global-map "\C-n" 'next-line) ; (define-key global-map "\C-_" 'search-forward) ; really the ^/ (define-key global-map "\C-^" 'enlarge-window2) ; (define-key global-map "\C-xi" 'insert-buffer) (define-key global-map "\C-k" 'kill-a-line) ;; ===================== The Left Keypad Family ===================== ;//////////////////////////Quickies////////////////////////////////// (defun switch-to-other-buffer()(interactive)(switch-to-buffer nil) ) (defun move-to-tempmai() (interactive) (vm-mv-and-delete "~/.maildir/temp.mai")) (defun move-to-ftmai() (interactive) (vm-mv-and-delete "~/.maildir/ft.mai")) (defun insert-other-buffer-name ()(interactive) (insert (buffer-name(other-buffer)))) (defun insert-buffer-name ()(interactive) (insert (buffer-name))) (defun insert-println () (interactive) (insert "System.out.println(\": \" + );\n")(forward-char -9)) (defun insert-println2 () (interactive) (insert "System.out.println(\": \" + );System.out.flush();\n")(forward-char -28)) (defun myfind-tag () (interactive) (find-tag (find-tag-default))(recenter 0)) (defun myfind-itag () (interactive) (tags-loop-continue)(recenter 0)) (defun editlog () (interactive) (find-file "~/log/log.html") ) (defun editweeklylog () (interactive) (find-file "~/log/980621.stm") ) ;(defun switch-to-3buffer () (interactive) (switch-to-other-buffer 2) ) (defun editemacs () (interactive) (find-file "~/.emacs") ) (defun kill-buffer-now () (interactive) (kill-buffer nil) ) (defun editaddr () (interactive) (find-file "~/.pers/addr") ) (defun reload-emacs-file () (interactive) (save-buffer)(load-file "~/.emacs") ) (defun kill-a-line () (interactive) "2 kills-lines" (beginning-of-line)(kill-line 1)) ;//////////////////////////////////////////////////////////// ;; Add the Last Updated: timestamp. ; Last Updated: June 14, 2003. (add-hook 'local-write-file-hooks 'update-writestamps) (defvar writestamp-date-format " %B %e, %Y" "*Format for displaying time") (defun update-writestamps () "Finds the string \"Last Updated: (date).\" and replace them with the current time. The string must be the first nonwhitespace on the line and the period must be the last character on the line. Written by Bob Glickstein." (interactive "*") (save-excursion ;;will restore original cursor location (save-restriction ;; will restore (narrow) boundaries (save-match-data ;; will restore item in search string (widen)(goto-char (point-min)) (while (re-search-forward "^[ ;\t]*Last Updated:\\(.*\\)\\." nil t) (replace-match (format-time-string writestamp-date-format (current-time)) t t nil 1 ))))) nil) (setq bell-volume 0) ;; turn off that annoying bell (add-hook 'simple-html-mode-hook 'auto-fill-mode) (add-hook 'simple-html-mode-hook 'syntax-table-stuff) ;(add-hook 'c++-mode-hook '(setq wrap-long-lines nil)) (defun syntax-table-stuff () (interactive) (modify-syntax-entry 31 "w") (modify-syntax-entry 45 "w") ) (defun toggle-picture-mode () (interactive) (if (eq major-mode 'edit-picture) (picture-mode-exit) (picture-mode))) (defun taber () (interactive) (search-forward-regexp " [0-2]") (backward-char 1) (message (format " current column is %d " (current-column) )) (if (< (current-column) 18) (insert " ")) ) (defun display-file-info() "trival function to show find-file-hooks functionality" (message (concat "the filename is " buffer-file-name " and it is " (if buffer-read-only "read only." "writable"))) ) (add-hook 'find-file-hooks 'display-file-info) (defun vm-mode-hook () (define-key vm-mode-map 'd '(lambda () (interactive) (vm-delete-message 1) (vm-Next-message)(vm-scroll-forward)))) ;; =================== functions ============================= (defun startmail () (interactive) (vm-visit-folder "~/.maildir/inbox")) (defun gs () "gets mail from ~/maildir/l." (interactive) (erase-buffer) (insert-file "~/.maildir/l") ) (defun gs2 () "gets mail from ~/maildir/l2" (interactive) (erase-buffer) (insert-file "~/.maildir/l2") ) (defun line-to-top() "Puts the current line at the top of the window" (interactive) (recenter 0)) (defun kill-to-end () "Kills text from point to end of buffer." (interactive) (kill-region (point) (point-max))) (defun kill-to-beginning () "Kills text from point to beginning of buffer." (interactive) (kill-region (point) (point-min))) (defun convert-html-angles () " replaces all < and > to < and > in the region" (interactive "*") (narrow-to-region (point) (mark)) (goto-char (point-min)) (replace-string "<" "<") (goto-char (point-min)) (replace-string ">" ">") (widen) ) (defun delete-leading-whitespace () (interactive) (narrow-to-region (point) (mark)) (goto-char (point-min)) (replace-regexp "^[\t ]*" "") (widen) ) (defun unify-region (top bottom &optional macro) "removes all carriage returns in region" (interactive "r") (save-excursion (let ((end-marker (progn (goto-char bottom) (beginning-of-line) (point-marker))) next-line-marker) (goto-char top) (if (not (bolp)) (forward-line 1)) (setq next-line-marker (point-marker)) (while (< next-line-marker end-marker) (goto-char next-line-marker) (save-excursion (forward-line 1) (set-marker next-line-marker (point))) (save-excursion ;; command goes here (end-of-line)(delete-char 1) )) (set-marker end-marker nil) (set-marker next-line-marker nil)) ) ) (defun comment-region (top bottom &optional macro) "comments the hightlighted region by prefacing lines with correct characters" (interactive "r") (save-excursion (let ((end-marker (progn (goto-char bottom) (beginning-of-line) (point-marker))) next-line-marker) (goto-char top) (if (not (bolp)) (forward-line 1)) (setq next-line-marker (point-marker)) (while (< next-line-marker end-marker) (goto-char next-line-marker) (save-excursion (forward-line 1) (set-marker next-line-marker (point))) (save-excursion ;; command goes here (beginning-of-line)(insert comment-start) )) (set-marker end-marker nil) (set-marker next-line-marker nil)) ) ) (defun indent-according-to-mode-region (top bottom &optional macro) "name says it all" (interactive "r") (message "indenting marked region...") (save-excursion (let ((end-marker (progn (goto-char bottom) (beginning-of-line) (point-marker))) next-line-marker) (goto-char top) (if (not (bolp)) (forward-line 1)) (setq next-line-marker (point-marker)) (while (< next-line-marker end-marker) (goto-char next-line-marker) (save-excursion (forward-line 1) (set-marker next-line-marker (point))) (save-excursion ;; command goes here (indent-according-to-mode) )) (set-marker end-marker nil) (set-marker next-line-marker nil)) ) (message "indenting marked region...done") ) (defun switch-to-third-buffer () (interactive) ;; needs to be fixed (switch-to-other-buffer) ) (defun vm-mv-and-delete ( dir ) (interactive "r" ) (vm-save-message dir ) (vm-delete-message 1) (vm-next-message) ) (defun my-c++-mode-hook () (interactive) (define-key c++-mode-map "\C-c;" 'comment-c-region) (my-set-colors) ) (defun my-set-colors () (interactive) "sets colors and fonts for font-locking" ; (let ;;((Default-Font (face-font (get-face 'default)))) (setq-default font-lock-auto-fontify t) (setq-default font-lock-use-fonts t) (setq-default font-lock-use-colors t) (setq-default font-lock-use-maximal-decoration t) (setq-default font-lock-mode-enable-list t) (setq-default font-lock-mode-disable-list nil) (require 'font-lock) (require 'fast-lock) ; (set-face-background 'font-lock-comment-face "White") ; (set-face-background 'font-lock-doc-string-face "White") ; (set-face-background 'font-lock-function-name-face "Yellow") ; (set-face-background 'font-lock-keyword-face "White") ; (set-face-background 'font-lock-string-face "White") ; (set-face-background 'font-lock-type-face "White") (set-face-foreground 'font-lock-comment-face "Red") (set-face-foreground 'font-lock-function-name-face "Blue") (set-face-foreground 'font-lock-keyword-face "Gold") (set-face-foreground 'font-lock-reference-face "Sienna") (set-face-foreground 'font-lock-string-face "SeaGreen") (set-face-foreground 'font-lock-type-face "Coral") (set-face-foreground font-lock-variable-name-face "DarkGoldenrod") (set-face-underline-p 'font-lock-string-face nil) ; ) ) (global-font-lock-mode t) (setq font-lock-maximum-decoration t) (add-hook 'java-mode-hook 'turn-on-font-lock) (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))) ;//////////////////////////////////////////////////////////// (defun trim () ;//////////////////////////////////////////////////////////// "Delete trailing whitespace everywhere after point" ;Tim Peters Kendall Square Research Corp ;tim@ksr.com, ksr!tim@uunet.uu.net (interactive) (replace-regexp "[ \t]+$" "") ) ;//////////////////////////////////////////////////////////// (defun insert-numbers (arg) ;//////////////////////////////////////////////////////////// "insert number into a file, starting with 1 -mdf" (interactive "NHow many numbers to insert: ") (setq i 0) (while (< i arg) (setq i (1+ i)) (insert (int-to-string i)) (backward-char 1) (next-line 2) (beginning-of-line 0) ) ) ;//////////////////////////////////////////////////////////// (defun my-c++-indent-defun () ;//////////////////////////////////////////////////////////// "puts message in message line when we start and finish" (interactive) (message "starting to reformat function...") (c++-indent-defun) (message "finished.") ) ;//////////////////////////////////////////////////////////// (defun x-mouse-cut-word () ;//////////////////////////////////////////////////////////// "copies the current word into the xbuffer and kill ring - by mitch fincher" (interactive) (set-mark (point)) (setq p0 (point)) (forward-word 1) (setq p1 (point)) (goto-char p0) (x-own-clipboard (buffer-substring p0 p1)) (message "pssst... current word copied to buffer.") (sit-for 1) ) ;//////////////////////////////////////////////////////////// (defun my-call-process (program infile &rest program-args) ;//////////////////////////////////////////////////////////// "See `call-process' documentation for meaning of `infile' argument." (let* ((b (generate-new-buffer " my-call-process")) (exit-code (apply 'call-process program infile b nil program-args)) (output-string (save-excursion (set-buffer b) (buffer-string)))) (kill-buffer b) (or (equal exit-code 0) (error "Running %S on %S lost: %S" program program-args exit-code)) (setq oldfilename output-string) ;; strip out ending character (setq filenamelength (length oldfilename)) (setq newfilename (substring oldfilename 0 (- filenamelength 1))) newfilename) ) ;//////////////////////////////////////////////////////////// (defun search-for-word() ;//////////////////////////////////////////////////////////// ;; by mitch fincher "searches for next occurance of the word at the point" (interactive ) (setq p0 (point)) (forward-word 1) (setq p1 (point)) (setq looking-for (buffer-substring p0 p1)) (setq status (search-forward looking-for nil t)) (backward-char (length looking-for)) (if status (progn (message (format " searching for \"%s\" " looking-for)) ) (progn (message " search failed for \"%s\" , wrapping to beginning." looking-for) (beep) (goto-char 0) (search-forward looking-for) (backward-char (length looking-for)) )) ) ;//////////////////////////////////////////////////////////// (defun jump-back () ;//////////////////////////////////////////////////////////// ;; by mitch fincher." "Returns to cursors previous position" (interactive "*" ) (pop-mark) (goto-char (mark t)) ) ;//////////////////////////////////////////////////////////// (defun insert-heading-info() ;//////////////////////////////////////////////////////////// "inserts the file name and date at the top of a file." (interactive) (insert " " ) (insert-date-stamp) (insert " " buffer-file-name) (insert "\n\n") ) ;//////////////////////////////////////////////////////////// (defun insert-quote-heading() ;//////////////////////////////////////////////////////////// "inserts the quote headers." (interactive) (insert "\n\n\n\n\n\n\n" ) (forward-line -6 ) (insert "\".\"")(forward-char -2) ) ;//////////////////////////////////////////////////////////// (defun delete-char-then-down() ;//////////////////////////////////////////////////////////// "inserts an fprintf statement around text." (interactive) (delete-char 1) (fkey-next-line 1) ) ;//////////////////////////////////////////////////////////// (defun insert-file-name() ;//////////////////////////////////////////////////////////// "inserts the file name and date at the top of a file." (interactive) (insert buffer-file-name) ) ;//////////////////////////////////////////////////////////// (defun bubble-line-up(click) ;//////////////////////////////////////////////////////////// ;; by mitch fincher (interactive "@e") (beginning-of-line)(transpose-lines 1) (previous-line 2)) ;//////////////////////////////////////////////////////////// (defun backup-file () ;//////////////////////////////////////////////////////////// "Insert current date at current position." (interactive) (message (concat "starting to backupfile " (buffer-file-name) " ...") ) ;(call-process (concat "java backupfile " (buffer-file-name) ) nil t) ;(call-process "c:/SDK-Java.20/Bin/jview" nil t nil "c:\fincher\java\backupfile" "c:\fincher\.emacs") (call-process "c:/unix/32-bit/utils/date.EXE" nil t nil ) (message (concat "starting to backupfile " (buffer-file-name) " ...done.") ) ) ;//////////////////////////////////////////////////////////// (defun insert-date-stamp () ;//////////////////////////////////////////////////////////// "Insert current date at current position." (interactive "*") (message "starting to date stamp the line...") (beginning-of-line) (insert "\n") (insert (format-time-string "<%D %a>" (current-time))) (insert "\n\ntimetool:\n\n") (forward-char -1) (message "starting to date stamp the line - finished.") ) ; ;//////////////////////////////////////////////////////////// (defun insert-date-stamp-minimal () ;//////////////////////////////////////////////////////////// "Insert current date at current position." (interactive) (call-process "/home/fincher/util/mydate" nil t) ) ; ;//////////////////////////////////////////////////////////// (defun insert-time-stamp () ;//////////////////////////////////////////////////////////// "Insert current time at current position." (interactive) (message "starting to time stamp the line...") (call-process "c:/unix/32-bit/utils/date.EXE" nil t nil "+\"(timestamp:%H hrs:%M min:%S secs)\"" ) (message "starting to time stamp the line - finished.") ) ; ;//////////////////////////////////////////////////////////// (defun insert-catch () ;//////////////////////////////////////////////////////////// "inserts java code for a standard catch clause" (interactive "*") (setq start1 (- (point) 1)) (beginning-of-line) (insert " catch(Exception ex)\n{ \nIQUtil.catchException(ex,\"Error:\" + ex);\n}\n") (setq end1 (point)) (indent-according-to-mode-region start1 end1) ) ;//////////////////////////////////////////////////////////// (defun my-indent-defun () ;//////////////////////////////////////////////////////////// "calls system indent-rigidly with correct args" (interactive "*") (message "starting to indent region..." ) (sit-for 1) (indent-rigidly (mark) (point) 3) (message "starting to indent region...done") ) ;//////////////////////////////////////////////////////////// (defun save-buffer-and-collect() ;//////////////////////////////////////////////////////////// ;; by mitch fincher (ok, so its a little kludgy) "the name says it all" (interactive) (save-buffer) ;(garbage-collect) ;;(store-savbufs) ) ;//////////////////////////////////////////////////////////// (defun align-column (nth) ;//////////////////////////////////////////////////////////// "deletes all blanks infront of cursor and then moves down 1 line. -mdf" (interactive "p") (while (looking-at " ") (delete-char 1)) (fkey-next-line 1) ) ;//////////////////////////////////////////////////////////// (defun scroll-to-end (nth) ;//////////////////////////////////////////////////////////// "Like end-of-buffer, but makes sure that the last non-blank line is displayed on the last line of the window. Leaves point at the bottom of the window. Sets mark to point's previous location \(just like end-of-buffer does). With a numeric arg scroll to the NTH from last line. \(Negative args do the right thing)" (interactive "p") ;(set-mark (point)) (goto-char (1- (point-max))) ;; Walk backwards until we find non-whitespace (while (looking-at "\n\\|\\s ") (forward-char -1)) ;; I know it's ugly, but it works. (if (> nth 1) (progn (vertical-motion (- 2 nth)) (backward-char 2) (setq nth 1) )) ;; Now starting from point, count up the right number of screen lines. (let ((last-pos (1+ (point)))) ;; Step up the appropriate number of lines (taking into account ;; continuation lines). (vertical-motion (- 3 (window-height) nth)) ;; Wherever we landed should be the first char displayed in the window. (set-window-start (selected-window) (point)) (goto-char last-pos) ) ;(message "going to point max") (sit-for 1) (goto-char (1- (point-max))) ) ;//////////////////////////////////////////////////////////// (defun killaword(click) ;//////////////////////////////////////////////////////////// ;; by mitch fincher (interactive "@e") (message "kill-word") (sit-for 1) (kill-word 1) ) ;//////////////////////////////////////////////////////////// (defun scroll-updown (event) ;//////////////////////////////////////////////////////////// "This allows the user to scroll up and down with the mouse in test area. This should be bound to a mouse click event type. by Mitch Fincher, Dec 93" (interactive "e") (let ( ;(goto-char (posn-point (event-start event))) (p1 (posn-point (event-start event) )) (p2 (posn-point (event-end event) )) ) (if (> p1 p2) (scroll-up (count-lines p1 p2 )) (scroll-down (count-lines p1 p2 )) ) ) ) ;//////////////////////////////////////////////////////////// (defun scroll-updown-old (click) ;//////////////////////////////////////////////////////////// "This allows the user to scroll up and down with the mouse in test area. This should be bound to a mouse click event type. by Mitch Fincher, Dec 93" (interactive "e") (let ( ;(goto-char (posn-point (event-start event))) (p1 (posn-point (event-start click) )) (p2 (posn-point (event-end click) )) ) (if (> p1 p2) (scroll-up (count-lines p1 p2 )) (scroll-down (count-lines p1 p2 )) ) ) ) ;; start landmark stuff ------------------- (defun rerun-hook (arg) "Force a given hook to be run" (interactive "SRun hook: ") (run-hooks arg) ) (message "Loading .emacs -- flavor is %s" emacs-version) ;(setq lpr-switches (list (format "-P%s" (getenv "PRINTER")))) (defun me-look-at (s) (interactive "sRegexp:") (print (buffer-substring (point) (point-max))) (if (looking-at s) (progn (print (concat s " Matched.")) t) (progn (print (concat s " Not Matched.")) nil ))) (defun reload () (interactive) (load-file (buffer-file-name))) (setq quick-redisplay 1) ;(setq auto-save-interval 500) (setq auto-save-default nil) (setq wrap-long-lines nil) (setq backup-before-writing 1) (setq backup-by-copying-when-linked 1) (setq completion-auto-help t) (setq inhibit-startup-message t) (setq require-final-newline nil) ;;(setq comment-start ";;") ;;; In Fundamental mode, auto fill as well. ;; (setq fundamental-mode-hook '(lambda (&rest args) (auto-fill-mode -1) (setq fill-column 65))) (setq text-mode-hook '(lambda (&rest args) (auto-fill-mode -1) (setq fill-column 70))) (setq default-major-mode 'text-mode) (put 'set-fill-column 'disabled nil) ;(defvar time-to-throw-away 2) (defun mark-long-comment () (interactive) (let ((at (point))) (beginning-of-line) (while(and (not (eobp)) (or (looking-at comment-start) ;(looking-at "[ ]*\n") )) (forward-line 1)) (set-mark (point)) (goto-char at) (while(and (not (bobp)) (or (looking-at comment-start) ;(looking-at "[ ]*\n") )) (forward-line -1)) (or (bobp )(forward-line 1)))) (defun fill-long-comment () (interactive) (mark-long-comment) (let ((beg (min (dot) (mark))) (end (max (dot) (mark))) (n 0)m) (narrow-to-region beg end) (goto-char (point-min)) (while (looking-at ";") (forward-char 1)) (setq n (- (point) beg)) (goto-char (point-min)) (while (not (eobp)) (setq m n) (while (> m 0) (cond ((looking-at ";") (delete-char 1) (cond ((looking-at " ")(delete-char 1)(setq m 0))) (setq m (- m 1))) (t (setq m 0)))) (forward-line 1)) (fill-region (dot-min) (dot-max)) (goto-char (point-min)) (while (not (eobp)) (cond ((looking-at "\n") nil) (t(insert ";;; "))) (forward-line 1)) (goto-char (point-min)) (set-mark (point-max)) (widen))) (put 'eval-expression 'disabled nil) ;(setq c-indent-level 2) ; default is 2 ;(setq c-argdecl-indent 5) ;(setq c-label-offset -4) (put 'backward-page 'disabled t) (put 'forward-page 'disabled t) (put 'mark-page 'disabled t) (put 'minibuffer-completion-help 'disabled t) (setq auto-mode-alist '(("\\.text$" . indented-text-mode) ("\\.c$" . c-mode) ("\\.h$" . c-mode) ("\\.y$" . c-mode) ("\\.cpp$" . c++-mode) ("\\.C$" . c++-mode) ("\\.hxx$" . c++-mode) ("\\.cc$" . c++-mode) ("\\.l$" . c-mode) ("\\.el$" . emacs-lisp-mode) ("\\.emacs$" . emacs-lisp-mode) ("\\.lisp$" . emacs-lisp-mode) ("\\.letter$" . mail-mode) ;("[]>:/]\\..*ema" . emacs-lisp-mode) ("\\.java$" . java-mode) ("\\.mocha$" . java-mode) ("\\.js$" . java-mode) ("\\.cfm$" . simple-html-mode) ("\\.shtml$" . simple-html-mode) ("\\.html$" . simple-html-mode) ("\\.stm$" . simple-html-mode) ("\\.htm$" . simple-html-mode) ("\\.tk$" . tcl-mode) ("addr$" . addr-mode) ("[Mm]akefile$" . makefile-mode) ("\\.mak$" . makefile-mode) ("\\.mk$" . makefile-mode) ("\\.pl$" . perl-mode) ("\\.cgi$" . perl-mode) ("\\.tcl$" . tcl-mode) ("\\.ged$" . gedcom-mode) )) (setq truncate-partial-width-windows nil) (setq truncate-lines nil) (defun switch-to-existing-buffer (bufname) (interactive "BSwitch to buffer: ") (let ((b (get-buffer bufname))) (if b (switch-to-buffer bufname) (error "Buffer %s does not exist." bufname)))) ;(setq enscript-switches (list (getenv "ENSCRIPT"))) (setq enscript-switches (list "-2Gr")) (setq lpr-command "print") (autoload 'shell "shell" "" t nil) ;; This should allow me to print the buffer, but it is not working. ;; check out ;; http://www.cs.washington.edu/homes/voelker/ntemacs/contrib/printing2.txt ;; for the source (require 'ps-print) (setq ps-paper-type 'ps-a4) ;; (setq ps-lpr-command "print") (setq ps-lpr-command "print") (setq ps-lpr-switches '("/d:\\\\binky\\spruce")) ; the printer name (setq ps-lpr-buffer "c:\\temp\\psspool.ps") ; a tmp spool file (defun nt-ps-print-buffer-with-faces () (interactive) (ps-print-buffer-with-faces ps-lpr-buffer) (shell-command (apply 'concat (append (list ps-lpr-command " ") ps-lpr-switches (list " " ps-lpr-buffer))))) (define-key global-map "\C-cp" 'nt-ps-print-buffer-with-faces) ;; this describes how c++ files are indented (setq c++-mode-hook '(lambda (&rest args) (auto-fill-mode -1) (setq fill-column 78 c-indent-level 4 c-continued-statement-offset 4 c-continued-brace-offset 0 c-brace-offset 0 c-brace-imaginary-offset 0 c-argdecl-indent 4 c-label-offset -4 c++-access-specifier-offset -4 c++-empty-arglist-indent 4 c++-friend-offset 0 c++-electric-pound-behavior '(alignleft) ) (put 'c++-submit-bug-report 'disabled t) (define-key c++-mode-map "" 'reindent-then-newline-and-indent ) ;;(define-key c++-mode-map ";" 'reindent-then-newline-and-indent ) (define-key c++-mode-map ";" 'c++-comment-region) (setq comment-continue comment-start) (setq case-fold-search t) )) (setq c-mode-hook '(lambda (&rest args) (auto-fill-mode -1) (setq fill-column 76) (setq comment-continue " * ") )) (fset 'revert-buffer-now "ørevert-bufferyes") (fset 'kill-buffer-please "økill-buffer") (fset 'insert-tab-please " quoted-insert ") (setq buffers-menu-max-size 35) ; maximum 20 buffer listed on menu (setq line-number-mode t) ;;(setq auto-fill-mode nil) (defun mail-setup-hack () ((lambda (pos) (goto-char (point-min)) (next-line 1) (insert "From: xxxx@yyyy.zzz (moi)\n") ;; Move to "To:" field and check to see if it's empty (mail-to) (backward-char 2) (if (looking-at ":") (end-of-line) ;; Move to message body if "To:" field is not empty. ; (end-of-buffer) ) (end-of-buffer) (goto-char (point-min)) (search-forward "line--") (insert "\n\nSincerely,\nMitch\n") (goto-char (point-min))(end-of-line)) (point)) ;(end-of-buffer) ) (setq mail-setup-hook 'mail-setup-hack) (transient-mark-mode 1) ;; Options Menu Settings ;; ===================== (cond ((and (string-match "XEmacs" emacs-version) (boundp 'emacs-major-version) (= emacs-major-version 19) (>= emacs-minor-version 12)) (setq-default overwrite-mode nil) (setq-default teach-extended-commands-p t) (setq-default bar-cursor nil) (setq-default debug-on-error nil) (setq-default debug-on-quit nil) (setq-default complex-buffers-menu-p nil) (setq-default font-menu-ignore-scaled-fonts t) (setq-default font-menu-this-frame-only-p t) (setq-default buffers-menu-max-size 30) (setq-default case-fold-search t) (setq-default case-replace t) (setq-default zmacs-regions t) (setq-default truncate-lines nil) (setq-default mouse-yank-at-point nil) (require 'paren) (paren-set-mode 'paren) (require 'pending-del) )) (setq Manual-query-multiple-pages t) (setq blink-matching-paren t) ;(setq gnus-nntp-server (getenv "NNTPSERVER")) (put 'erase-buffer 'disabled nil) (setq delete-selection-mode t) (delete-selection-mode t) ;; modeline stuff (setq column-number-mode t) (setq line-number-mode t) (setq buffers-menu-sort-function nil) (setq frame-title-format "TheOneTrueEditor: \"%f\"") ;; SMTP stuff ;;;;;;;;;; Mail Stufff ;;;;;;;;;;;;;;;;;;;;; (setq vm-xemacs-p nil) (setq user-full-name "Mitch Fincher") (setq user-mail-address "mfincher@texas.net") (setq smtpmail-default-smtp-server "mail.texas.net") (setq smtpmail-local-domain nil) (setq send-mail-function 'smtpmail-send-it) (load-library "smtpmail") ;; VM stuff (setq vm-init-file "~/.vm") (autoload 'vm "vm.elc" "" t) ;; Maximum colors ;(autoload 'simple-html-mode "simple-html-mode" "Yay HTML" t) ; (setq auto-mode-alist (cons '("\\.html$" . simple-html-mode) auto-mode-alist;)) (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) (require 'gnuserv) (gnuserv-start) (setq gnuserv-frame (car (frame-list))) (setq completion-ignored-extensions '(".o" ".elc" "~" ".bin" ".bak" ".obj" ".map" ".a" ".ln" ".class")) ;; browser connection (setq highlight-headers-follow-url-function 'highlight-headers-follow-url-netscape) (setq vm-url-browser 'vm-mouse-send-url-to-netscape) (setq browse-url-netscape-program "C:/Progra~1/Netscape/Communicator/Program/netscape.exe") (defvar shell-execute-helper "shelex.exe") (defun shell-execute-url (url &optional new-window) "Invoke the shell-execute-helper program to call ShellExecute and launch or re-direct a web browser on the specified url." (interactive "sURL: ") (call-process shell-execute-helper nil nil nil url)) (setq browse-url-browser-function 'shell-execute-url) (setq gnus-button-url 'shell-execute-url) ; GNUS (setq vm-url-browser 'shell-execute-url) ; VM (modify-syntax-entry 31 "w") ; specifies "_" char 31 to be a word (modify-syntax-entry 45 "w") ; specifies "-" char 45 to be a word (set-face-background 'modeline "plum") (set-face-foreground 'modeline "black") (display-time) ;; VM stuff (autoload 'vm "vm.elc" "" t) ;(add-hook 'diary-hook 'appt-make-list) (defun copy-filename-to-kill-buffer () (interactive) (kill-new (buffer-file-name)) ) (defun toggle-slashes () "toggles the slashes between unix and dos in the region. It changes all / to \ and all \ to / -mdf" (interactive "*") (setq maxptr (point)) (goto-char (mark)) (while ( < (point) maxptr) (if (or (looking-at "/") (looking-at "\\\\")) (progn (if (looking-at "/")(insert "\\")) (if (looking-at "\\\\")(insert "/")) (delete-char 1)) ) (forward-char 1) ) ;; while ) ;; aa/bb (setq-default abbrev-mode t) (read-abbrev-file "~/.abbrev_defs") (setq save-abbrevs t) (setq search-highlight t) (setq query-replace-highlight t) (setq track-eol t) (setq mouse-scroll-delay .0) (setq suggest-key-bindings nil) ;(easy-menu-add simple-html-menu simple-html-mode-map) (if (equal (buffer-file-name) nil) ;; load log file if buffer is empty. (find-file "c:/fincher/log/log.html")) (message "Let's rock!")