From: João Távora Date: Mon, 11 Feb 2019 21:33:49 +0000 (+0000) Subject: Don't sort xref's by default X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~333 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e123f41b9b2bc1b0c3ae9728362217bfc5a4770c;p=emacs.git 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 --- 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)))