;; Are we running XEmacs or Emacs? (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)) ;; Main window title option: set it to say XEmacs: user@host or Emacs: user@host (if running-xemacs (setq frame-title-format (concat "XEmacs: " (user-real-login-name) "@" (system-name))) (setq frame-title-format (concat "Emacs: " (user-real-login-name) "@" (system-name)))) ;; load path for packages (setq load-path (append (list ;"~/.xemacs/xemacs-packages/ultratex/lisp/" ;"~/.xemacs/xemacs-packages/lisp" ) load-path)) ;; Keyboard definitions ;; 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) ;; Makes f1 take to a line (global-set-key '[f1] 'goto-line) ;; makes spell-checking the buffer f12 (global-set-key '[f12] 'ispell-buffer) ;; makes shift-delete cut the selection (global-set-key '[(shift delete)] 'kill-primary-selection) ;; makes C-K delete to the beginning of a line (global-set-key '[(control K)] (lambda () (interactive) (kill-line 0))) ;; makes C-! count the words in the file (global-set-key '[(control !)] 'count-words-buffer);) ;; makes M-f4 exit a gnuclient buffer (global-set-key '[(meta f4)] 'gnuserv-edit) ;; makes C-TAB always switch to another frame (global-set-key '[(control tab)] 'other-window) ;; defines a function recover-this-file that runs recover-file with the ;; current file name --- NOT REALLY USED RIGHT NOW (defun recover-this-file () (recover-file (buffer-file-name))) ;; turn on font-lock mode for emacs ;; if running xemacs from X, load all packages and enable mouse wheel support ;; if running xemacs in a terminal, only lod some of the packages ;; can also check whether you are in a window system by checking ;; the symbol "window-system" ;; currently doing it that way, since emacs has no symbol x-win-initted (cond ((equal window-system 'x) ;; Support Ilisp and AUC-TeX and X-symbol ;(require 'ilisp) ;(require 'tex) ;(require 'tuareg) (global-font-lock-mode t) ;(require 'x-symbol) ;; support the mouse wheel ;(mwheel-install) ;(if running-xemacs (gnuserv-start) (server-start)) ) (t ;; if running Xemacs in a terminal, support Ilisp and AUC-TeX ;(require 'tex) ;(require 'ilisp) )) ;; 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) ;; Syntax coloring by default (font-lock-mode t) ;; Auto-fill by default (auto-fill-mode t) ;; line nubmers by default (line-number-mode t) (column-number-mode t) ;; Changes to hoooks ;; function to highlight code past the 80th column (defun match-at-column-79 (end) (let (done c res) (while (and (not done) (< (point) end)) ;;(message "At point=%s, end=%s, col=%s" (point) end (setq c (current-column))) (cond ; need to move forward >=1 char ((< 79 (current-column)) (forward-line 1)) ; will not move at eobp only ((< 79 (move-to-column 80)) ; will move >= 0 char; 0 chars at eolp (setq done t res t) (forward-char -1) (re-search-forward ".")) ((eobp) (setq done t)) (t (forward-line 1)))) res)) ;; the addition to font-lock (add-hook 'font-lock-mode-hook (function (lambda () (font-lock-add-keywords nil '((match-at-column-79 0 secondary-selection t)) 'append)))) ;; c-mode specific customizations (add-hook 'c-mode-common-hook '(lambda () ;; put tabs instead of spaces (setq tab-width 8 indent-tabs-mode nil) ;; keybindings for all languages (define-key c-mode-base-map "\C-m" 'c-context-line-break) ;; Makes C-c C-v compile (define-key c-mode-base-map '[(control c) (control v)] 'compile))) ;; lisp-mode customizations (autoload 'scheme "ilisp" "Inferior generic Scheme." t) ;;; load hook for Ilisp (add-hook 'ilisp-mode-hook '(lambda () ;; Change default key prefix to C-c (setq ilisp-prefix "\C-c") ;; Define LispMachine-like key bindings, too. (ilisp-lispm-bindings) ;; Define the clisp program (setq clisp-hs-program "clisp -I -q -ansi") ;; Set a keybinding for the COMMON-LISP-HYPERSPEC command (define-key lisp-mode-map "\C-l" 'common-lisp-hyperspec) ;; make C-z C-z evaluate the previous s-expression and not ;; move point (define-key lisp-mode-map '[(control z) (control z)] (lambda () (interactive) (backward-sexp) (eval-next-sexp-lisp) (forward-sexp))) ;; make C-z C-a evaluate the next s-expression and move point ;; to after the s-expression (define-key lisp-mode-map '[(control z) (control a)] (lambda () (interactive) (eval-next-sexp-lisp) (forward-sexp))) ;; Load my definition for the Ilisp display function (load "~/.xemacs/ilisp-init.el") ;; split the window the way I like it if we have enough room (cond ((> (window-width) 160) (make-windows-vertically)) ((> (window-displayed-height) 20) (make-windows-horizontally))) ;; Sample initialization hook. Set the inferior LISP directory to ;; the directory of the buffer that spawned it on the first prompt. (setq ilisp-init-hook '(lambda () (default-directory-lisp ilisp-last-buffer) (setq ilisp-display-output-function 'ilisp-display-output-in-buffers-adaptively))))) ;; x-symbol load hook (add-hook 'x-symbol-after-init-input-hook '(lambda () ;; so that x-symbol does not save 8-bit characters (setq x-symbol-8bits nil) ;; so that x-symbol only changes one kind of expression into ;; one kind of symbol (setq x-symbol-unique t) ;; makes (| and |) not turn into weird symbols (delete '(cataleft (math delim stmaryrd) "\\llparenthesis") x-symbol-tex-table) (delete '(cataright (math delim stmaryrd) "\\rrparenthesis") x-symbol-tex-table) )) ;; fill paragraphs in text mode (add-hook 'text-mode-hook 'turn-on-auto-fill) ;; SML mode hook (add-hook 'sml-mode-hook '(lambda () ;; makes C-c C-c the command to run the inferior SML (define-key sml-mode-map '[(control c) (control c)] 'run-sml) ;; makes enter indent the next line (define-key sml-mode-map "\C-m" 'newline-and-indent) ;; )) ;; Tuareg mode hook (add-hook 'tuareg-mode-hook '(lambda () ;; makes C-up and C-down not go to the beginning and end of chunks (define-key tuareg-mode-map '[(control up)] nil) (define-key tuareg-mode-map '[(control down)] nil))) ;; enable a Matlab mode (autoload 'matlab-mode "~/.xemacs/matlab.el" "Enter Matlab mode." t) (setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist)) (autoload 'matlab-shell "~/.xemacs/matlab.el" "Interactive Matlab mode." t)