From e123f41b9b2bc1b0c3ae9728362217bfc5a4770c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 11 Feb 2019 21:33:49 +0000 Subject: [PATCH] Don't sort xref's by default But use a eglot-xref-lessp-function in case someone wants to tweak this. * eglot.el (eglot-xref-lessp-function): New variable. (eglot--handling-xrefs): Use it. GitHub-reference: fix https://github.com/joaotavora/eglot/issues/220 --- lisp/progmodes/eglot.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 79e414646b3..4fdd5c4e5be 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1678,13 +1678,13 @@ DUMMY is ignored." (defvar eglot--temp-location-buffers (make-hash-table :test #'equal) "Helper variable for `eglot--handling-xrefs'.") +(defvar eglot-xref-lessp-function #'ignore + "Compare two `xref-item' objects for sorting.") + (defmacro eglot--handling-xrefs (&rest body) "Properly sort and handle xrefs produced and returned by BODY." `(unwind-protect - (sort (progn ,@body) - (lambda (a b) - (< (xref-location-line (xref-item-location a)) - (xref-location-line (xref-item-location b))))) + (sort (progn ,@body) eglot-xref-sort-function) (maphash (lambda (_uri buf) (kill-buffer buf)) eglot--temp-location-buffers) (clrhash eglot--temp-location-buffers))) -- 2.39.2