2015-06-05 08:37:06 +00:00
|
|
|
;;; packages.el --- cscope Layer packages File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2015-06-05 08:37:06 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(setq cscope-packages
|
|
|
|
'(
|
2017-07-03 07:52:54 +00:00
|
|
|
(helm-cscope :requires helm)
|
2016-05-30 02:39:21 +00:00
|
|
|
xcscope
|
|
|
|
))
|
2015-06-05 08:37:06 +00:00
|
|
|
|
|
|
|
(defun cscope/init-xcscope ()
|
|
|
|
(use-package xcscope
|
2015-07-24 02:20:25 +00:00
|
|
|
:commands (cscope-index-files cscope/run-pycscope)
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
;; for python projects, we don't want xcscope to rebuild the databse,
|
|
|
|
;; because it uses cscope instead of pycscope
|
|
|
|
(setq cscope-option-do-not-update-database t
|
|
|
|
cscope-display-cscope-buffer nil)
|
|
|
|
|
|
|
|
(defun cscope//safe-project-root ()
|
|
|
|
"Return project's root, or nil if not in a project."
|
|
|
|
(and (fboundp 'projectile-project-root)
|
|
|
|
(projectile-project-p)
|
|
|
|
(projectile-project-root)))
|
|
|
|
|
|
|
|
(defun cscope/run-pycscope (directory)
|
|
|
|
(interactive (list (file-name-as-directory
|
|
|
|
(read-directory-name "Run pycscope in directory: "
|
|
|
|
(cscope//safe-project-root)))))
|
|
|
|
(let ((default-directory directory))
|
|
|
|
(shell-command
|
2019-05-10 12:49:28 +00:00
|
|
|
(format "%s -R -f '%s'"
|
|
|
|
pycscope-binary
|
2015-07-24 02:20:25 +00:00
|
|
|
(expand-file-name "cscope.out" directory))))))))
|
2015-06-05 08:37:06 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun cscope/init-helm-cscope ()
|
|
|
|
(use-package helm-cscope
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-05-30 02:39:21 +00:00
|
|
|
:init
|
|
|
|
(defun spacemacs/setup-helm-cscope (mode)
|
|
|
|
"Setup `helm-cscope' for MODE"
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2016-11-07 18:28:18 +00:00
|
|
|
"g=" 'helm-cscope-find-assignments-to-this-symbol
|
2016-05-30 02:39:21 +00:00
|
|
|
"gc" 'helm-cscope-find-called-function
|
2017-03-29 22:37:56 +00:00
|
|
|
"gC" 'helm-cscope-find-calling-this-function
|
2016-05-30 02:39:21 +00:00
|
|
|
"gd" 'helm-cscope-find-global-definition
|
|
|
|
"ge" 'helm-cscope-find-egrep-pattern
|
|
|
|
"gf" 'helm-cscope-find-this-file
|
|
|
|
"gF" 'helm-cscope-find-files-including-file
|
|
|
|
"gr" 'helm-cscope-find-this-symbol
|
|
|
|
"gx" 'helm-cscope-find-this-text-string))
|
|
|
|
:config
|
|
|
|
(defadvice helm-cscope-find-this-symbol (before cscope/goto activate)
|
|
|
|
(evil--jumps-push))))
|