diff options
author | Kyle Meyer <kyle@kyleam.com> | 2018-08-11 23:49:51 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2018-08-17 23:23:49 -0400 |
commit | 68415befccf02b5b56da6b391bda988a4d930797 (patch) | |
tree | f4075d7b584df397dd0a627a8270318ce9f6b0bf | |
parent | 65b7991e516b8f6874d4d37f14ee13b0200e0680 (diff) | |
download | emacs.d-68415befccf02b5b56da6b391bda988a4d930797.tar.gz |
Add mode to override xref-find-definitions with helm-etags-select
-rw-r--r-- | init.el | 17 | ||||
-rw-r--r-- | lisp/km-helm.el | 13 |
2 files changed, 19 insertions, 11 deletions
@@ -1357,7 +1357,12 @@ (after 'helm-buffers (bind-keys :map helm-buffer-map ("C-c b" . km/helm-display-buffer-below) - ("C-c C-o" . km/helm-display-buffer)))) + ("C-c C-o" . km/helm-display-buffer))) + :config + (after 'elisp-mode + (add-hook 'emacs-lisp-mode-hook #'km/helm-maybe-override-xref)) + (after 'python + (add-hook 'python-mode-hook #'km/helm-maybe-override-xref))) (use-package helm-mode :diminish helm-mode @@ -1931,16 +1936,6 @@ (setq outline-level #'km/elisp-outline-level)) (add-hook 'emacs-lisp-mode-hook #'km/elisp-set-outline-vars) - (defun km/elisp-use-xref-etags-inside-git () - (when (and (executable-find "git") - (equal (with-temp-buffer - (call-process "git" nil t nil - "rev-parse" "--is-inside-work-tree") - (buffer-string)) - "true\n")) - (xref-etags-mode 1))) - (add-hook 'emacs-lisp-mode-hook #'km/elisp-use-xref-etags-inside-git) - ;; Modified from usepackage's issue #80. (defun km/imenu-add-use-package () (when (string= (buffer-file-name (buffer-base-buffer)) diff --git a/lisp/km-helm.el b/lisp/km-helm.el index 5295e2a..eda178b 100644 --- a/lisp/km-helm.el +++ b/lisp/km-helm.el @@ -68,5 +68,18 @@ (display-buffer (find-file-noselect f) '(display-buffer-below-selected))))))) +(defvar km/helm-etags-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "M-.") #'helm-etags-select) + map)) + +(define-minor-mode km/helm-etags-mode + "Override `xref-find-definitions' with `helm-etags-select'." + :keymap km/helm-etags-mode-map) + +(defun km/helm-maybe-override-xref () + (when (helm-etags-find-tag-file-directory default-directory) + (km/helm-etags-mode 1))) + (provide 'km-helm) ;;; km-helm.el ends here |