Hook semantic is to be used with run-hooks API and run all hooks sequentially, jump list semantic is different since the running functions are not guaranteed to be executed so we prefer using regular list API to manage jump-lists.
66 lines
2.3 KiB
EmacsLisp
66 lines
2.3 KiB
EmacsLisp
;;; funcs.el --- gtags functions File
|
|
;;
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
|
;;
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
;;
|
|
;; This file is not part of GNU Emacs.
|
|
;;
|
|
;;; License: GPLv3
|
|
|
|
(defun helm-gtags-dwim-other-window ()
|
|
"helm-gtags-dwim in the other window"
|
|
(interactive)
|
|
(let ((helm-gtags--use-otherwin t)
|
|
(split-height-threshold nil)
|
|
(split-width-threshold 140))
|
|
(helm-gtags-dwim)))
|
|
|
|
(defun spacemacs/helm-gtags-maybe-dwim ()
|
|
"Runs `helm-gtags-dwim' if `gtags-enable-by-default' is on.
|
|
Otherwise does nothing."
|
|
(interactive)
|
|
(when gtags-enable-by-default
|
|
(call-interactively 'helm-gtags-dwim)))
|
|
|
|
(defun spacemacs/helm-gtags-define-keys-for-mode (mode)
|
|
"Define key bindings for the specific MODE."
|
|
(when (fboundp mode)
|
|
;; The functionality of `helm-gtags-mode' is pretty much entirely superseded
|
|
;; by `ggtags-mode', so we don't add this hook
|
|
;; (let ((hook (intern (format "%S-hook" mode))))
|
|
;; (add-hook hook 'helm-gtags-mode))
|
|
|
|
;; `helm-gtags-dwim' is added to the end of the mode-specific jump handlers
|
|
;; Some modes have more sophisticated jump handlers that go to the beginning
|
|
;; It might be possible to add `helm-gtags-dwim' instead to the default
|
|
;; handlers, if it does a reasonable job in ALL modes.
|
|
(let ((jumpl (intern (format "spacemacs-jump-handlers-%S" mode))))
|
|
(add-to-list jumpl 'spacemacs/helm-gtags-maybe-dwim 'append))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
"gc" 'helm-gtags-create-tags
|
|
"gd" 'helm-gtags-find-tag
|
|
"gD" 'helm-gtags-find-tag-other-window
|
|
"gf" 'helm-gtags-select-path
|
|
"gG" 'helm-gtags-dwim-other-window
|
|
"gi" 'helm-gtags-tags-in-this-function
|
|
"gl" 'helm-gtags-parse-file
|
|
"gn" 'helm-gtags-next-history
|
|
"gp" 'helm-gtags-previous-history
|
|
"gr" 'helm-gtags-find-rtag
|
|
"gR" 'helm-gtags-resume
|
|
"gs" 'helm-gtags-select
|
|
"gS" 'helm-gtags-show-stack
|
|
"gu" 'helm-gtags-update-tags)))
|
|
|
|
(defun spacemacs/ggtags-mode-enable ()
|
|
"Enable ggtags and eldoc mode.
|
|
|
|
For eldoc, ggtags advises the eldoc function at the lowest priority
|
|
so that if the major mode has better support it will use it first."
|
|
(when gtags-enable-by-default
|
|
(ggtags-mode 1)
|
|
(eldoc-mode 1)))
|