From f2fe0fbbc3bd647e1e319b5982f95c0b00d2a4e1 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Mon, 20 Apr 2020 13:17:14 -0700 Subject: [PATCH] Update emacs to support C/C++ dev --- dotfiles/bash/scripts/cgen.sh | 6 +++++- dotfiles/emacs.d/init.el | 12 ++++++++++++ dotfiles/emacs.d/package.el | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dotfiles/bash/scripts/cgen.sh b/dotfiles/bash/scripts/cgen.sh index 0b1ff7b..f10404d 100755 --- a/dotfiles/bash/scripts/cgen.sh +++ b/dotfiles/bash/scripts/cgen.sh @@ -5,7 +5,11 @@ cmake_version=$2 c_standard=$3 # Finds the directory of this script -script_dir=$(cd "$( dirname "`readlink -f ${BASH_SOURCE[0]}`")" && pwd) +if [[ "$OS_TYPE" == "linux-gnu" ]]; then + script_dir=$(cd "$( dirname "`readlink -f ${BASH_SOURCE[0]}`")" && pwd) +else + script_dir=$(cd "$( dirname "`greadlink -f ${BASH_SOURCE[0]}`")" && pwd) +fi if [ -z $name ] then diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index d977cd0..89ccff2 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -156,6 +156,9 @@ There are two things you can do about this warning: (add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode) (add-hook 'scheme-mode-hook #'enable-paredit-mode) +(add-hook 'c-mode-hook 'counsel-gtags-mode) +(add-hook 'c++-mode-hook 'counsel-gtags-mode) + (require 'rainbow-delimiters) (add-hook 'clojure-mode-hook 'rainbow-delimiters-mode) @@ -208,6 +211,15 @@ There are two things you can do about this warning: ;; Press in lisp mode to evaluate the current defun in SLIME. (define-key lisp-mode-map (kbd "") 'slime-eval-defun) +;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +(with-eval-after-load 'counsel-gtags + (define-key counsel-gtags-mode-map (kbd "M-t") 'counsel-gtags-find-definition) + (define-key counsel-gtags-mode-map (kbd "M-r") 'counsel-gtags-find-reference) + (define-key counsel-gtags-mode-map (kbd "M-s") 'counsel-gtags-find-symbol) + (define-key counsel-gtags-mode-map (kbd "M-,") 'counsel-gtags-go-backward)) + ;;-------------------------------------------------------------------------------------- ;; Install and load Packages ;;-------------------------------------------------------------------------------------- diff --git a/dotfiles/emacs.d/package.el b/dotfiles/emacs.d/package.el index 1c57d8b..f1d70f8 100644 --- a/dotfiles/emacs.d/package.el +++ b/dotfiles/emacs.d/package.el @@ -69,6 +69,7 @@ grizzl smex projectile + counsel-gtags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; )