From 1919b7d26e819fcbc4d6e5285f08f4f3ba02916f Mon Sep 17 00:00:00 2001 From: Daniel Bergey Date: Sat, 14 May 2016 21:56:55 -0400 Subject: [PATCH 1/3] fallback to tags if there is no haskell-session The function name & docs suggest this is the intended behavior. `haskell-mode-find-def` errors if there is no session, so we need to only call it if there is a session. closes https://github.com/haskell/haskell-mode/issues/1180 --- haskell-commands.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/haskell-commands.el b/haskell-commands.el index d2d798510..57c60c897 100644 --- a/haskell-commands.el +++ b/haskell-commands.el @@ -350,13 +350,13 @@ If the definition or tag is found, the location from which you jumped will be pushed onto `xref--marker-ring', so you can return to that position with `xref-pop-marker-stack'." (interactive "P") - (let ((initial-loc (point-marker)) - (loc (haskell-mode-find-def (haskell-ident-at-point)))) - (if (not loc) - (call-interactively 'haskell-mode-tag-find) - (haskell-mode-handle-generic-loc loc) - (unless (equal initial-loc (point-marker)) - (xref-push-marker-stack initial-loc))))) + (if (haskell-session-maybe) + (let ((initial-loc (point-marker)) + (loc (haskell-mode-find-def (haskell-ident-at-point)))) + (haskell-mode-handle-generic-loc loc) + (unless (equal initial-loc (point-marker)) + (xref-push-marker-stack initial-loc))) + (call-interactively 'haskell-mode-tag-find))) ;;;###autoload (defun haskell-mode-goto-loc () From c747b50825e9b33a529ce912dd858b98d224fa18 Mon Sep 17 00:00:00 2001 From: Daniel Bergey Date: Sat, 14 May 2016 21:59:08 -0400 Subject: [PATCH 2/3] call `hasktags` without `find` In my tests, calling hasktags is faster, and has better rules of which files & directories to search. More importantly, it produces a more accurate tags table. For example, the old version links some types to functions with the same name (in lowercase). --- haskell-cabal.el | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/haskell-cabal.el b/haskell-cabal.el index 5416ea643..e6bc7dc01 100644 --- a/haskell-cabal.el +++ b/haskell-cabal.el @@ -1097,26 +1097,7 @@ recursively avoiding visiting unnecessary heavy directories like cabal-install, stack, etc and passes list of found files to Hasktags." (if (eq system-type 'windows-nt) (format "hasktags --output=\"%s\\TAGS\" -x -e \"%s\"" dir dir) - (format "cd %s && %s | %s" - dir - (concat "find . " - "-type d \\( " - "-path ./.git " - "-o -path ./.svn " - "-o -path ./_darcs " - "-o -path ./.stack-work " - "-o -path ./dist " - "-o -path ./.cabal-sandbox " - "\\) -prune " - "-o -type f \\( " - "-name '*.hs' " - "-or -name '*.lhs' " - "-or -name '*.hsc' " - "\\) -not \\( " - "-name '#*' " - "-or -name '.*' " - "\\) -print0") - "xargs -0 hasktags -e -x"))) + (format "cd %s && hasktags . -e -x" dir))) (provide 'haskell-cabal) ;;; haskell-cabal.el ends here From 60ff51ae4b24294a215910649520fa02a2b2aadd Mon Sep 17 00:00:00 2001 From: Daniel Bergey Date: Sun, 15 May 2016 08:32:10 -0400 Subject: [PATCH 3/3] bind M-. to haskell-mode-tag-find in haskell-mode `interactive-haskell-mode` has `M-.` bound to `haskell-mode-jump-to-def-or-tag`. The emacs default `find-tag` does not work in `haskell-mode`. This patch allows users of `haskell-mode` without `interactive-haskell-mode` to use tags. The binding is overridden by the `interactive-haskell-mode` map, if that minor mode is active. --- haskell-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/haskell-mode.el b/haskell-mode.el index 917581155..2b129e0a7 100644 --- a/haskell-mode.el +++ b/haskell-mode.el @@ -207,6 +207,7 @@ be set to the preferred literate style." (define-key map (kbd "C-c C-t") 'haskell-mode-enable-process-minor-mode) (define-key map (kbd "C-c C-i") 'haskell-mode-enable-process-minor-mode) (define-key map (kbd "C-c C-s") 'haskell-mode-toggle-scc-at-point) + (define-key map (kbd "M-.") 'haskell-mode-tag-find) map) "Keymap used in `haskell-mode'.")