summaryrefslogtreecommitdiffstats
path: root/lisp/ravi-init-cpp.el
diff options
context:
space:
mode:
authorRavi R Kiran <aine.marina@gmail.com>2015-11-04 05:18:45 (GMT)
committerRavi R Kiran <aine.marina@gmail.com>2015-11-04 05:18:45 (GMT)
commit207603d7d86b12a93ffd4391464188cb299d7dde (patch)
tree011ff1492f8e80e95e9b08da59afaf335fc6bcea /lisp/ravi-init-cpp.el
parent3c28362f7ff0b374ffa92e4402b0ee4791f42863 (diff)
downloaddotemacs-207603d7d86b12a93ffd4391464188cb299d7dde.zip
dotemacs-207603d7d86b12a93ffd4391464188cb299d7dde.tar.gz
dotemacs-207603d7d86b12a93ffd4391464188cb299d7dde.tar.bz2
Malinka for feeding rtags
Diffstat (limited to 'lisp/ravi-init-cpp.el')
-rw-r--r--lisp/ravi-init-cpp.el52
1 files changed, 52 insertions, 0 deletions
diff --git a/lisp/ravi-init-cpp.el b/lisp/ravi-init-cpp.el
index 47e587e..684db1f 100644
--- a/lisp/ravi-init-cpp.el
+++ b/lisp/ravi-init-cpp.el
@@ -489,6 +489,58 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named
(bind-key "<f6>" 'hydra-cextra/body c-mode-base-map))
(bind-key "<M-f8>" 'compile-dwim c-mode-base-map)
+
+ ;; Enable Malinka
+ (use-package malinka
+ :config
+ (progn
+ ;; At this point, malinka has been loaded, so f.el has also
+ ;; been loaded and is ready for use.
+ (defun ravi/get-project-name-and-build-dir (proj-root-dir)
+ (interactive "D")
+ (let* ((proj-parent (and (f-exists? (f-dirname proj-root-dir))
+ (f-dirname proj-root-dir)))
+ (proj-build (and proj-parent (f-exists? (f-join proj-parent "build"))
+ (f-join proj-parent "build")))
+ (proj-root-dir-last (car (last (f-split proj-root-dir))))
+ (proj-name (if (and (s-equals? proj-root-dir-last "source")
+ proj-parent)
+ (car (last (f-split proj-parent)))
+ proj-root-dir-last)))
+ (list proj-name proj-build)))
+
+ (defun ravi/find-current-project ()
+ (interactive)
+ (unless (or (not (buffer-file-name)) (malinka--file-belongs-to-project (buffer-file-name)))
+ (message "Searching for project for %s" (buffer-file-name))
+ (let* ((proj-root (or (and (boundp 'ravi-project-root) ravi-project-root)
+ (malinka--project-detect-root)))
+ (proj-name-and-build-dir (and proj-root (ravi/get-project-name-and-build-dir proj-root)))
+ (proj-name (or (and (boundp 'ravi-project-name) ravi-project-name)
+ (and proj-root (nth 0 proj-name-and-build-dir))))
+ (proj-build-dir (or (and (boundp 'ravi-project-build-dir) ravi-project-build-dir)
+ (and proj-root (nth 1 proj-name-and-build-dir))))
+ (proj-compilation-database (and (boundp 'ravi-project-compilation-database)
+ ravi-project-compilation-database))
+ (proj-configure-cmd (or (and (boundp 'ravi-project-configure-cmd)
+ ravi-project-configure-cmd)
+ (and proj-root
+ (f-exists? (f-join proj-root "CMakeLists.txt"))
+ "cmake"))))
+ (when proj-root
+ (message "%s %s %s %s" proj-root proj-name proj-build-dir proj-compilation-database)
+ (malinka-define-project :name proj-name
+ :root-directory proj-root
+ :build-directory proj-build-dir
+ :configure-cmd proj-configure-cmd)))))
+
+ (defun ravi/setup-malinka ()
+ (interactive)
+ (malinka-mode 1)
+ (ravi/find-current-project))
+ (add-hook 'c-mode-common-hook 'ravi/setup-malinka)
+ )
+ :ensure t)
)
)