All pastes #33478 Raw Edit

Anonymous

public text v1 · immutable
#33478 ·published 2005-12-13 04:10 UTC
rendered paste body
; c-mode
(setq auto-mode-alist (append '(("\\.h$" . c++-mode)) auto-mode-alist))
(defun my-c-mode-common-hook ()
  (c-toggle-auto-hungry-state 1)
  (c-set-style "stroustrup")
  (define-key c-mode-base-map (kbd "RET") 'c-context-line-break)
  (define-key c-mode-base-map (kbd "M-o") 'switch-cpp-h)
  (define-key c-mode-base-map (kbd "C-SPC") 'senator-completion-menu-popup)
  (define-key c-mode-base-map (kbd "C-c ;") 'comment-region)
  (define-key c-mode-base-map (kbd "C-c :") 'my-uncomment-region)
  (semantic-default-c-setup)
  (turn-off-filladapt-mode)
)

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c-mode-hook 'my-c-mode-common-hook)
(add-hook 'c++-mode-hook 'my-c-mode-common-hook)
(add-hook 'c-initialization-hook 'my-c-mode-common-hook)

(defun my-uncomment-region ()
  (comment-region (region-beginning) (region-end) (quote (4)))
)


; cedet
(setq semantic-load-turn-useful-things-on t)
(load-file "~/projects/emacs-lisp/lisp/cedet-1.0beta2a/common/cedet.el")
(load-file "~/projects/emacs-lisp/lisp/cedet-1.0beta2a/semantic/semantic-load.el")
(setq semanticdb-project-roots
      (list "/home/anthony/projects/development/nanosmalltalk" "/usr/include"))

; eldoc -- intellisense for cedet
(require 'eldoc)


(defun switch-cpp-h ()
  "Switch to the corresponding .cpp, .c, .cc or .h file."
  (interactive)
  (let ((n (buffer-file-name))
        (c nil))
    (cond ((and (string-match "\\.h$" n)
                (progn (setq c (replace-match ".cpp" t t n)) (file-readable-p c)))
           (find-file c))
          ((and (string-match "\\.h$" n)
                (progn (setq c (replace-match ".cc" t t n)) (file-readable-p c)))
           (find-file c))
          ((and (string-match "\\.h$" n)
                (progn (setq c (replace-match ".c" t t n)) (file-readable-p c)))
           (find-file c))
          ((string-match "\\.h$" n)
           (error "%s has no existing .cc, .c or .cpp" n))
          ((string-match "\\.cpp$" n)
           (find-file (replace-match ".h" t t n)))
          ((string-match "\\.cc$" n)
           (find-file (replace-match ".h" t t n)))
          ((string-match "\\.c$" n)
           (find-file (replace-match ".h" t t n)))
          (t
           (error "%s is neither .h, .cc, .c or .cpp" n)))))