From 89864775745cc5763fb86c263958abe9ea278c4a Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Thu, 12 Feb 2015 21:13:26 +0100 Subject: [PATCH 1/3] Fixed #459 by applying the @vonavi's patch --- haskell-commands.el | 17 ++++++++++------- inf-haskell.el | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/haskell-commands.el b/haskell-commands.el index d507ec625..97e1acb2d 100644 --- a/haskell-commands.el +++ b/haskell-commands.el @@ -18,6 +18,7 @@ ;;; Code: (require 'cl-lib) +(require 'xref) (require 'haskell-process) (require 'haskell-font-lock) (require 'haskell-interactive-mode) @@ -354,10 +355,9 @@ jump to the tag. Remember: If GHCi is busy doing something, this will delay, but it will always be accurate, in contrast to tags, which always work but are not always accurate. - -If the definition or tag is found, the location from which you -jumped will be pushed onto `find-tag-marker-ring', so you can -return to that position with `pop-tag-mark'." +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)))) @@ -365,8 +365,11 @@ return to that position with `pop-tag-mark'." (haskell-mode-handle-generic-loc loc) (call-interactively 'haskell-mode-tag-find)) (unless (equal initial-loc (point-marker)) - ;; Store position for return with `pop-tag-mark' - (ring-insert find-tag-marker-ring initial-loc)))) + (save-excursion + (goto-char initial-loc) + (set-mark-command nil) + ;; Store position for return with `xref-pop-marker-stack' + (xref-push-marker-stack))))) ;;;###autoload (defun haskell-mode-goto-loc () @@ -380,7 +383,7 @@ command from GHCi." (defun haskell-mode-goto-span (span) "Jump to the span, whatever file and line and column it needs to to get there." - (ring-insert find-tag-marker-ring (point-marker)) + (xref-push-marker-stack) (find-file (expand-file-name (plist-get span :path) (haskell-session-cabal-dir (haskell-interactive-session)))) (goto-char (point-min)) diff --git a/inf-haskell.el b/inf-haskell.el index 86ace1cc1..002ee7023 100644 --- a/inf-haskell.el +++ b/inf-haskell.el @@ -32,6 +32,7 @@ (require 'comint) (require 'shell) ; For directory tracking. +(require 'xref) (require 'compile) (require 'haskell-mode) (require 'haskell-decl-scan) @@ -568,7 +569,7 @@ The returned info is cached for reuse by `haskell-doc-mode'." (setq file (expand-file-name file))) ;; Push current location marker on the ring used by `find-tag' (require 'etags) - (ring-insert find-tag-marker-ring (point-marker)) + (xref-push-marker-stack) (pop-to-buffer (find-file-noselect file)) (when line (goto-char (point-min)) From f1a59840d8f68ef59fddf5eba8ed316874c38f5e Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Sun, 22 Feb 2015 20:43:40 +0100 Subject: [PATCH 2/3] Add aliases to provide backward compatibility --- haskell-commands.el | 1 + haskell-compat.el | 14 ++++++++++++++ inf-haskell.el | 1 + 3 files changed, 16 insertions(+) diff --git a/haskell-commands.el b/haskell-commands.el index 97e1acb2d..767ac8edb 100644 --- a/haskell-commands.el +++ b/haskell-commands.el @@ -18,6 +18,7 @@ ;;; Code: (require 'cl-lib) +(require 'haskell-compat) (require 'xref) (require 'haskell-process) (require 'haskell-font-lock) diff --git a/haskell-compat.el b/haskell-compat.el index a15a79336..8a409d3f8 100644 --- a/haskell-compat.el +++ b/haskell-compat.el @@ -31,6 +31,20 @@ A process is considered alive if its status is `run', `open', (memq (process-status process) '(run open listen connect stop)))) +;; Cross-referencing commands have been replaced since Emacs 25.1. +;; These aliases are required to provide backward compatibility. +(unless (require 'xref nil 'noerror) + (defalias 'xref-pop-marker-stack 'pop-tag-mark) + + (defun xref-push-marker-stack () + "Add point to the marker stack." + (require 'ring) + (defvar find-tag-marker-ring) + + (ring-insert find-tag-marker-ring (point-marker))) + + (provide 'xref)) + (provide 'haskell-compat) ;;; haskell-compat.el ends here diff --git a/inf-haskell.el b/inf-haskell.el index 002ee7023..76e6563d8 100644 --- a/inf-haskell.el +++ b/inf-haskell.el @@ -32,6 +32,7 @@ (require 'comint) (require 'shell) ; For directory tracking. +(require 'haskell-compat) (require 'xref) (require 'compile) (require 'haskell-mode) From ce97865645cc177ab2fdd86d02df440a845b32ec Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Wed, 25 Feb 2015 21:42:29 +0100 Subject: [PATCH 3/3] Address @gracjan's comments --- haskell-compat.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/haskell-compat.el b/haskell-compat.el index 8a409d3f8..943971e0d 100644 --- a/haskell-compat.el +++ b/haskell-compat.el @@ -21,6 +21,8 @@ ;;; Commentary: ;;; Code: +(require 'xref nil 'noerror) +(require 'ring) ;; Missing in Emacs23, stolen from Emacs24's `subr.el' (unless (fboundp 'process-live-p) @@ -33,14 +35,12 @@ A process is considered alive if its status is `run', `open', ;; Cross-referencing commands have been replaced since Emacs 25.1. ;; These aliases are required to provide backward compatibility. -(unless (require 'xref nil 'noerror) +(unless (fboundp 'xref-push-marker-stack) (defalias 'xref-pop-marker-stack 'pop-tag-mark) (defun xref-push-marker-stack () "Add point to the marker stack." - (require 'ring) (defvar find-tag-marker-ring) - (ring-insert find-tag-marker-ring (point-marker))) (provide 'xref))