;; Red Hat Linux default .emacs initialization file ;; Modifications by darkness ;; $Id: dot-emacs,v 1.9 2004/07/27 05:13:20 darkness Exp $ ;; Are we running XEmacs or Emacs? (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)) ;; Set up the keyboard so the delete key on both the regular keyboard ;; and the keypad delete the character under the cursor and to the right ;; under X, instead of the default, backspace behavior. (global-set-key [delete] 'delete-char) (global-set-key [kp-delete] 'delete-char) ;; Turn on font-lock mode for Emacs (cond ((not running-xemacs) (global-font-lock-mode t) )) ;; Visual feedback on selections (setq-default transient-mark-mode t) ;; Always end a file with a newline (setq require-final-newline t) ;; Stop at the end of the file, not just add lines (setq next-line-add-newlines nil) ;; Enable wheelmouse support by default (cond (window-system (mwheel-install) )) ;;; darkness modifications ;; Some paths to other emacs stuff I have installed. (setq load-path (append '("~/.elisp/single-files" "~/.elisp/w3-lisp" "~/.elisp/psgml" "~/.elisp/tramp" "~/.elisp/cc-mode" "~/.elisp/speedbar" "~/.elisp/eieio" "~/.elisp/semantic" "~/.elisp/elib" "~/.elisp/jde/lisp" "~/.elisp/dictionary" "~/.elisp/xref/emacs" "~/.elisp/slime" "~/.elisp/apel" "~/.elisp/eldav" "~/brm/elisp") load-path)) ;; Make variables buffer local as needed. I kind of fudged my way ;; through making this macro, but it appears to do the right thing, ;; at least in simple cases. (defmacro my-setq-local (&rest bindings) (let ((num-bindings (length bindings)) i output) (if (= (mod num-bindings 2) 1) nil (dotimes (i (/ num-bindings 2)) (setq output (cons `(make-local-variable ',(nth (* i 2) bindings)) output))) (append '(progn) output `(,(cons 'setq bindings)))))) ;; Quick function to make a tab stop list with stops every STEP columns. (defun my-make-tab-stop-list (step &optional last-value) (if (null last-value) (setq last-value 80)) (let ((i last-value) list) (while (> i 0) (setq list (cons i list)) (setq i (- i step))) list)) ;; Simple autoindent functions. (defun my-get-indent-from-current-line-simple () (save-excursion (beginning-of-line) ; I'm actively trying to avoid a regular expression here, ; since I don't want to look too Perl-ish. (let ((start (point))) (skip-syntax-forward " ") (buffer-substring-no-properties start (point))))) (defvar my-get-indent-from-current-line-function 'my-get-indent-from-current-line-simple "This points to a function that must return a string to be used for indenting a line following the current line.") (defun my-get-last-indent () (save-excursion (while (and (> (point) (point-min)) ; Can you tell I spend a lot of time in Perl yet? (progn (beginning-of-line 0) (looking-at "^\\s-*$")))) (cond ((= (point) (point-min)) "") (t (funcall my-get-indent-from-current-line-function))))) (defun my-indent-line-autoindent () (interactive) (save-excursion (beginning-of-line) (delete-horizontal-space) (insert (my-get-last-indent))) (if (bolp) (skip-syntax-forward " " (line-end-position)))) (defun my-newline-and-indent-autoindent () (interactive) (delete-horizontal-space) (newline) (my-indent-line-autoindent)) ;; Remove all preceeding space characters -- not any whitespace, only ;; space -- at point. (defun my-delete-preceding-spaces () (interactive) (while (eq (preceding-char) ?\ ) (delete-backward-char 1))) ;; Scroll one line at a time. (setq scroll-step 1) ;; Maximum decoration. (setq font-lock-maximum-decoration t) ;; Move forward and backward over symbols. (defun forward-symbol (count) "Moves point forward over COUNT symbols." (interactive "p") (let ((max (point-max)) (symbol-syntax-classes '("w" "_")) (i count)) (while (> i 0) (while (and (< (point) max) (not (member (string (char-syntax (char-after))) symbol-syntax-classes))) (forward-char)) (while (and (< (point) max) (member (string (char-syntax (char-after))) symbol-syntax-classes)) (forward-char)) (setq i (1- i))))) (defun backward-symbol (count) "Moves point backward over COUNT symbols." (interactive "p") (let ((min (point-min)) (symbol-syntax-classes '("w" "_")) (i count)) (while (> i 0) (while (and (> (point) min) (not (member (string (char-syntax (char-before))) symbol-syntax-classes))) (backward-char)) (while (and (> (point) min) (member (string (char-syntax (char-before))) symbol-syntax-classes)) (backward-char)) (setq i (1- i))))) ;; Functions to calculate word and symbol length. (defun show-length (forward-func backward-func name) "Shows the length of the object (named by NAME) in the minibuffer. forward-func and backward-func are functions used to move forward and backward over the given type of object. They should accept a single argument, which is the number of types of that object to move over." (save-excursion (let (beginning end) (funcall forward-func 1) (funcall backward-func 1) (setq beginning (point)) (funcall forward-func 1) (setq end (point)) (message (concat name " \"" (buffer-substring beginning end) "\" has length " (number-to-string (- end beginning)) ))))) (defun show-word-length () "Shows the length of the current word in the minibuffer." (interactive) (show-length 'forward-word 'backward-word "Word")) (defun show-symbol-length () "Shows the length of the current symbol in the minibuffer." (interactive) (show-length 'forward-symbol 'backward-symbol "Symbol")) (global-set-key "\C-c\C-w" 'show-word-length) (global-set-key "\C-c\C-s" 'show-symbol-length) ;; No backup files, thank you. (setq make-backup-files nil) ;; python-mode settings. (defun my-python-mode-settings () (setq py-indent-offset 4 py-python-command "python2.3") (my-setq-local indent-tabs-mode nil tab-width 4)) (add-hook 'python-mode-hook 'my-python-mode-settings) ;; Pymacs and bicyclerepairman (BRM) settings. (setenv "PYTHONPATH" (let ((current-path (getenv "PYTHONPATH")) (additional-path (concat (getenv "HOME") "/brm/lib/python2.2/site-packages"))) (if current-path (concat current-path ":" additional-path) additional-path))) (autoload 'pymacs-load "pymacs" nil t) (autoload 'pymacs-eval "pymacs" nil t) (autoload 'pymacs-apply "pymacs") (autoload 'pymacs-call "pymacs") (defun my-python-mode-brm-hook () (pymacs-load "bikeemacs" "brm-") (brm-init)) (add-hook 'python-mode-hook 'my-python-mode-brm-hook) ;; sgml-mode settings. (defun my-sgml-mode-settings () (setq sgml-set-face t sgml-live-element-indicator t sgml-auto-activate-dtd t sgml-insert-missing-element-comment nil sgml-indent-data t sgml-custom-dtd '(("XHTML 1.0 Strict" (concat "\n" "")) ("XHTML 1.0 Transitional" (concat "\n" ""))) ;; Part of my sgml-mode modifications. sgml-explicit-fixed-attribute-alist '(("html" . ("xmlns"))) sgml-attribute-indent-function 'sgml-indent-according-to-stag-end) (my-setq-local indent-tabs-mode t tab-width 4) (local-set-key "\C-m" 'newline-and-indent)) (add-hook 'sgml-mode-hook 'my-sgml-mode-settings) (setq auto-mode-alist (append '(("\\.htm" . xml-mode) ("\\.html" . xml-mode) ("\\.xml" . xml-mode) ("\\.xsl" . xml-mode)) auto-mode-alist)) (autoload 'xml-mode "psgml") ;; Some stuff for working with CVS in vc-mode. Amazingly, vc-mode ;; (vc-mode not... really doing anything, oddly) doesn't have a ;; vc-mode-hook. So, I am left to use find-file-hooks, because I am ;; not 3r33t. (defun my-vc-mode-settings () (if (and (vc-registered buffer-file-name) (eq (vc-backend buffer-file-name) 'CVS)) (local-set-key "\C-xv\C-s" 'cvs-status))) (add-hook 'find-file-hooks 'my-vc-mode-settings) (defun my-log-edit-insert-changelog () (interactive) (log-edit-insert-changelog-entries (log-edit-files)) (log-edit-set-common-indentation) (goto-char (point-max)) (while (eq (char-before) ?\n) (delete-backward-char 1)) (insert "\n") (goto-char (point-min))) (defun my-log-edit-mode-settings () (local-set-key "\C-c\C-a" 'my-log-edit-insert-changelog)) (add-hook 'log-edit-mode-hook 'my-log-edit-mode-settings) ;; auto-fill-mode in certain modes. (defun my-auto-fill-mode-hook () (auto-fill-mode)) (add-hook 'change-log-mode-hook 'my-auto-fill-mode-hook) (add-hook 'log-edit-mode-hook 'my-auto-fill-mode-hook) (add-hook 'blogger-mode-hook 'my-auto-fill-mode-hook) (add-hook 'sgml-mode-hook 'my-auto-fill-mode-hook) ;; Blogger stuff. (autoload 'blogger-start-post "blogger.el") (global-set-key "\C-cbs" 'blogger-start-post) (defun my-blogger-mode-settings () (setq blogger-username "removed-for-security blogger-url "http://foo/bar" blogger-weblog-ping-urls nil)) (add-hook 'blogger-mode-hook 'my-blogger-mode-settings) ;; Elisp debugging settings. It's possible these should be moved ;; to the top. (setq message-log-max '50000) ;(setq-default debug-on-error t) ;; Tramp stuff. (require 'tramp) (setq tramp-default-method "sshx") (setq tramp-auto-save-directory "~/tmp") ;; cperl-mode and other Perl stuff. ;; cperl-mode also sucks. ;; (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode)) ;; (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode)) ;; (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode)) ;; (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode)) ;; (defun my-cperl-mode-settings () ;; (setq ;; ; cperl-extra-newline-before-brace t ;; ; cperl-continued-statement-offset 3 ;; ; cperl-continued-brace-offset 1 ;; tab-width 2 ;; indent-tabs-mode t) ;; (local-set-key "\C-m" 'newline-and-indent) ;; (local-set-key "\C-c\C-hf" 'cperl-perldoc-at-point) ;; (local-set-key "\C-c\C-hd" 'cperl-perldoc)) ;; (add-hook 'cperl-mode-hook 'my-cperl-mode-settings) ;; (defun my-cperl-indent-line () ;; (interactive) ;; (save-excursion ;; (beginning-of-line 0) ;; (let ((cperl-indent-level cperl-indent-level)) ;; (if (looking-at "^\\s-*sub\\s-+") ;; (setq cperl-indent-level -2)) ;; (message (format "%d" cperl-indent-level)) ;; (cperl-indent-line)))) ;; tinyperl isn't very good. ;; (autoload 'turn-on-tinyperl-mode "tinyperl") ;; (add-hook 'cperl-mode-hook 'turn-on-tinyperl-mode) ;; (defun my-post-perldoc () ;; (let ((orig-buffer (current-buffer))) ;; (set-buffer (get-buffer-create tinyperl-:perldoc-buffer)) ;; (goto-char (point-min)) ;; (message (format "XXX %d" (point-min))) ;; (set-buffer orig-buffer))) ;; (add-hook 'tinyperl-:perldoc-hook 'my-post-perldoc) ;; blank-mode. ; This isn't working for some reason. ;(autoload 'blank-mode "blank-mode") (require 'blank-mode) ;; My Perl editing settings. (defvar my-perl-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-hf" 'cperl-perldoc-at-point) (define-key map "\C-c\C-hd" 'cperl-perldoc) (define-key map "{" 'my-perl-mode-electric-open-brace) (define-key map "}" 'my-perl-mode-electric-close-brace) (define-key map "\M-]" 'my-delete-preceding-spaces) map) "Keymap for my-perl-mode.") (defvar my-perl-mode-hook) (defun my-perl-mode-possibly-indent-line () (interactive) (if (or tab-always-indent (let ((starting-point (point))) (<= starting-point (save-excursion (beginning-of-line) (skip-syntax-forward " " starting-point) (point))))) (my-perl-mode-indent-line))) (defun my-perl-mode-single-indent-string () (if indent-tabs-mode "\t" (make-string tab-width ?\ ))) (defun my-perl-mode-get-indentation-from-current-line () (let ((indent-string (my-get-indent-from-current-line-simple))) (save-excursion (beginning-of-line) (skip-syntax-forward " " (line-end-position)) (if (not (eolp)) (let* ((current-char (following-char)) (single-indent (my-perl-mode-single-indent-string)) (single-indent-length (length single-indent))) (cond ((eq current-char ?{) (concat single-indent indent-string)) ((save-excursion (and (eq current-char ?}) (progn (beginning-of-line) (looking-at (regexp-quote single-indent))) (progn (up-list -1) (not (my-perl-mode-line-follows-sub-decl))))) (substring indent-string single-indent-length)) (t indent-string))) indent-string)))) (defun my-perl-mode-indent-line () (interactive) (let ((my-get-indent-from-current-line-function 'my-perl-mode-get-indentation-from-current-line)) (my-indent-line-autoindent))) (defun my-perl-mode-newline-and-indent () (interactive) (delete-horizontal-space) (newline) (my-perl-mode-indent-line) (skip-syntax-forward " " (line-end-position))) (defun my-perl-mode-line-follows-sub-decl () (save-excursion (beginning-of-line 0) (looking-at "\\s-*sub\\([^[:alnum:]_:]\\|$\\)"))) (defun my-perl-mode-electric-open-brace () (interactive) (insert "{") (when (my-perl-mode-string-is-only-thing-on-line "{") (save-excursion (backward-char 1) (while (eq (preceding-char) ?\ ) (delete-backward-char 1)) (when (not (my-perl-mode-line-follows-sub-decl)) (beginning-of-line) (insert (my-perl-mode-single-indent-string)))))) (defun my-perl-mode-electric-close-brace () (interactive) (insert "}") (when (my-perl-mode-string-is-only-thing-on-line "}") (save-excursion (backward-char 1) (while (eq (preceding-char) ?\ ) (delete-backward-char 1)) (beginning-of-line) (let ((single-indent (my-perl-mode-single-indent-string))) (if (looking-at (regexp-quote single-indent)) (delete-char (length single-indent))))))) (defun my-perl-mode-string-is-only-thing-on-line (string) (save-excursion (beginning-of-line) (looking-at (concat "^\\s-*" (regexp-quote string) "\\s-*$")))) (defun my-perl-mode () "My simple perl mode." (interactive) (kill-all-local-variables) (my-setq-local major-mode 'my-perl-mode mode-name "MyPerl" indent-line-function 'my-perl-mode-indent-line comment-start "#") (use-local-map my-perl-mode-map) (put 'my-perl-mode 'mode-class 'special) ; I believe this to be semi-harmless magic to turn on cperl-mode ; syntax highlighting. It is very possible some things will be found ; to be broken. (setq cperl-clobber-mode-lists nil) (require 'cperl-mode) (set-syntax-table cperl-mode-syntax-table) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults (cond ((string< emacs-version "19.30") '(perl-font-lock-keywords-2)) ((string< emacs-version "19.33") ; Which one to use? '((perl-font-lock-keywords perl-font-lock-keywords-1 perl-font-lock-keywords-2))) (t '((cperl-load-font-lock-keywords cperl-load-font-lock-keywords-1 cperl-load-font-lock-keywords-2))))) (if cperl-use-syntax-table-text-property (progn (make-variable-buffer-local 'parse-sexp-lookup-properties) ;; Do not introduce variable if not needed, we check it! (set 'parse-sexp-lookup-properties t) ;; Fix broken font-lock: (or (boundp 'font-lock-unfontify-region-function) (set 'font-lock-unfontify-region-function 'font-lock-default-unfontify-region)) (make-variable-buffer-local 'font-lock-unfontify-region-function) (set 'font-lock-unfontify-region-function 'cperl-font-lock-unfontify-region-function) (make-variable-buffer-local 'cperl-syntax-done-to) ;; Another bug: unless font-lock-syntactic-keywords, font-lock ;; ignores syntax-table text-property. (t) is a hack ;; to make font-lock think that font-lock-syntactic-keywords ;; are defined (make-variable-buffer-local 'font-lock-syntactic-keywords) (setq font-lock-syntactic-keywords (if cperl-syntaxify-by-font-lock '(t (cperl-fontify-syntaxically)) '(t))))) (cperl-init-faces) (font-lock-mode 1) (run-hooks 'my-perl-mode-hook)) (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . my-perl-mode)) (add-to-list 'interpreter-mode-alist '("perl" . my-perl-mode)) (add-to-list 'interpreter-mode-alist '("perl5" . my-perl-mode)) (add-to-list 'interpreter-mode-alist '("miniperl" . my-perl-mode)) (defun my-my-perl-mode-settings () (my-setq-local indent-tabs-mode t tab-width 2 tab-stop-list (my-make-tab-stop-list 2) dabbrev-case-fold-search nil comment-start "##" comment-padding nil) (local-set-key "\C-m" 'my-perl-mode-newline-and-indent)) (add-hook 'my-perl-mode-hook 'my-my-perl-mode-settings) ;; sh-mode settings. (defun my-sh-mode-settings () (setq sh-basic-offset 2) (my-setq-local indent-tabs-mode t tab-width 2 tab-stop-list (my-make-tab-stop-list 2) sh-indent-after-do '+ sh-indent-for-do 0 sh-indent-after-if '+ sh-indent-for-then 0) (local-set-key "\C-m" 'newline-and-indent)) (add-hook 'sh-mode-hook 'my-sh-mode-settings) ;; Run if Emacs is running in server mode and it switches the active ;; buffer in a frame as a result of a client request. I think. (defun my-server-switch-hook () (make-frame-visible)) (add-hook 'server-switch-hook 'my-server-switch-hook) ;; Java indenting stuff for cc-mode. (defun my-c-lineup-java-throws (&rest args) (let ((c-basic-offset 5)) (apply 'c-lineup-java-throws args))) (defun my-c-lineup-math (&rest args) (let ((c-basic-offset 5)) (apply 'c-lineup-math args))) (defun my-java-cc-mode-settings () (setq c-basic-offset 4) (c-set-offset 'func-decl-cont 'my-c-lineup-java-throws) (c-set-offset 'statement-cont 'my-c-lineup-math) (c-set-offset 'topmost-intro-cont 5) (c-set-offset 'inher-intro 5) (my-setq-local tab-width 4 tab-stop-list (my-make-tab-stop-list 4) indent-tabs-mode t dabbrev-case-fold-search nil) (local-set-key "\C-m" 'newline-and-indent) (add-hook 'c-special-indent-hook 'my-c-possibly-indent-mixed-tab-space)) (add-hook 'java-mode-hook 'my-java-cc-mode-settings) ;; Mixed tab/space indenting for cc-mode. Like most everything I ;; write in Elisp, I don't expect that this is very pretty for an ;; experienced programmer to look at. (require 'cl) (defun my-c-possibly-indent-mixed-tab-space () (let* ((syntax (c-guess-basic-syntax)) (syntax-symbol (car (car syntax)))) (cond ((or (memq syntax-symbol '(arglist-cont-nonempty func-decl-cont topmost-intro-cont inher-cont statement-cont brace-list-entry)) (and (eq syntax-symbol 'statement) (> (count-lines (cadar syntax) (point)) 1))) (my-c-indent-mixed-tab-space syntax))))) (defun my-c-indent-mixed-tab-space (syntax) (let ((c-indent-column (c-get-syntactic-indentation syntax)) (starting-point (point)) parent-indent-str parent-indent-column) (save-excursion (setq starting-point (point)) (goto-char (cadar syntax)) (beginning-of-line) (setq parent-indent-str (buffer-substring (point) (+ (point) (skip-syntax-forward " ")))) (setq parent-indent-column (current-column)) (goto-char starting-point) (move-to-column c-indent-column) (delete-horizontal-space) ; Don't know if this is necessary. (beginning-of-line) (insert parent-indent-str (make-string (- c-indent-column parent-indent-column) ?\ ))) (if (= (current-column) 0) (move-to-column c-indent-column)))) ;; JDE stuff. (autoload 'jde-mode "jde") (add-to-list 'auto-mode-alist '("\\.java\\'" . jde-mode)) (add-hook 'jde-mode-hook 'my-java-cc-mode-settings) (defun my-regexp-search-replace-list (regexp replacement list) "For each element of LIST: - If that element is a string, REPLACEMENT is nil, and the element matches REGEXP, the string is not included in the resulting list. - If that element is a string, REPLACEMENT is non-nil, all matches of REGEXP are replaced with REPLACEMENT. The string is then added to the resulting list. - If the element is not a string, it is added to the resulting list without modification." (let ((return-list nil) elt) (dolist (elt list return-list) (let ((is-string (stringp elt))) (unless (and is-string (null replacement) (string-match regexp elt)) (if (and is-string (not (null replacement))) (while (string-match regexp elt) (setq elt (replace-match replacement t nil elt)))) (setq return-list (append return-list `(,elt)))))))) (defun my-jde-mode-settings () (setq jde-help-docsets '(("JDK API" "http://java.sun.com/j2se/1.4.1/docs/api/" nil)) jde-ant-enable-find t jde-ant-read-target t jde-build-function '(jde-ant-build) jde-ant-build-hook '(jde-compile-finish-refresh-speedbar jde-compile-finish-flush-completion-cache) jde-gen-method-signature-padding-1 " " jde-gen-method-signature-padding-3 "\n" jde-gen-method-conditional-padding-3 "\n" jde-gen-k&r nil jde-gen-comments nil) (let ((method-template (my-regexp-search-replace-list (regexp-quote "(jde-javadoc-autodoc-at-line)") "" jde-gen-method-template))) (defalias 'jde-gen-method (tempo-define-template "method" (jde-gen-read-template method-template) nil "Insert skeleton method.")) (setq-default jde-gen-method-template method-template))) (add-hook 'jde-mode-hook 'my-jde-mode-settings) ;; w3m. (autoload 'w3m-goto-url-new-session "w3m") (autoload 'w3m-goto-url "w3m") ;; browse-url stuff. (setq browse-url-new-window-flag nil) ; Based on browse-url-w3m taken from ; http://list-archive.xemacs.org/xemacs-patches/200211/msg00070.html (defun browse-url-w3m (url &optional new-window) "Ask the emacs-w3m WWW browser to load URL. Default to the URL around or before point. When called interactively, if variable `browse-url-new-window-flag' is non-nil, load the document in a new window. A non-nil interactive prefix argument reverses the effect of `browse-url-new-window-flag'. When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "W3M URL: ")) (if (browse-url-maybe-new-window new-window) (progn (split-window) (other-window 1))) ; (w3m-goto-url-new-session url)) (w3m-goto-url url)) ; The behavior we're looking for: ; - If a *w3m* buffer is active in any windows in any frame, focus on it. ; - Otherwise, make a new frame, focus to it, and display w3m in it. ; This is useful when I'm using SLIME and I call up a Hyperspec page. (defun my-browse-url-w3m (url &optional new-window) "This function does its best to totally disregard new-window and friends." (interactive (browse-url-interactive-arg "W3M URL: ")) (let* ((w3m-window (get-buffer-window "*w3m*" t)) (w3m-frame (if (not (eq w3m-window nil)) (window-frame w3m-window) (let ((frame (new-frame))) (setf w3m-window (frame-selected-window frame)) frame)))) (select-frame w3m-frame) (raise-frame w3m-frame) (select-window w3m-window) ; Without this my sloppy focus ends up not giving the frame keyboard ; focus. 0 should be the index of the selected frame in the cyclic ; frame list. Check out 29.9 in the elisp manual, specifically ; focus-follows-mouse. (other-frame 0) (w3m-goto-url url))) (setq browse-url-browser-function 'my-browse-url-w3m) ;; dictionary stuff. (load "dictionary-init") (global-set-key "\C-c\C-ud" 'dictionary-search) (global-set-key "\C-c\C-uw" 'dictionary-lookup-definition) ;; webjump and webjump-plus stuff. (defun my-webjump-load (&optional args) (interactive) (require 'webjump-plus) (setq webjump-sites (append webjump-sites webjump-plus-sites)) (apply 'webjump args)) (fset 'webjump 'my-webjump-load) ;; Some cc-mode universal settings. (defun my-cc-mode-initialization-hook () (setq c-style-variables-are-local-p t)) (add-hook 'c-initialization-hook 'my-cc-mode-initialization-hook) ;; Xrefactory stuff. ; We put Xrefactory as a java-mode hook so java-mode sets up the local ; map for us. Xrefactory does not have its own mode. (add-hook 'java-mode-hook 'my-load-xrefactory) (defun my-load-xrefactory () (my-setq-local exec-path (append exec-path '("~/.elisp/xref")) xref-current-project nil xref-key-binding 'local) (load "xrefactory")) ;; w3m stuff. (add-hook 'w3m-form-input-textarea-mode-hook '(lambda () (save-excursion (while (re-search-forward "\r\n" nil t) (replace-match "\n" nil nil))) (refill-mode) (longlines-mode))) (add-hook 'w3m-form-input-textarea-set-hook '(lambda () (refill-mode -1) (longlines-mode -1) (save-excursion (while (re-search-forward "\n" nil t) (replace-match "\r\n" nil nil))))) (defun my-w3m-mode-settings () (setq w3m-use-cookies t)) (add-hook 'w3m-mode-hook 'my-w3m-mode-settings) ; Secretly emacs-w3m kind of sucks. If we're using w3m from a ; terminal we might still be editing textarea's from emacs. Add ; some auto-mode-alist entries to set the above settings. (defun longlines-refill-mode () (longlines-mode) (refill-mode)) (setq auto-mode-alist (append '(("/w3m[^/]*\\'" . longlines-refill-mode)) auto-mode-alist)) ;; longlines.el stuff. (autoload 'longlines-mode "longlines" nil t) ;; sql-mode stuff. (defun my-sql-mode-settings () (local-set-key "\C-i" 'self-insert-command) ; (my-setq-local sql-postgres-options (append sql-postgres-options ; '("--set" "PROMPT2="))) ) (add-hook 'sql-mode-hook 'my-sql-mode-settings) ;; ILISP stuff. ;; (setq common-lisp-hyperspec-root "file:/home/darkness/HyperSpec/" ;; common-lisp-hyperspec-symbol-table ;; "/home/darkness/HyperSpec/Data/Map_Sym.txt" ;; cltl2-root-url "file:/home/darkness/cltl/") ;; (set-default 'auto-mode-alist ;; (append '(("\\.lisp$" . lisp-mode) ;; ("\\.lsp$" . lisp-mode) ;; ("\\.cl$" . lisp-mode)) ;; auto-mode-alist)) ;; (add-hook 'lisp-mode-hook '(lambda () (require 'ilisp))) ;; (set-default 'auto-mode-alist ;; (append '(("\\.scm$" . scheme-mode) ;; ("\\.ss$" . scheme-mode) ;; ("\\.stk$" . scheme-mode) ;; ("\\.stklos$" . scheme-mode)) ;; auto-mode-alist)) ;; (add-hook 'scheme-mode-hook '(lambda () (require 'ilisp))) ;; (autoload 'sbcl "ilisp" nil t) ;; C code. (defun my-c-mode-hook () (c-set-style "k&r") (c-set-offset 'statement-cont 'my-c-lineup-math) (my-setq-local tab-width 4 tab-stop-list (my-make-tab-stop-list 4) indent-tabs-mode t dabbrev-case-fold-search nil c-basic-offset 4 c-backspace-function 'delete-backward-char) (local-set-key "\C-m" 'newline-and-indent) (add-hook 'c-special-indent-hook 'my-c-possibly-indent-mixed-tab-space)) (add-hook 'c-mode-hook 'my-c-mode-hook) ;; ange-ftp sees weird error messages on Red Hat. (require 'ange-ftp) (setq ange-ftp-skip-msgs (concat ange-ftp-skip-msgs "\\|^500 'AUTH': command not understood")) ;; Lisp and Slime. (autoload 'slime "slime" nil t) (autoload 'slime-mode "slime" nil t) (add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t))) (setq inferior-lisp-program "sbcl") (setq slime-multiprocessing t) (setq common-lisp-hyperspec-root "file:///home/darkness/lisp/HyperSpec/") (defun my-lisp-mode-hook () (slime-mode t) (my-setq-local lisp-indent-function 'common-lisp-indent-function) (local-set-key "\C-m" 'newline-and-indent) (local-set-key [?\M-\C-/] 'slime-complete-symbol)) (add-hook 'lisp-mode-hook 'my-lisp-mode-hook) ;; Prolog mode. (autoload 'run-prolog "prolog" "Start a Prolog sub-process." t) (autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t) ;(autoload 'mercury-mode "prolog" "Major mode for editing Mercury programs." t) (setq prolog-system 'swi) (setq auto-mode-alist (append '(("\\.pl$" . prolog-mode) ; ("\\.m$" . mercury-mode) ) auto-mode-alist))