;; Local customizations override system versions (add-to-list 'load-path "/usr/share/emacs/site-lisp") (add-to-list 'load-path "/usr/local/share/emacs/site-lisp") (add-to-list 'load-path "~/.emacs.d/site-lisp") ;; PTW's c style preferences (from Harlequin MM Group) (defconst mm-c-style '( (c-basic-offset . 2) ; ptw prefer's 2 but Laszlo seems to use 4 (c-comment-only-line-offset . (0 . 0)) (c-offsets-alist . ((statement-block-intro . +) (knr-argdecl-intro . 5) (substatement-open . 0) ; GNU uses + (label . 0) (case-label . +) ; GNU uses cc-mode default, (case-label 0) (statement-case-open . +) (statement-cont . +) (arglist-intro . + ) ; c-lineup-arglist-intro-after-paren) (arglist-cont . 0) ; Don't line up if no args after paren (arglist-close . c-lineup-arglist) )) (c-cleanup-list . (brace-else-brace scope-operator)) ;; don't fill doc comment start lines (c-hanging-comment-starter-p . nil) (c-comment-continuation-stars . "* ") ; GNU uses "" (c-hanging-comment-ender-p . nil) ; GNU uses t (c-echo-syntactic-information-p . t) ) "MM C Programming Style") ;; PTW likes all C operators to be treated as symbols for the purposes ;; of sexp commands. It makes more sense to him (defun bung-c-mode-syntax-table () (let ((table c-mode-syntax-table)) (modify-syntax-entry ?! "_" table) (modify-syntax-entry ?~ "_" table) (modify-syntax-entry ?* "_" table) (modify-syntax-entry ?% "_" table) (modify-syntax-entry ?+ "_" table) (modify-syntax-entry ?- "_" table) (modify-syntax-entry ?< "_" table) (modify-syntax-entry ?> "_" table) (modify-syntax-entry ?& "_" table) (modify-syntax-entry ?^ "_" table) (modify-syntax-entry ?| "_" table) (modify-syntax-entry ?? "_" table) (modify-syntax-entry ?: "_" table) (modify-syntax-entry ?= "_" table) (cond ((memq '8-bit c-emacs-features) ;; XEmacs (formerly Lucid) has the best implementation (modify-syntax-entry ?/ "_ 1456" table) (modify-syntax-entry ?* "_ 23" table) (modify-syntax-entry ?\n "> b" table) ;; Give CR the same syntax as newline, for selective-display (modify-syntax-entry ?\^m "> b" table)) ((memq '1-bit c-emacs-features) ;; Emacs 19 does things differently, but we can work with it (modify-syntax-entry ?/ "_ 124b" table) (modify-syntax-entry ?* "_ 23" table) (modify-syntax-entry ?\n "> b" table) ;; Give CR the same syntax as newline, for selective-display (modify-syntax-entry ?\^m "> b" table)) ) ;; hack to make casified words sort of work as components (let ((i ?a)) (while (<= i ?z) (modify-syntax-entry i "w" table) (setq i (1+ i)))) (let ((i ?A)) (while (<= i ?Z) (modify-syntax-entry i "_" table) (setq i (1+ i)))) ) ) ;; Customizations for all of c-mode, c++-mode, and objc-mode (defun my-c-mode-common-hook () ;; add my personal style and set it for the current buffer (c-add-style "MM" mm-c-style c-buffer-is-cc-mode) ;; other customizations (setq tab-width 8 ;; this will make sure spaces are used instead of tabs indent-tabs-mode nil) ;; I don't like auto-newline and hungry-delete (c-toggle-auto-hungry-state -1) (setq c-indent-comments-syntactically-p t) ;; keybindings for C, C++, and Objective-C. We can put these in ;; c-mode-map because c++-mode-map and objc-mode-map inherit it (define-key c-mode-map "\C-m" 'newline-and-indent) ;; (setq dabbrev-case-fold-search nil dabbrev-case-replace nil) (turn-on-auto-fill) ;; Use ptw's syntax table (bung-c-mode-syntax-table) ) ;; the following only works in Emacs 19 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) ;; whitespace (require 'whitespace) ;; Text prefs (add-hook 'text-mode-hook 'turn-on-auto-fill) (setq require-final-newline 'ask) ;; was -alL, but then you can't see symlinks (setq dired-listing-switches "-alh") ;; Need to add 'B' and 'K' as size suffixes to this for -h above ;; [From dired.el] (setq dired-move-to-filename-regexp (let* ((l "\\([A-Za-z]\\|[^\0-\177]\\)") ;; In some locales, month abbreviations are as short as 2 letters, ;; and they can be padded on the right with spaces. ;; weiand: changed: month ends potentially with . or , or ., ;;old (month (concat l l "+ *")) (month (concat l l "+[.]?,? *")) ;; Recognize any non-ASCII character. ;; The purpose is to match a Kanji character. (k "[^\0-\177]") ;; (k "[^\x00-\x7f\x80-\xff]") (s " ") (yyyy "[0-9][0-9][0-9][0-9]") (mm "[ 0-1]?[0-9]") ;;old (dd "[ 0-3][0-9]") (dd "[ 0-3][0-9][.]?") (HH:MM "[ 0-2][0-9]:[0-5][0-9]") (seconds "[0-6][0-9]\\([.,][0-9]+\\)?") (zone "[-+][0-2][0-9][0-5][0-9]") (iso-mm-dd "[01][0-9]-[0-3][0-9]") (iso-time (concat HH:MM "\\(:" seconds "\\( ?" zone "\\)?\\)?")) (iso (concat "\\(\\(" yyyy "-\\)?" iso-mm-dd "[ T]" iso-time "\\|" yyyy "-" iso-mm-dd " ?\\)")) (western (concat "\\(" month s dd "\\|" dd s month "\\)" ;; weiand: changed: year potentially unaligned ;;old s "\\(" HH:MM "\\|" s yyyy "\\|" yyyy s "\\)")) s "\\(" HH:MM "\\|" yyyy s s "?" "\\|" s "?" yyyy "\\)")) (japanese (concat mm k "?" s dd k "?" s "+" "\\(" HH:MM "\\|" yyyy k "?" "\\)"))) ;; The "[0-9]" below requires the previous column to end in a digit. ;; This avoids recognizing `1 may 1997' as a date in the line: ;; -r--r--r-- 1 may 1997 1168 Oct 19 16:49 README ;; The "[kMGTPEZY]?" below supports "ls -alh" output. ;; The ".*" below finds the last match if there are multiple matches. ;; This avoids recognizing `jservice 10 1024' as a date in the line: ;; drwxr-xr-x 3 jservice 10 1024 Jul 2 1997 esg-host (concat ".*[0-9][BkKMGTPEZY]?" s "\\(" western "\\|" japanese "\\|" iso "\\)" s))) (load "ange-ftp") ;; I think the released version of this is broken (defun x-cut-buffer-or-selection-value () (let (text) (when x-select-enable-clipboard (if (null text) (condition-case c (setq text (x-get-selection 'CLIPBOARD 'COMPOUND_TEXT)) (error nil))) (if (null text) (condition-case c (setq text (x-get-selection 'CLIPBOARD 'STRING)) (error nil))) (if (string= text "") (setq text nil))) ;; Don't die if x-get-selection signals an error. (if (null text) (condition-case c (setq text (x-get-selection 'PRIMARY 'COMPOUND_TEXT)) (error nil))) (if (null text) (condition-case c (setq text (x-get-selection 'PRIMARY 'STRING)) (error nil))) (if (string= text "") (setq text nil)) ;; Filter out either of those it they are from us (setq text (cond ((not text) nil) ((eq text x-last-selected-text) nil) ((string= text x-last-selected-text) ;; Record the newer string, so subsequent calls can use the `eq' test. (setq x-last-selected-text text) nil) (t text))) ;; Try the cut buffer (or text (setq text (x-get-cut-buffer 0))) (if (string= text "") (setq text nil)) ;; Now filter once again (cond ((not text) nil) ((eq text x-last-selected-text) nil) ((string= text x-last-selected-text) ;; Record the newer string, so subsequent calls can use the `eq' test. (setq x-last-selected-text text) nil) (t (setq x-last-selected-text text))))) ;; My keybindings (global-set-key "" (quote goto-line)) ;; Check for Xemacs (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)) ;; Start server (if running-xemacs (gnuserv-start) (server-start) ) ;; Syntax highlighting (global-font-lock-mode t) (setq font-lock-maximum-decoration t) ;; Font-lock for all derivatives of c-mode (add-hook 'c-mode-hook (lambda () (font-lock-add-keywords nil '( ("//" ("\\<\\(TODO\\|FIXME\\|NOTE\\|XXX\\|---\\|+++\\)\\>" nil nil (0 'font-lock-warning-face t))) ))) ) ;; Ditto for Lisp modes (add-hook 'lisp-mode-hook (lambda () (font-lock-add-keywords 'lisp-mode '( (";" ("\\<\\(TODO\\|FIXME\\|NOTE\\|XXX\\|---\\|+++\\)\\>" nil nil (0 'font-lock-warning-face t))) ; )))) ;; Other modes (font-lock-add-keywords 'nxml-mode '( ("