(setq max-specpdl-size 1000)
(setq load-path (append
'("~/lisp/elisp" "~/lisp/elisp/cc-mode-5.26")
load-path))
(setq default-frame-alist
'(
(background-color . "white")
(foreground-color . "black")
(cursor-color . "blue")
(cursor-type . box)
(font . "-*-Lucida Console-normal-r-*-*-11-97-96-96-c-*-iso8859-1")
))
(require 'gnuserv)
(gnuserv-start)
(setq gnuserv-frame (selected-frame))
(delete-selection-mode)
(pc-selection-mode)
(hscroll-global-mode t)
(show-paren-mode 1)
(global-set-key [?\M-g] 'goto-line)
(defun make-backup-file-name(file)
(concat "~/backups/" (file-name-nondirectory file) "~"))
(require 'cc-mode)
(defun yes-or-no-p (arg)
"An alias for y-or-n-p, because I hate having to type 'yes' or 'no'."
(y-or-n-p arg))
(setq calendar-latitude [51 30 north])
(setq calendar-longitude [0 5 west])
(setq calendar-location-name "Northampton, UK")
(setq auto-mode-alist
(append '(("\\.C$" . c++-mode)
("\\.cc$" . c++-mode)
("\\.cpp$" . c++-mode)
("\\.cxx$" . c++-mode)
("\\.hxx$" . c++-mode)
("\\.hpp$" . c++-mode)
("\\.h$" . c++-mode)
("\\.hh$" . c++-mode)
("\\.idl$" . c++-mode)
("\\.ipp$" . c++-mode)
("\\.c$" . c-mode)
("\\.pl$" . perl-mode)
("\\.pm$" . perl-mode)
("\\.java$" . java-mode)
("\\.txt$" . text-mode))
auto-mode-alist))
(set-fill-column 72)
(defun my-text-mode-hook ()
(auto-fill-mode)
)
(add-hook 'text-mode-hook 'my-text-mode-hook)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
(setq column-number-mode t)
(require 'whitespace)
(setq whitespace-auto-cleanup t)
(whitespace-global-mode 1)
(add-hook 'folding-mode-hook 'my-folding-mode-hook)
(defun my-folding-mode-hook ()
(interactive)
(setq fold-behave-table
'((close fold-hide)
(open fold-enter)
(up fold-exit)
(other fold-mouse-call-original)))
(define-key folding-mode-map [mouse-3] 'fold-mouse-context-sensitive))
(setq fold-default-keys-function 'fold-bind-backward-compatible-keys)
(load "folding.el" 'nomessage 'noerror)
(folding-mode-add-find-file-hook)
(autoload 'follow-mode "follow.el" nil t)
(autoload 'follow-delete-other-windows-and-split "follow.el" nil t)
(global-set-key [f8] 'follow-mode)
(global-set-key [f7] 'follow-delete-other-windows-and-split)
(add-hook 'follow-mode-hook 'my-follow-mode-hook)
(defun my-follow-mode-hook ()
(define-key follow-mode-map "\C-c\C-v" 'follow-scroll-up)
(define-key follow-mode-map "\C-cv" 'follow-scroll-down)
(define-key follow-mode-map "\C-cb" 'follow-switch-to-buffer)
(define-key follow-mode-map "\C-cl" 'follow-recenter))
(require 'php-mode)
(defvar grep-null-device null-device)
(setq igrep-expression-quote-char ?')
(setq igrep-parenthesis-escape-char ?\\)
(autoload (function igrep) "igrep"
"*Run `grep` PROGRAM to match EXPRESSION in FILES..." t)
(autoload (function igrep-find) "igrep" "*Run `grep` via `find`..." t)
(autoload (function dired-do-igrep) "igrep"
"*Run `grep` on the marked (or next prefix ARG) files." t)
(autoload (function dired-do-igrep-find) "igrep"
"*Run `grep` via `find` on the marked (or next prefix ARG) directories." t)
(setq igrep-options "-i")
(setq igrep-find t)
(global-set-key (quote [f9]) (quote font-lock-fontify-buffer))
(require 'htmlize)
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
(defconst my-c-style
'(
(c-echo-syntactic-information-p . t)
(c-basic-offset . 4)
(c-toggle-auto-state . t)
(c-offsets-alist .
((string . +)
(c . 0)
(defun-open . 0)
(defun-close . 0)
(defun-block-intro . +)
(class-open . 0)
(class-close . 0)
(inline-open . 0)
(inline-close . 0)
(extern-lang-open . 0)
(extern-lang-close . 0)
(func-decl-cont . +)
(knr-argdecl-intro . +)
(knr-argdecl . +)
(topmost-intro . 0)
(topmost-intro-cont . +)
(member-init-intro . +)
(member-init-cont . +)
(inher-intro . +)
(inher-cont . +)
(block-open . 0)
(block-close . 0)
(brace-list-open . 0)
(brace-list-close . 0)
(brace-list-intro . +)
(brace-list-entry . 0)
(statement . 0)
(statement-cont . +)
(statement-block-intro . +)
(statement-case-intro . +)
(statement-case-open . 0)
(substatement . +)
(substatement-open . 0)
(case-label . +)
(access-label . -)
(label . 0)
(do-while-closure . 0)
(else-clause . 0)
(catch-clause . 0)
(comment-intro . 0)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-cont . c-lineup-arglist)
(arglist-cont-nonempty . c-lineup-arglist-intro-after-paren)
(arglist-close . c-lineup-arglist)
(stream-op . +)
(inclass . +)
(inextern-lang . +)
(cpp-macro . 0)
(friend . 0)
(objc-method-intro . +)
(objc-method-args-cont . +)
(objc-method-call-cont . +)
))
(c-comment-only-line-offset . (0 . -1000))
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro) (case-label after)
(label after) (access-label after)))
(c-cleanup-list . ((scope-operator
empty-defun-braces
defun-close-semi)))
)
"Dave's Programming Style")
(defun my-c-mode-common-hook ()
(c-add-style "Dave's" my-c-style t)
(c-set-offset 'member-init-intro '+)
(setq compile-command "nmake -f ")
(setq tab-width 4
indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(setq font-lock-maximum-decoration t)
(global-font-lock-mode t)
(setq font-lock-support-mode 'lazy-lock-mode)
(setq lazy-lock-defer-on-scrolling nil)
(setq lazy-lock-defer-time 1)
(setq lazy-lock-stealth-time 20)
(setq lazy-lock-stealth-lines 25)
(setq lazy-lock-stealth-verbose nil)
(require 'font-lock)
(require 'lazy-lock)
(setq c-font-lock-extra-types
(append
'("BOOL" "BSTR" "LPC?\\(W\\|T\\|OLE\\)?\\STR" "HRESULT"
"BYTE" "DWORD" "SOCKET" "idl_char"
"idl_boolean" "idl_byte" "idl_\\(short\\|long\\)_float"
"idl_u?\\(small\\|short\\|long\\)_int"
"boolean32" "unsigned\\(32\\|16\\)"
"SAFEARRAY" "boolean" "UINT" "ULONG" "VARIANT") c-font-lock-extra-types))
(setq c++-font-lock-extra-types
(append
c-font-lock-extra-types c++-font-lock-extra-types))
(load-library "mic-paren.el")
(require 'font-lock)
(add-hook 'font-lock-mode-hook 'turn-on-fast-lock)
(setq fast-lock-cache-directories '("~/.xemacs/fast-lock/" ))
(setq-default font-lock-maximum-decoration t )
(add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
(add-hook 'lisp-mode-hook 'turn-on-font-lock)
(add-hook 'perl-mode-hook 'turn-on-font-lock)
(add-hook 'c-mode-hook 'turn-on-font-lock)
(add-hook 'c++-mode-hook 'turn-on-font-lock)
(setq user-mail-address "dave@lucien.cx")
(setq smtpmail-default-smtp-server "post.demon.co.uk")
(setq smtpmail-local-domain nil)
(setq user-full-name "David Jolley")
(setq send-mail-function 'smtpmail-send-it)
(load-library "smtpmail")
(load-library "supercite")
(setq sc-nested-citation-p t)
(setq gnus-cache-directory "~/news/cache/")
(setq gnus-home-directory "~/news/")
(setq gnus-startup-file "~/news/.newsrc")
(setq gnus-default-nntp-server "localhost")
(setq gnus-user-full-name "David Jolley")
(setq gnus-user-from-line "dave-news@lucien.demon.co.uk")
(setq message-default-news-headers
"From: David Jolley <dave-news@lucien.demon.co.uk>\nReply-To: David Jolley <dave@lucien.cx>\n")
(setq gnus-use-generic-from "David Jolley")
(setq mail-host-address "lucien.cx")
(setq gnus-local-organization "little, if any")
(setq gnus-secondary-select-methods '((nnml "")))
(setq nnmail-pop-password-required t)(setq gnus-use-cache t)
(setq message-yank-prefix ">")
(defun insert-function-comment ()
"Insert function comment"
(interactive)
(insert-file-contents "~/templates/function.cpp"))
(global-set-key [f6] 'insert-function-comment)
(global-set-key [home] 'My-smart-home)
(global-set-key [end] 'My-smart-end)
(defun My-smart-home ()
"Odd home to beginning of line, even home to beginning of text/code."
(interactive)
(if (and (eq last-command 'My-smart-home)
(/= (line-beginning-position) (point)))
(beginning-of-line)
(beginning-of-line-text))
)
(defun My-smart-end ()
"Odd end to end of line, even end to begin of text/code."
(interactive)
(if (and (eq last-command 'My-smart-end)
(= (line-end-position) (point)))
(end-of-line-text)
(end-of-line))
)
(defun end-of-line-text ()
"Move to end of current line and skip comments and trailing space.
Require `font-lock'."
(interactive)
(end-of-line)
(let ((bol (line-beginning-position)))
(unless (eq font-lock-comment-face (get-text-property bol 'face))
(while (and (/= bol (point))
(eq font-lock-comment-face
(get-text-property (point) 'face)))
(backward-char 1))
(unless (= (point) bol)
(forward-char 1) (skip-chars-backward " \t\n"))))
)
(defun ewd-classname ()
"If the point is in a class definition, gets the name of the class.
Return nil otherwise." (save-excursion
(let ((brace (assoc 'inclass (c-guess-basic-syntax))))
(if (null brace) '() (goto-char (cdr brace))
(let ((class-open (assoc 'class-open (c-guess-basic-syntax))))
(if class-open (goto-char (cdr class-open)))
(if (looking-at "^class[ \t]+\\([A-Za-z_][^ \t:{]*\\)")
(buffer-substring (match-beginning 1) (match-end 1))
(error "Error parsing class definition!")))))))
(defun ewd-insert-new-method (rettype proto)
"Insert a function declaration into the current class header file at
point, along with matching function definition in the corresponding
implementation file, complete with class name and scope resolution
operator. This function expects the implementation file to be named
foo.cpp and in the same directory as the current header file, foo.h."
(interactive "sReturn type:\nsPrototype: ")
(let ((classname (ewd-classname))
(c-tab-always-indent t))
(if (null classname) (message "Not in class definition!")
(unless (string-equal rettype "") (setq rettype (concat rettype " ")))
(insert rettype proto ";")
(c-indent-command)
(save-window-excursion
(find-file (concat (file-name-sans-extension (buffer-file-name))
".cpp"))
(end-of-buffer)
(insert "\n\n")
(insert-function-comment)
(end-of-buffer)
(insert rettype classname "::" proto "\n{\n}\n")))))
(global-set-key "\C-ci" 'ewd-insert-new-method)
(load "desktop")
(desktop-load-default)
(desktop-read)
(setq load-path
(cons "~/lisp/elisp/w3-4.0pre.46/lisp" load-path))
(require 'w3-auto)
(global-set-key [f3] 'ascii-table)
(global-set-key [f4] 'mult-table)
(setq ascii-unprint-chars-low ["NUL " "SOH " "STX " "ETX " "EOT "
"ENQ " "ACK " "BEL " "BS " "HT "
"LF " "VT " "FF " "CR " "SO "
"SI " "DLE " "DC1 " "DC2 " "DC3 "
"DC4 " "NAK " "SYN " "ETB " "CAN "
"EM " "SUB " "ESC " "FS " "GS "
"RS " "US "])
(defun mult-table()
"Prints a formatted multiplication table."
(interactive)
(switch-to-buffer "*MULT*")
(erase-buffer)
(insert "Multiplication table:\n\n")
(let ((i 1))
(insert " 1 2 3 4 5 6 7 8 9 10\n")
(while (< i 11)
(setq j 1)
(if (< i 10)
(insert (format "\n %d " i))
(insert (format "\n%d " i))
)
(while (< j 11)
(setq k (* i j))
(if (< k 10)
(insert (format " %d" k))
(insert (format " %d" k))
)
(setq j (+ j 1))
)
(setq i (+ i 1))
)
)
(beginning-of-buffer)
)
(defun ascii-table ()
"Prints a formatted ASCII table. With control characters symbolically shown"
(interactive)
(switch-to-buffer "*ASCII*")
(erase-buffer)
(insert "ASCII Table:\n\n")
(let ((i 0))
(let ((j 0))
(insert " 0 1 2 3 4 5 6 7 8 9 A B C D E F")
(while (< i 16)
(setq j 0)
(if (= i 8)
(insert "\n\nCharacters after 127 aren't defined in the ASCII spec\n but are defined on this computer's locale as\n")
)
(insert (format "\n %X " i))
(while (< j 16)
(let ((char-num (+ (* i 16) j)))
(if (or (< char-num 32))
(insert (aref ascii-unprint-chars-low char-num))
(if (= char-num 127)
(insert "DEL ")
(if (or (< char-num 127) (> char-num 159))
(insert (format "%c " char-num))
(insert " ")
)
)
)
)
(setq j (+ j 1))
)
(setq i (+ i 1))
)
)
)
(beginning-of-buffer)
)
(require 'color-theme)
(color-theme-sitaramv-solaris)
(require 'ps-print)
(setq ps-lpr-command "c:\\Ghostgum\\gsview\\gsprint.exe")
(setq ps-lpr-switches '("-query"))
(setq ps-printer-name t)
|