Skip to content

Commit

Permalink
add c++, yasnippet stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
chen bin committed Aug 31, 2011
1 parent 11fd85f commit dbc6dbd
Show file tree
Hide file tree
Showing 1,920 changed files with 477,136 additions and 1 deletion.
5 changes: 5 additions & 0 deletions init-better-registers.el
@@ -0,0 +1,5 @@
(require 'better-registers)
(better-registers-install-save-registers-hook)
(load better-registers-save-file)

(provide 'init-better-registers)
54 changes: 54 additions & 0 deletions init-cc-mode.el
@@ -0,0 +1,54 @@
;C/C++ SECTION
(defun my-c-mode-hook ()
(local-set-key "\M-f" 'c-forward-into-nomenclature)
(local-set-key "\M-b" 'c-backward-into-nomenclature)
(setq c-basic-offset 4)
(setq c-style-variables-are-local-p nil)
;give me NO newline automatically after electric expressions are entered
(setq c-auto-newline nil)

;if (0) becomes if (0)
; { {
; ; ;
; } }
(c-set-offset 'substatement-open 0)

;first arg of arglist to functions: tabbed in once
;(default was c-lineup-arglist-intro-after-paren)
(c-set-offset 'arglist-intro '+)

;second line of arglist to functions: tabbed in once
;(default was c-lineup-arglist)
(c-set-offset 'arglist-cont-nonempty '+)

;switch/case: make each case line indent from switch
(c-set-offset 'case-label '+)

;make the ENTER key indent next line properly
(local-set-key "\C-m" 'newline-and-indent)

;syntax-highlight aggressively
;(setq font-lock-support-mode 'lazy-lock-mode)
(setq lazy-lock-defer-contextually t)
(setq lazy-lock-defer-time 0)

;make DEL take all previous whitespace with it
(c-toggle-hungry-state 1)

;make open-braces after a case: statement indent to 0 (default was '+)
(c-set-offset 'statement-case-open 0)

;make a #define be left-aligned
(setq c-electric-pound-behavior (quote (alignleft)))

;do not impose restriction that all lines not top-level be indented at least
;1 (was imposed by gnu style by default)
(setq c-label-minimum-indentation 0)
(if (or *linux* *cygwin*)
(gtags-mode 1)
)
)
(add-hook 'c-mode-hook 'my-c-mode-hook)
(add-hook 'cc-mode-hook 'my-c-mode-hook)

(provide 'init-cc-mode)
51 changes: 51 additions & 0 deletions init-cedet.el
@@ -0,0 +1,51 @@
;load cedet now, emacs23' embedded cedet is now powerful enough
;@see http://appsintheopen.com/articles/1-setting-up-emacs- \
;for-rails-development/part/6-setting-up-the-emacs-code-browser
;TIPs:
; Having used ecb for a few year now, the only commands I ever use are:
; * Jump to the directory window CTRL-c . gd (ctrl and c together,
; release and press '.', release and press 'g' then 'd')
; * Jump to the history window CTRL-c . gh
; * Jump to the last window you were in CTRL-c . gl
; * Jump to the method window CTRL-c . gm
; * Jump to the first editor window CTRL-c . g1
; The directory browser can be controlled without using the mouse too ¨C
; just use the arrow keys and enter ¨C give it a go!
; NO embedded cedet becasue 'ecb' ask for latest cedet
(load-file "~/.emacs.d/site-lisp/cedet/common/cedet.el")
(setq semantic-load-turn-everything-on t)
; * This turns on which-func support (Plus all other code helpers)
; This is a minor mode which starts semantic-complete-analyze-inline during
; idle time.
; This has additional effect of showing list of completions in tooltip
; if you leave Emacs alone for too long.
; (global-semantic-idle-completions-mode 1)
; (global-semantic-idle-summary-mode 1)
(require 'semantic-sb nil t)
(require 'semanticdb nil t)

;; customisation of modes
(defun my-cedet-hook ()
(local-set-key "\C-c," 'semantic-ia-complete-symbol)
(local-set-key "\C-c." 'senator-complete-symbol)
(local-set-key "\C-c/" 'semantic-ia-complete-symbol-menu)
(local-set-key "\C-c>" 'semantic-complete-analyze-inline)
(local-set-key "\C-c=" 'semantic-decoration-include-visit)
(local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle)
)
(add-hook 'c-mode-common-hook 'my-cedet-hook)

(defun my-c-mode-cedet-hook ()
(local-set-key "." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert)
;(local-set-key "\C-ct" 'eassist-switch-h-cpp)
;(local-set-key "\C-xt" 'eassist-switch-h-cpp)
)
(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)

(setq-default semanticdb-default-save-directory "~/tmp/semantic")

(custom-set-variables '(semantic-idle-scheduler-idle-time 10))

(provide 'init-cedet)

5 changes: 5 additions & 0 deletions init-cmake-mode.el
@@ -0,0 +1,5 @@
(require 'cmake-mode)
(setq auto-mode-alist (append '(("CMakeLists\\.txt\\'" . cmake-mode))
'(("\\.cmake\\'" . cmake-mode))
auto-mode-alist))
(provide 'init-cmake-mode)
7 changes: 7 additions & 0 deletions init-cperl-mode.el
@@ -0,0 +1,7 @@
;; Use cperl-mode instead of the default perl-mode
(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))

(provide 'init-cperl-mode)
3 changes: 3 additions & 0 deletions init-csharp-mode.el
@@ -0,0 +1,3 @@
(require 'csharp-mode)
(setq auto-mode-alist (append '(("\\.cs$" . csharp-mode)) auto-mode-alist))
(provide 'init-csharp-mode)
5 changes: 5 additions & 0 deletions init-ecb.el
@@ -0,0 +1,5 @@
(load-library "ecb")
(global-set-key (kbd "C-x C-e") 'ecb-activate)
(global-set-key (kbd "C-x C-q") 'ecb-deactivate)

(provide 'init-ecb)
59 changes: 59 additions & 0 deletions init-emacs-w3m.el
@@ -0,0 +1,59 @@
(require 'w3m-load)
(setq w3m-coding-system 'utf-8
w3m-file-coding-system 'utf-8
w3m-file-name-coding-system 'utf-8
w3m-input-coding-system 'utf-8
w3m-output-coding-system 'utf-8
w3m-terminal-coding-system 'utf-8)
(setq w3m-use-cookies t)
(setq w3m-cookie-accept-bad-cookies t)
(setq w3m-home-page
(if (file-readable-p "~/html/home.html")
(concat "file://" (expand-file-name "~/html/home.html"))
"http://www.google.com.au"))

(setq w3m-use-toolbar t
;w3m-use-tab nil
w3m-key-binding 'info
)

(setq w3m-search-default-engine "g")
(eval-after-load "w3m-search" '(progn
; C-u S g RET <search term> RET
(add-to-list 'w3m-search-engine-alist '("g"
"http://www.google.com.au/search?hl=zh-CN&q=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("wz"
"http://zh.wikipedia.org/wiki/Special:Search?search=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("q"
"http://www.google.com.au/search?hl=en&q=%s+site:stackoverflow.com" utf-8))
(add-to-list 'w3m-search-engine-alist '("s"
"http://www.google.com.au/codesearch?q=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("b"
"http://blogsearch.google.com.au/blogsearch?q=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("w"
"http://en.wikipedia.org/wiki/Special:Search?search=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("d"
"http://dictionary.reference.com/search?q=%s" utf-8))
))

(setq w3m-command-arguments '("-F" "-cookie")
w3m-mailto-url-function 'compose-mail
browse-url-browser-function 'w3m
mm-text-html-renderer 'w3m)

(defun ted-delicious-url ()
"Bookmark this page with del.icio.us."
(interactive)
(w3m-goto-url
(concat "http://del.icio.us/redguardtoo?"
"url=" (w3m-url-encode-string w3m-current-url)
"&title=" (w3m-url-encode-string w3m-current-title))))
;bind this function to ‘a’, which is the normal w3m bookmark binding:
(eval-after-load "w3m" '(progn
(define-key w3m-info-like-map "A" 'ted-delicious-url)))

(require 'w3m-lnum)
(autoload 'w3m-link-numbering-mode "w3m-lnum" nil t)
(add-hook 'w3m-mode-hook 'w3m-link-numbering-mode)

(provide 'init-emacs-w3m)
4 changes: 4 additions & 0 deletions init-fill-column-indicator.el
@@ -0,0 +1,4 @@
(when (not *cygwin*)
(require 'fill-column-indicator)
)
(provide 'init-fill-column-indicator)
17 changes: 17 additions & 0 deletions init-gtags.el
@@ -0,0 +1,17 @@
(if (or *linux* *cygwin*)
(if (file-exists-p "/usr/share/emacs/site-lisp/gtags.el")
(load-file "/usr/share/emacs/site-lisp/gtags.el")
)
(add-hook 'gtags-mode-hook
(lambda()
(local-set-key "\M-t" 'gtags-find-tag) ; find a tag, definition
(local-set-key "\M-r" 'gtags-find-rtag) ; find a tag reference
(local-set-key "\C-t" 'gtags-pop-stack)
(local-set-key "\M-." 'gtags-find-symbol)
;\M-, is used by search in dired
(local-set-key "\M-m" 'gtags-find-file)
(local-set-key "\M-/" 'gtags-find-pattern)
(local-set-key "\M-;" 'gtags-find-with-grep)))
)

(provide 'init-gtags)
24 changes: 24 additions & 0 deletions init-linum-mode.el
@@ -0,0 +1,24 @@
(when *emacs23*
(global-linum-mode t)

;@see http://www.emacswiki.org/emacs-en/GnusEncryptedAuthInfo
(require 'epa-file) (epa-file-enable)

;http://stackoverflow.com/questions/3875213/ \
;turning-on-linum-mode-when-in-python-c-mode
(setq linum-mode-inhibit-modes-list '(eshell-mode
shell-mode
erc-mode
jabber-roster-mode
jabber-chat-mode
gnus-group-mode
w3m-mode
gnus-summary-mode
gnus-article-mode))
(defadvice linum-on (around linum-on-inhibit-for-modes)
"Stop the load of linum-mode for some major modes."
(unless (member major-mode linum-mode-inhibit-modes-list)
ad-do-it))
(ad-activate 'linum-on)
)
(provide 'init-linum-mode)
15 changes: 15 additions & 0 deletions init-org2blog.el
@@ -0,0 +1,15 @@
; @see http://blog.nethazard.net/post-to-wordpress-blogs-with-emacs-org-mode/
(require 'org2blog-autoloads)
; setup proxy
;(setq url-proxy-services '(("http" . "127.0.0.1:8580"))) ; fr*egate
;(setq url-proxy-services '(("http" . "127.0.0.1:8000"))) ; gae
(setq org2blog/wp-blog-alist
'(("wp"
:url "http://emacsguru.wordpress.com/xmlrpc.php"
:username "emacsguru"
:default-title ""
:default-categories ("Linux")
:tags-as-categories nil
)
))
(provide 'init-org2blog)
8 changes: 8 additions & 0 deletions init-yari.el
@@ -0,0 +1,8 @@
; override `better register` which also uses [f1]
; You can use C-u M-x yari to reload all completion targets.
(require 'yari)
(defun ri-bind-key ()
(local-set-key [f1] 'yari-anything))
(add-hook 'ruby-mode-hook 'ri-bind-key)

(provide 'init-yari)
5 changes: 5 additions & 0 deletions init-yasnippet.el
@@ -0,0 +1,5 @@
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/site-lisp/yasnippet/snippets")

(provide 'init-yasnippet)
21 changes: 20 additions & 1 deletion init.el
Expand Up @@ -11,6 +11,13 @@
(setq *is-a-mac* (eq system-type 'darwin))
(setq *is-carbon-emacs* (and *is-a-mac* (eq window-system 'mac)))
(setq *is-cocoa-emacs* (and *is-a-mac* (eq window-system 'ns)))
(defconst *win32* (eq system-type 'windows-nt) "Windows?")
(defconst *cygwin* (eq system-type 'cygwin) "Cygwin?")
(defconst *linux* (or (eq system-type 'gnu/linux) (eq system-type 'linux)) "Linux?")
(defconst *unix* (or *linux* (eq system-type 'usg-unix-v) (eq system-type 'berkeley-unix)) "Unix")
(defconst *linux-x* (and window-system *linux*) "X on Linux")
(defconst *xemacs* (featurep 'xemacs) "Are we running XEmacs?")
(defconst *emacs23* (and (not *xemacs*) (or (= emacs-major-version 23))) ">=Emacs23")

;;----------------------------------------------------------------------------
;; Make elisp more civilised
Expand Down Expand Up @@ -98,6 +105,19 @@
;; Finally set up themes, after most possibly-customised faces have been defined
(require 'init-themes)
;; Chinese inut method
(require 'init-org2blog)
(require 'init-fill-column-indicator)
(require 'init-yasnippet)
(require 'init-better-registers)
(require 'init-yari)
(require 'init-gtags)
(require 'init-cc-mode)
(require 'init-cedet)
(require 'init-ecb)
(require 'init-cmake-mode)
(require 'init-csharp-mode)
(require 'init-linum-mode)
(require 'init-emacs-w3m)
(require 'init-eim)

;;----------------------------------------------------------------------------
Expand All @@ -120,7 +140,6 @@
(load custom-file)



;;----------------------------------------------------------------------------
;; Locales (setting them earlier in this file doesn't work in X)
;;----------------------------------------------------------------------------
Expand Down

0 comments on commit dbc6dbd

Please sign in to comment.