Advertisement
Guest User

Untitled

a guest
Nov 29th, 2011
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 9.99 KB | None | 0 0
  1. (server-start)
  2. (add-to-list 'load-path "~/.emacs.d/")
  3. (load-file "~/.emacs.d/cedet-1.0/common/cedet.el")
  4.  
  5. (semantic-load-enable-excessive-code-helpers)
  6. ;;(semantic-load-enable-semantic-debugging-helpers)
  7.  
  8. (setq senator-minor-mode-name "SN")
  9. (setq semantic-imenu-auto-rebuild-directory-indexes nil)
  10. (global-srecode-minor-mode 1)
  11. (global-semantic-mru-bookmark-mode 1)
  12.  
  13. (require 'auto-complete)
  14. (global-auto-complete-mode t)
  15. ;; (ac-flyspell-workaround)
  16.  
  17. (setq path-to-ctags "/usr/local/share/ctags/TAGS") ;; <- your ctags path here
  18.   (defun create-tags (dir-name)
  19.     "Create tags file."
  20.     (interactive "DDirectory: ")
  21.     (shell-command
  22.      (format "%s -f %s/TAGS -e -R %s" path-to-ctags dir-name (directory-file-name dir-name)))
  23. )
  24.  
  25. (require 'semantic-decorate-include)
  26.  
  27. ;; gcc setup
  28. (require 'semantic-gcc)
  29.  
  30. ;; smart complitions
  31. (require 'semantic-ia)
  32.  
  33. (semantic-add-system-include "/usr/include/pcl-1.3/" 'c++-mode)
  34. (semantic-add-system-include "/usr/include/eigen3/" 'c++-mode)
  35.  
  36. (setq-mode-local c-mode semanticdb-find-default-throttle
  37.                  '(project unloaded system recursive))
  38. (setq-mode-local c++-mode semanticdb-find-default-throttle
  39.                  '(project unloaded system recursive))
  40. (setq-mode-local erlang-mode semanticdb-find-default-throttle
  41.                  '(project unloaded system recursive))
  42.  
  43. (require 'eassist)
  44.  
  45. ;; customisation of modes
  46. (defun alexott/cedet-hook ()
  47.   (local-set-key [(control return)] 'semantic-ia-complete-symbol-menu)
  48.   (local-set-key "\C-c?" 'semantic-ia-complete-symbol)
  49.   ;;
  50.   (local-set-key "\C-c>" 'semantic-complete-analyze-inline)
  51.   (local-set-key "\C-c=" 'semantic-decoration-include-visit)
  52.  
  53.   (local-set-key "\C-cj" 'semantic-ia-fast-jump)
  54.   (local-set-key "\C-cq" 'semantic-ia-show-doc)
  55.   (local-set-key "\C-cs" 'semantic-ia-show-summary)
  56.   (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle)
  57.   )
  58. ;; (add-hook 'semantic-init-hooks 'alexott/cedet-hook)
  59. (add-hook 'c-mode-common-hook 'alexott/cedet-hook)
  60. (add-hook 'lisp-mode-hook 'alexott/cedet-hook)
  61. (add-hook 'scheme-mode-hook 'alexott/cedet-hook)
  62. (add-hook 'emacs-lisp-mode-hook 'alexott/cedet-hook)
  63. (add-hook 'erlang-mode-hook 'alexott/cedet-hook)
  64.  
  65. (defun alexott/c-mode-cedet-hook ()
  66.  ;; (local-set-key "." 'semantic-complete-self-insert)
  67.  ;; (local-set-key ">" 'semantic-complete-self-insert)
  68.   (local-set-key "\C-ct" 'eassist-switch-h-cpp)
  69.   (local-set-key "\C-xt" 'eassist-switch-h-cpp)
  70.   (local-set-key "\C-ce" 'eassist-list-methods)
  71.   (local-set-key "\C-c\C-r" 'semantic-symref)
  72.   )
  73. (add-hook 'c-mode-common-hook 'alexott/c-mode-cedet-hook)
  74.  
  75. ;; hooks, specific for semantic
  76. (defun alexott/semantic-hook ()
  77. ;; (semantic-tag-folding-mode 1)
  78.   (imenu-add-to-menubar "TAGS")
  79.  )
  80. (add-hook 'semantic-init-hooks 'alexott/semantic-hook)
  81.  
  82. (custom-set-variables
  83.   ;; custom-set-variables was added by Custom.
  84.   ;; If you edit it by hand, you could mess it up, so be careful.
  85.   ;; Your init file should contain only one such instance.
  86.   ;; If there is more than one, they won't work right.
  87.  '(fancy-splash-image nil)
  88.  '(global-semantic-show-parser-state-mode t nil (semantic-util-modes))
  89.  '(global-semantic-tag-folding-mode t nil (semantic-util-modes))
  90.  '(inhibit-startup-screen t)
  91.  '(semantic-self-insert-show-completion-function (lambda nil (semantic-ia-complete-symbol-menu (point)))))
  92.  
  93. ;; gnu global support
  94. (require 'semanticdb-global)
  95. (semanticdb-enable-gnu-global-databases 'c-mode)
  96. (semanticdb-enable-gnu-global-databases 'c++-mode)
  97.  
  98. ;; ctags
  99. ;; (require 'semanticdb-ectag)
  100. ;; (defvar semantic-ectag-program "/usr/bin/ctags-exuberant")
  101. ;; (semantic-load-enable-primary-exuberent-ctags-support)
  102.  
  103. ;;
  104. (semantic-add-system-include "/usr/include/pcl-1.3/" 'c++-mode)
  105.  
  106. (defun recur-list-files (dir re)
  107.   "Returns list of files in directory matching to given regex"
  108.   (when (file-accessible-directory-p dir)
  109.     (let ((files (directory-files dir t))
  110.           matched)
  111.       (dolist (file files matched)
  112.         (let ((fname (file-name-nondirectory file)))
  113.           (cond
  114.            ((or (string= fname ".")
  115.                 (string= fname "..")) nil)
  116.            ((and (file-regular-p file)
  117.                  (string-match re fname))
  118.             (setq matched (cons file matched)))
  119.            ((file-directory-p file)
  120.             (let ((tfiles (recur-list-files file re)))
  121.               (when tfiles (setq matched (append matched tfiles)))))))))))
  122.  
  123. (defun c++-setup-boost (boost-root)
  124.   (when (file-accessible-directory-p boost-root)
  125.     (let ((cfiles (recur-list-files boost-root "\\(config\\|user\\)\\.hpp")))
  126.       (dolist (file cfiles)
  127.         (add-to-list 'semantic-lex-c-preprocessor-symbol-file file)))))
  128.  
  129.  
  130. ;;
  131. ;;(global-semantic-idle-tag-highlight-mode 1)
  132.  
  133. ;;; ede customization
  134. (require 'semantic-lex-spp)
  135. (global-ede-mode t)
  136. (ede-enable-generic-projects)
  137.  
  138. ;; maven-based projects
  139. ;;(ede-maven2-project "clojure-hadoop" :file "~/projects/clojure-hadoop/pom.xml")
  140. ;; cpp-tests project definition
  141. (setq cpp-tests-project
  142.       (ede-cpp-root-project "cpp-tests"
  143.                             :file "~/projects/lang-exp/cpp/CMakeLists.txt"
  144.                             :system-include-path '("/usr/include/"
  145.                                                    boost-base-directory)
  146.                             :local-variables (list
  147.                                               (cons 'compile-command 'alexott/gen-cmake-debug-compile-string)
  148.                                               )
  149.                             ))
  150.  
  151. (defun alexott/ede-get-local-var (fname var)
  152.   "fetch given variable var from :local-variables of project of file fname"
  153.   (let* ((current-dir (file-name-directory fname))
  154.          (prj (ede-current-project current-dir)))
  155.     (when prj
  156.       (let* ((ov (oref prj local-variables))
  157.             (lst (assoc var ov)))
  158.         (when lst
  159.           (cdr lst))))))
  160.  
  161. ;; setup compile package
  162. ;; TODO: allow to specify function as compile-command
  163. (require 'compile)
  164. (setq compilation-disable-input nil)
  165. (setq compilation-scroll-output t)
  166. (setq mode-compile-always-save-buffer-p t)
  167.  
  168. (defun alexott/compile ()
  169.   "Saves all unsaved buffers, and runs 'compile'."
  170.   (interactive)
  171.   (save-some-buffers t)
  172.   (let* ((r (alexott/ede-get-local-var
  173.              (or (buffer-file-name (current-buffer)) default-directory)
  174.              'compile-command))
  175.          (cmd (if (functionp r) (funcall r) r)))
  176. ;;    (message "AA: %s" cmd)
  177.     (set (make-local-variable 'compile-command) (or cmd compile-command))
  178.     (compile compile-command)))
  179.  
  180. (global-set-key [f9] 'alexott/compile)
  181.  
  182. ;;
  183. (defun alexott/gen-std-compile-string ()
  184.   "Generates compile string for compiling CMake project in debug mode"
  185.   (let* ((current-dir (file-name-directory
  186.                        (or (buffer-file-name (current-buffer)) default-directory)))
  187.          (prj (ede-current-project current-dir))
  188.          (root-dir (ede-project-root-directory prj))
  189.          )
  190.     (concat "cd " root-dir "; make -j2")))
  191.  
  192. ;;
  193. (defun alexott/gen-cmake-debug-compile-string ()
  194.   "Generates compile string for compiling CMake project in debug mode"
  195.   (let* ((current-dir (file-name-directory
  196.                        (or (buffer-file-name (current-buffer)) default-directory)))
  197.          (prj (ede-current-project current-dir))
  198.          (root-dir (ede-project-root-directory prj))
  199.          (subdir "")
  200.          )
  201.     (when (string-match root-dir current-dir)
  202.       (setf subdir (substring current-dir (match-end 0))))
  203.     (concat "cd " root-dir "Debug/" "; make -j3")))
  204.  
  205. (custom-set-faces
  206.   ;; custom-set-faces was added by Custom.
  207.   ;; If you edit it by hand, you could mess it up, so be careful.
  208.   ;; Your init file should contain only one such instance.
  209.   ;; If there is more than one, they won't work right.
  210.  '(linum ((t (:inherit (shadow default)))))
  211.  '(scroll-bar ((t nil))))
  212.  
  213. (require 'color-theme)
  214. (color-theme-initialize)
  215. (color-theme-subtle-hacker)
  216. (global-set-key [?\M-1] 'tmm-menubar)
  217. (column-number-mode t)
  218.  
  219. ;; Python stuff starts here!
  220. (setq python-python-command "ipython")
  221. (load-file "~/.emacs.d/ipython.el")
  222. (load-file "~/.emacs.d/anything.el")
  223. (load-file "~/.emacs.d/anything-ipython.el")
  224. (load-file "~/.emacs.d/anything-show-completion.el")
  225.  
  226. (require 'python-mode)
  227. (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
  228.  
  229. (require 'ipython)
  230.  
  231. (require 'anything)
  232. (require 'anything-ipython)
  233. (when (require 'anything-show-completion nil t)
  234.    (use-anything-show-completion 'anything-ipython-complete
  235.                                  '(length initial-pattern)))
  236. (require 'comint)
  237. (define-key comint-mode-map (kbd "M-") 'comint-next-input)
  238. (define-key comint-mode-map (kbd "M-") 'comint-previous-input)
  239. (define-key comint-mode-map [down] 'comint-next-matching-input-from-input)
  240. (define-key comint-mode-map [up] 'comint-previous-matching-input-from-input)
  241.  
  242. (setq pylookup-dir "~/.emacs.d/pylookup/")
  243. (add-to-list 'load-path pylookup-dir)
  244. ;; load pylookup when compile time
  245. (eval-when-compile (require 'pylookup))
  246.  
  247. ;; set executable file and db file
  248. (setq pylookup-program (concat pylookup-dir "/pylookup.py"))
  249. (setq pylookup-db-file (concat pylookup-dir "/pylookup.db"))
  250.  
  251. ;; to speedup, just load it on demand
  252. (autoload 'pylookup-lookup "pylookup"
  253.   "Lookup SEARCH-TERM in the Python HTML indexes." t)
  254. (autoload 'pylookup-update "pylookup"
  255.   "Run pylookup-update and create the database at `pylookup-db-file'." t)
  256.  
  257. (setq TeX-auto-save t)
  258. (setq TeX-parse-self t)
  259. (setq-default TeX-master nil)
  260.  
  261. (tool-bar-mode -1)
  262. (global-linum-mode 1)
  263.  
  264. ;; TeX stuff
  265. (load "auctex.el" nil t t)
  266. (load "preview-latex.el" nil t t)
  267.  
  268. ;; (require 'ac-math)
  269. ;; (add-to-list 'ac-modes 'latex-mode)   ; make auto-complete aware of {{{latex-mode}}}
  270. ;; (defun ac-latex-mode-setup ()         ; add ac-sources to default ac-sources
  271. ;;   (setq ac-sources
  272. ;;      (append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands)
  273. ;;                ac-sources)
  274. ;;      (ac-flyspell-workaround)
  275. ;;      (flyspell-mode t)
  276. ;;      )
  277. ;; )
  278. ;; (add-hook 'LaTeX-mode-hook 'ac-latex-mode-setup)
  279.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement