summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2018-08-11 23:49:51 -0400
committerKyle Meyer <kyle@kyleam.com>2018-08-17 23:23:49 -0400
commit68415befccf02b5b56da6b391bda988a4d930797 (patch)
treef4075d7b584df397dd0a627a8270318ce9f6b0bf
parent65b7991e516b8f6874d4d37f14ee13b0200e0680 (diff)
downloademacs.d-68415befccf02b5b56da6b391bda988a4d930797.tar.gz
Add mode to override xref-find-definitions with helm-etags-select
-rw-r--r--init.el17
-rw-r--r--lisp/km-helm.el13
2 files changed, 19 insertions, 11 deletions
diff --git a/init.el b/init.el
index 700f3b8..3317dc4 100644
--- a/init.el
+++ b/init.el
@@ -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