all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Felicián Németh" <felician.nemeth@gmail.com>
To: 34471@debbugs.gnu.org
Subject: bug#34471: [PATCH] Fix jumping to the current error in xref
Date: Wed, 13 Feb 2019 21:35:46 +0100	[thread overview]
Message-ID: <CAGLaV2Y7hsPC5gp134hGFgm0ab=qGp3uE5s_8OR7OHFLpEwWew@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 395 bytes --]

I sometimes find useful to return to the current reference after examining
its context. However, xref--next-error-function fails to jump to the
current reference. The following steps reproduce the problem.

emacs -Q lisp/progmodes/xref.el
M-? xref-make RET
n RET
M-<
C-u 0 M-g n

I know next-error + previous-error is a workaround, but the patch fixes the
bug.

Thanks,
Felicián

[-- Attachment #1.2: Type: text/html, Size: 591 bytes --]

[-- Attachment #2: 0001-Fix-jumping-to-the-current-error-in-xref.patch --]
[-- Type: text/x-patch, Size: 1095 bytes --]

From c774e643437d4fe7a2a89106032ec377b28ce369 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@gmail.com>
Date: Wed, 13 Feb 2019 21:19:36 +0100
Subject: [PATCH] Fix jumping to the current error in xref

* xref.el (xref--next-error-function): Handle the corner case of
n==0.
---
 lisp/progmodes/xref.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9522d7e475..6974d00048 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -694,8 +694,10 @@ xref--next-error-function
   (let ((backward (< n 0))
         (n (abs n))
         (xref nil))
-    (dotimes (_ n)
-      (setq xref (xref--search-property 'xref-item backward)))
+    (if (= n 0)
+        (setq xref (get-text-property (point) 'xref-item))
+      (dotimes (_ n)
+        (setq xref (xref--search-property 'xref-item backward))))
     (cond (xref
            ;; Save the current position (when the buffer is visible,
            ;; it gets reset to that window's point from time to time).
-- 
2.11.0


             reply	other threads:[~2019-02-13 20:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 20:35 Felicián Németh [this message]
2019-02-22  7:47 ` bug#34471: [PATCH] Fix jumping to the current error in xref Eli Zaretskii
2019-02-22 18:36   ` Dmitry Gutov
2019-02-23  9:38     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGLaV2Y7hsPC5gp134hGFgm0ab=qGp3uE5s_8OR7OHFLpEwWew@mail.gmail.com' \
    --to=felician.nemeth@gmail.com \
    --cc=34471@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.