From 869a85a46b08bc88fde9c244fa8df47fe3f0f0c0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 26 Dec 2017 23:39:21 -0500 Subject: [PATCH] lang/cc: new command +cc/reload-compile-commands #305 --- modules/lang/cc/autoload.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/lang/cc/autoload.el b/modules/lang/cc/autoload.el index 046ed54db..d41c34faa 100644 --- a/modules/lang/cc/autoload.el +++ b/modules/lang/cc/autoload.el @@ -1,5 +1,24 @@ ;;; lang/cc/autoload.el -*- lexical-binding: t; -*- +;;;###autoload +(defun +cc/reload-compile-commands (&optional force-p) + "Reload the current project's compile_commands.json file." + (interactive "P") + (unless (memq major-mode '(c-mode c++-mode objc-mode)) + (user-error "Not a C/C++/ObjC buffer")) + (unless (doom-project-has! "compile_commands.json") + (user-error "No compile_commands.json file")) + ;; first rtag + (when (and (featurep 'rtags) + rtags-enabled + (executable-find "rc")) + (with-temp-buffer + (message "Reloaded compile commands for rtags daemon") + (rtags-call-rc :silent t "-J" (doom-project-root)))) + ;; then irony + (when (and (featurep 'irony) irony-mode) + (+cc|irony-init-compile-options))) + ;;;###autoload (defun +cc*align-lambda-arglist (orig-fun &rest args) "Improve indentation of continued C++11 lambda function opened as argument."