;;Purpose: ;; init file common to both emacs and xemacs ;; ;;================== ;;================================== ;; ChangeLog:2009-11-08 ;; The following is based on instructions from: ;; ;; http://www.gnu.org/software/cflow/manual/cflow.html#Emacs ;; ;;(autoload 'cflow-mode "cflow-mode") ;;(setq auto-mode-alist (append auto-mode-alist ;; '(("\\.cflow$" . cflow-mode)))) ;;================================== ;(debug) ;;(load-file "/usr/share/emacs/site-lisp/cedet-common/cedet.el") ;;Above load-file according to http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html#sec2 ;;========>Desktop save<============ ;;;;Don't use the following desktop calls because ;;;;they seem to cause > to be indented 2 spaces ;;;;past where it's actually inserted in a .cpp file :( ;;(desktop-load-default) ;; ;; By default we starting in text mode. (setq initial-major-mode (lambda () (text-mode) (turn-on-auto-fill) (font-lock-mode 1) )) ;; Define function to match a parenthesis otherwise insert a % (defun match-paren (arg) "Go to the matching parenthesis if on parenthesis otherwise insert %." (interactive "p") (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) ((looking-at "\\s\)") (forward-char 1) (backward-list 1)) (t (self-insert-command (or arg 1))))) (global-set-key "%" 'match-paren) ;;======>save recent files<========= (recentf-mode t) ;; ;;(debug-on-entry 'run-hooks ) ;;(debug-on-entry 'c++-mode-my-hook ) ;;=================================== ;; ChangeLog:2010-12-08.1616 ;; As instructed by: ;; http://haskell.org/haskellwiki/Haskell_mode_for_Emacs#Setup ;; ChangeLog:2011-01-05.1326 ;; Because getting error about ;; turn-on-haskell-indentation ;; being void, and seeing in: ;; /usr/share/emacs/site-lisp/haskell-mode/haskell-indent.el ;; the instruction: ;; (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) ;; followed that instruction. ;; (load "/usr/share/emacs/site-lisp/haskell-mode/haskell-site-file") (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) ;;************2011-01-04.2219:copied from ../xemacs/custom.el********** ;;************************************ (defun c-electric-my-brace (arg) "my c-electric-brace. arg ignored. Only present because required by ?" (interactive "P") (self-insert-command (prefix-numeric-value arg)) ) ;;defun)c-electric-my-brace defun ;;************************************ (defun c-newline-indent-my-relative (arg) "insert newline and then indent relative" (interactive "P") (newline ) (indent-relative-maybe) ;;(message "indent-my-rel") ) ;;defun)c-newline-indent-my-relative ;;************************************ (defun c-insert-my-tab (arg) "insert a tab. arg is ignored" (interactive "P") (message "{insert tab") (move-to-tab-stop) (message "}insert tab") ) ;;defun)c-insert-my-tab ;;************************************ (defun c-insert-my-shift-tab (arg) "insert a shift-tab. arg is ignored" (interactive "P") (message "{insert shift-tab") (let ((tabs tab-stop-list) (new-column 0) ) (while (and tabs (< (car tabs) (current-column))) (setq new-column (car tabs)) (setq tabs (cdr tabs)) );end while (if tabs (move-to-column new-column t) );end if );end let (message "}insert shift-tab") ) ;;defun)c-insert-my-shift-tab ;;************************************ (defun c-tab-stop-my-list () "my tab-stop-list for c/c++ modes" (message "%s" "c-tab-stop-my-list message") (setq tab-stop-list (let ( (value) (tab-width 2) ) (dotimes (number 3 value) (setq value (append value (list (* number tab-width)) ; 1 element list ) ) ) ) ) ) ;;defun)c-tab-stop-my-list ;;************************************ (defun c++-mode-my-hook () "my c++-mode-hook" (c-tab-stop-my-list) (message "%s" "c++-mode-my-hook message:tabs=") (message "%s" tab-stop-list) (define-key c++-mode-map "\r" 'c-newline-indent-my-relative) (define-key c++-mode-map "<" 'self-insert-command) (define-key c++-mode-map ">" 'self-insert-command) (define-key c++-mode-map "(" 'self-insert-command) (define-key c++-mode-map ")" 'self-insert-command) (define-key c++-mode-map "{" 'self-insert-command) (define-key c++-mode-map "}" 'self-insert-command) (define-key c++-mode-map "/" 'self-insert-command) (define-key c++-mode-map "," 'self-insert-command) (define-key c++-mode-map ";" 'self-insert-command) (define-key c++-mode-map ":" 'self-insert-command) (message "%s" "c++-mode-my-hook message{") (setq debug-on-error t) (define-key c++-mode-map 'tab 'c-insert-my-tab) (message "%s" "c++-mode-my-hook message;") ;;(define-key c++-mode-map 'iso-left-tab 'c-insert-my-shift-tab) (message "%s" "c++-mode-my-hook message}") (setq indent-tabs-mode nil) ) ;;defun) c++-mode-my-hook (setq c++-mode-hook 'c++-mode-my-hook ) ;;the filename extension in the following is for Template definitions (setq auto-mode-alist (cons ( cons "\\.hpp\\'" 'c++-mode ) auto-mode-alist ) ) ;;the filename extension in the following is for Template definitions (setq auto-mode-alist (cons ( cons "\\.cpp\\'" 'c++-mode ) auto-mode-alist ) ) ;;the filename extension in the following is for Template definitions (setq auto-mode-alist (cons ( cons "\\.tpp\\'" 'c++-mode ) auto-mode-alist ) ) ;;the filename extension in the following is for Forward declarations (setq auto-mode-alist (cons ( cons "\\.fpp\\'" 'c++-mode ) auto-mode-alist ) ) ;;the filename extension in the following is for "simple" include files ;; i.e. files included in another file which is a .cpp or .hpp file (setq auto-mode-alist (cons ( cons "\\.ipp\\'" 'c++-mode ) auto-mode-alist ) ) ;;************************************ (defun text-mode-my-hook () "my text-mode-hook" ;; (message "text-mode-my-hook message") (c-tab-stop-my-list) (auto-fill-mode) (define-key text-mode-map "\r" 'c-newline-indent-my-relative) ) ;;defun) text-mode-my-hook (setq text-mode-hook 'text-mode-my-hook ) (setq auto-mode-alist (cons ( cons "\\.log\\'" 'text-mode ) auto-mode-alist ) ) (setq auto-mode-alist (cons ( cons "\\.pl\\'" 'text-mode ) auto-mode-alist ) ) (setq auto-mode-alist (cons ( cons "\\.pm\\'" 'text-mode ) auto-mode-alist ) ) (setq auto-mode-alist (cons ( cons "\\.g\\'" 'text-mode ) auto-mode-alist ) ) (setq auto-mode-alist (cons ( cons "\\.imk\\'" 'makefile-mode ) auto-mode-alist ) ) (setq auto-mode-alist (cons ( cons "\\.mk\\'" 'makefile-mode ) auto-mode-alist ) ) ;;************************************ (put 'narrow-to-region 'disabled nil) ;; The following copied from ../.emacs.d/Abrahams.emacs ; is it gnu emacs or xemacs (setq my-gnup (not (string-match "^\\(XEmacs\\).*" (emacs-version)))) ;; font-lock-mode is what implements syntax coloring and hilighting. (require 'font-lock) ; require forces the module to load right away. ;; ;; Override some of the default version-control behavior ;; (require 'vc-hooks) (defun my-vc-file-owner (file) ;; vc-mode doesn't seems overly strict in checking the writable status of ;; checked-out files: It wants the CVS username to be identical to the login ;; of the emacs user. This is problematic if you work with repositories where ;; your userID is different from your OS login. This is typical when working ;; with remote repositories. Here we just fake emacs into thinking that these ;; things always match. (vc-user-login-name)) ;; ;; Set defaults that will be picked up by various modes and other emacs packages. ;; (setq-default ;; "Electrify" a few keys in SGML-mode for editing HTML documents sgml-quick-keys t sgml-validate-command "gtidy" ; sgml-validate-command "tidy -i -wrap 78 --keep-time 0 --gnu-emacs 1 --gnu-emacs-file" ;; Tell me if I use M-x when there was a key binding for it teach-extended-commands-p t ;; Non-nil means truncate lines in all windows less than full frame wide. truncate-partial-width-windows nil ;; Show the file name in the buffer's mode-line ;; mode-line-buffer-identification '("%12b [%f]") ;; Always indent using spaces instead of tabs (hooked separately for makefiles below) indent-tabs-mode nil ;; By default, ediff all in one frame. ediff-window-setup-function 'ediff-setup-windows-plain ;; view diffs side-by-side ediff-split-window-function 'split-window-horizontally ;; only highlight the selected diff (keeps down gray cruft onscreen) ediff-highlight-all-diffs nil ;; don't try to use pkunzip to extract archive-zip-use-pkzip nil ) (if my-gnup (progn ;; Automatically revert unmodified buffers when they change out from under us on disk. (global-auto-revert-mode 1) ;; Turn on syntax highlighting in all modes by default (global-font-lock-mode 1) ;; This highlights the region (between point and mark) whenever the mark is ;; active. It also causes the mark to be able to become inactive (e.g. by ;; typing C-g. To get the mark back, just type C-x C-x. (transient-mark-mode 1) )) ;;================================== ;; ChangeLog:2009-11-09 ;; The following is based on instructions from: ;; ;; http://www.rattlesnake.com/intro/Loading-Files.html ;; (setq load-path (cons "~/download/cflow/install/share/emacs/site-lisp" load-path)) ;;================================== ;; ChangeLog:2009-11-08 ;; The following is based on instructions from: ;; ;; http://www.gnu.org/software/cflow/manual/cflow.html#Emacs ;; (autoload 'cflow-mode "cflow-mode") (setq auto-mode-alist (append auto-mode-alist '(("\\.cflow$" . cflow-mode)))) ;;==================================